Menu

Make Emacs a bit quieter

The minibuffer is the area at the bottom of your Emacs frame where you interact with Emacs prompts, or type commands. It also doubles up as the echo area, where Emacs tells you useful things. However sometimes when Emacs is prompting me for an answer in the minibuffer, the prompt is hidden by a message so I can’t see what I’m being asked any more.

When this happens, I found it is almost always a message about a buffer being reverted or a file being auto-saved. These messages can be prevented from appearing in the echo area as follows.

The revert messages are easy to silence with the following setting:

;; turn off auto revert messages(setq auto-revert-verbose nil)

For the auto-save messages, it is a bit trickier. Some solutions suggest advising do-auto-save which is the function that does the actual job of auto-saving (e.g. this stackexchange question). However, this doesn’t work for Emacs 24.4 and newer since the call to do-auto-save bypasses the advice, for technical reasons I don’t fully understand!

A work around is to switch off the built-in auto-save, and replace it with our own silent version:

;; custom autosave to suppress messages;;;; For some reason `do-auto-save' doesn't work if called manually;; after switching off the default autosave altogether. Instead set;; to a long timeout so it is not called.(setq auto-save-timeout 99999);; Set up my timer(defvarbjm/auto-save-timer nil
"Timer to run `bjm/auto-save-silent'");; Auto-save every 5 seconds of idle time(defvarbjm/auto-save-interval 5
"How often in seconds of idle time to auto-save with `bjm/auto-save-silent'");; Function to auto save files silently(defunbjm/auto-save-silent()"Auto-save all buffers silently"(interactive)(do-auto-save t));; Start new timer(setq bjm/auto-save-timer
(run-with-idle-timer 0 bjm/auto-save-interval 'bjm/auto-save-silent))

Note that I found some strange behaviour that do-auto-save does not work if the built-in auto-save is switched off altogether using (setq auto-save-default nil), so instead I had to set it for a long timeout to prevent it from running.