15

I want my documents to be auto-saved, but I don't want to be interrupted with the message "Auto-saving...done" every few minutes.

Is there a way to just disable this message, but not the auto-saving functionality?

I have tried the following without success: https://stackoverflow.com/questions/22511847/how-to-disable-auto-save-message

scaramouche
  • 1,772
  • 10
  • 24
  • 12
    Although the function `do-auto-save` admits an argument `t` to omit the message, in `keyboard.c` it is called with that argument hardcoded as `nil`. I suggest you open a bug report so that argument can be customized. – angus May 20 '15 at 19:10

4 Answers4

6

Is there a way to just disable this message, but not the auto-saving functionality?

Yes, Emacs 27 will introduce the user option auto-save-no-message:

auto-save-no-message is a variable defined in ‘keyboard.c’.
Its value is nil

  You can customize this variable.


This variable was introduced, or its default value was changed, in
version 27.1 of Emacs.

Documentation:
Non-nil means do not print any message when auto-saving.

Quoth (emacs) Auto Save:

18.6 Auto-Saving: Protection Against Disasters
==============================================

From time to time, Emacs automatically saves each visited file in a
separate file, without altering the file you actually use.  This is
called “auto-saving”.  It prevents you from losing more than a limited
amount of work if the system crashes.

   When Emacs determines that it is time for auto-saving, it considers
each buffer, and each is auto-saved if auto-saving is enabled for it and
it has been changed since the last time it was auto-saved.  When the
‘auto-save-no-message’ variable is set to ‘nil’ (the default), the
message ‘Auto-saving...’ is displayed in the echo area during
auto-saving, if any files are actually auto-saved; to disable these
messages, customize the variable to a non-‘nil’ value.  Errors occurring
during auto-saving are caught so that they do not interfere with the
execution of commands you have been typing.

To customise the variable, you can either M-xcustomize-variableRETauto-save-no-messageRET or simply:

(setq-default auto-save-no-message t)
Basil
  • 12,019
  • 43
  • 69
2

You can ensure do-auto-save is called with the correct argument to suppress the message by advising the function:

(defun my-auto-save-wrapper (save-fn &rest args)
  (apply save-fn '(t)))

(advice-add 'do-auto-save :around #'my-auto-save-wrapper)
stsquad
  • 4,626
  • 28
  • 45
  • This does not work (at least on Emacs 24.4.1). As mentioned by @angus, `do-auto-save` is not taking into account the arguments it receives. – scaramouche May 30 '15 at 00:04
  • @scaramouche: odd as I tested it on the HEAD of the emacs-24 branch and it worked fine. Although I was calling with M-x do-auto-save. – stsquad May 30 '15 at 18:10
0

because do-auto-save is called by c code here, so advice is not possible here.

we can use an idle timer. following code is tested.

(setq auto-save-list-file-prefix nil)
(setq auto-save-visited-file-name t)
(setq auto-save-timeout 0)
(setq auto-save-interval 0)

(defun my-auto-save-silent ()
  (do-auto-save t))

(run-with-idle-timer 1 t #'my-auto-save-silent)

also, cf. http://tinyurl.com/ydeyn4ks

FunkyBaby
  • 767
  • 1
  • 4
  • 10
  • I'd like to know why has this answer a 0 score. Are idle timers the wrong tool to get this job done? –  Dec 25 '19 at 12:25
0

Auto save runs auto-save-hook before saving so you can use this to temporary disable messages (they are still logged to the *Messages* buffer):

(add-hook 'auto-save-hook 'auto-save-silence+)

(defun auto-save-silence+ ()
  (setq inhibit-message t)
  (run-at-time 0 nil
               (lambda ()
                 (setq inhibit-message nil))))
clemera
  • 3,401
  • 13
  • 40