GNU bug report logs - #25478
26.0.50; No hooks are called when auto-saving

Previous Next

Package: emacs;

Reported by: Philipp Stephani <p.stephani2 <at> gmail.com>

Date: Wed, 18 Jan 2017 21:40:01 UTC

Severity: wishlist

Found in version 26.0.50

Done: Stefan Kangas <stefan <at> marxist.se>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Philipp Stephani <p.stephani2 <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>, Glenn Morris <rgm <at> gnu.org>
Cc: 25478 <at> debbugs.gnu.org
Subject: bug#25478: 26.0.50; No hooks are called when auto-saving
Date: Sun, 26 Mar 2017 18:21:01 +0000
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> schrieb am Fr., 20. Jan. 2017 um 09:45 Uhr:

> > From: Glenn Morris <rgm <at> gnu.org>
> > Date: Thu, 19 Jan 2017 15:29:04 -0500
> > Cc: 25478 <at> debbugs.gnu.org
> >
> > Philipp Stephani wrote:
> >
> > > The Emacs manual states:
> > >
> > > "If you want auto-saving to be done in the visited file rather than in
> > > a separate auto-save file, set the variable
> > > 'auto-save-visited-file-name' to a non-'nil' value.  In this mode,
> there
> > > is no real difference between auto-saving and explicit saving."
> > >
> > > However, there is a significant difference between auto-saving and
> > > explicit saving, even in this mode: auto-saving doesn't run
> > > before-save-hook, after-save-hook, write-contents-functions, or
> > > write-file-functions.  Either some of these hooks should be run during
> > > auto-saving if auto-save-visited-file-name is t, or new hooks should be
> > > created to run in this case.
> >
> > The phrasing of the manual can easily be changed if it's creating
> > unreasonable expectations.
>
> I've done that now on the release branch.
>
> > Do you have a use case for autosave running hooks?
> > One could argue that it is a low-level
> > operation that should not be modifiable in this way.
>
> Auto-save has its own hook.  But that's just the tip of an iceberg,
> because nowadays various modes can completely change what happens at
> save-buffer time by using the hooks mentioned above, and those hooks
> run only when basic-save-buffer is invoked; they won't be run during
> auto-saving.
>
> And there are other differences, too.  E.g., if save-buffer asks the
> user for a suitable encoding, it will record the value used in
> buffer-file-coding-system, so that future saves reuse that
> automatically.  Auto-saving doesn't record the value, so if the user
> doesn't change the buffer's file encoding manually, she will be
> prompted to provide an encoding on every auto-save.
>
> All in all, I think this option is subtly dangerous and should be
> either deprecated or completely reimplemented to invoke
> basic-save-buffer instead.  I'm quite sure this option made sense in
> the past, when complications with encoding and save-related hooks
> didn't exist, but that is no longer the case in Emacs these days.
> If someone thinks using this option will allow them not to bother with
> saving their edits, they are in for an unpleasant surprise.
>
>
That's quite unfortunate, as not having to bother with saving edits
manually is a very desirable feature that I think Emacs should offer out of
the box.

If you really want to deprecate auto-save-visited-file-name, how about
adding a simple global minor mode that invokes save-some-buffers from an
idle timer to files.el?
[Message part 2 (text/html, inline)]

This bug report was last modified 4 years and 311 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.