How do I get emacs to show a short (not full) file path in the minibuffer when saving?

The problem is that the file path is quite long every time I save it, the minibuffer height grows and basically shrinks right away. The view is annoying because it happens so often.

So, I want to either shorten (basename?) The message "wrote: ..." or set the default minibuffer height (starting at 2 lines). Or it is possible to enable truncation only in the minibuffer, but this is not good.

Is there a way?

+3


source to share


1 answer


Edit: I just noticed a variable message-truncate-lines

and, unlike resize-mini-windows

and max-mini-window-height

, I can get it to 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)

      

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

I think messing around with the post itself would be pretty hairy (and a bad idea anyway). write-region

(in fileio.c) does talk about its arguments If VISIT is neither t nor nil nor a string, that means do not display the "Wrote file" message

, but I highly doubt that would be reasonable.

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



(setq resize-mini-windows nil)

      

My normal approach here would be to write some advice for the function we're interested in (I thought save-buffer

) to temporarily set this value, but for whatever reason that doesn't have the desired effect.

Similarly, the use of before-save-hook

and after-save-hook

for its installation and recovery.

There is also a variable max-mini-window-height

, but trying to set it temporarily brings up the same issue.

+4


source







All Articles