Question

The problem is when file path is pretty long each time I save it, minibuffer height grows and basically immediately shrinks. Kind of annoying because happens so often.

So I want to either shorten (basename?) the "wrote: ..." message or make default (starting) minibuffer height of 2 lines. Or maybe enable truncation in minibuffer only but that's not really good.

Is there a way?

Was it helpful?

Solution

Edit: I just noticed the message-truncate-lines variable and, unlike resize-mini-windows and max-mini-window-height, I can actually make this one behave the way I want:

(defadvice save-buffer (around my-save-mini-window-size)
  "Don't increase the size of the echo area if the path of the file being saved is too long to show on one line."
  (let ((message-truncate-lines t))
    ad-do-it))
(ad-activate 'save-buffer)

original answer follows (and I'm interested to know why setting the other variables with similar advice doesn't have the desired effect, if anyone can elaborate on that?)

I think messing with the message itself is going to be pretty hairy (and in any case a bad idea). write-region (in fileio.c) does say of its arguments If VISIT is neither t nor nil nor a string, that means do not display the "Wrote file" message, but I strongly doubt that enforcing that would be sensible.

I think the only sane approach is to prevent the minibuffer from resizing regardless of the message length. The following will do this, but for more situations than just saving a file:

(setq resize-mini-windows nil)

My normal approach here would be to write some around advice for the function we're interested in (I was thinking save-buffer), to temporarily set that value, but for whatever reason that's not having the desired effect.

Similarly with using before-save-hook and after-save-hook to set and restore it.

There's also the max-mini-window-height variable, but that appears to be subject to the same issue when attempting to set it temporarily.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top