unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* A *real* auto-save-mode?
@ 2008-01-23  6:21 shreevatsa
  2008-01-23  8:15 ` David Kastrup
  2008-01-23 13:01 ` Rupert Swarbrick
  0 siblings, 2 replies; 5+ messages in thread
From: shreevatsa @ 2008-01-23  6:21 UTC (permalink / raw)
  To: help-gnu-emacs

Hello,

Emacs has an auto-save-mode, which comes useful on rare occasions such
as crashes. However, what I (and apparently, many others) would like
is a feature that automatically saves your files for you -- not to
another file but to the one your buffer is visiting, and such that you
will not be prompted to save your file on exit.

There appears to be a variable auto-save-visited-file-name which is
documented as
    "Non-nil says auto-save a buffer in the file it is visiting, when
practical.
    Normally auto-save files are written under other names."
but setting it does not make for a very usable Emacs -- each time one
tries to edit the buffer after it is (auto-)saved, one is prompted
with a
    "file changed on disk; really edit the buffer? (y, n, r, or C-h)"
message, which gets annoying. [I guess I could turn on auto-revert-
mode to fix this, but I don't want auto-revert for changes from
external sources; I only want auto-save to work.]

I have also tried
    (add-hook 'auto-save-hook 'save-buffer)
but that seems to take effect on all buffers, even completion buffers
and the minibuffer! (Why does auto-save act on these buffers anyway?)

Thanks for any advice on what to do,
Shreevatsa

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: A *real* auto-save-mode?
  2008-01-23  6:21 shreevatsa
@ 2008-01-23  8:15 ` David Kastrup
  2008-01-23 13:01 ` Rupert Swarbrick
  1 sibling, 0 replies; 5+ messages in thread
From: David Kastrup @ 2008-01-23  8:15 UTC (permalink / raw)
  To: help-gnu-emacs

shreevatsa <shreevatsa.public@gmail.com> writes:

> Hello,
>
> Emacs has an auto-save-mode, which comes useful on rare occasions such
> as crashes. However, what I (and apparently, many others) would like
> is a feature that automatically saves your files for you -- not to
> another file but to the one your buffer is visiting, and such that you
> will not be prompted to save your file on exit.
>
> There appears to be a variable auto-save-visited-file-name which is
> documented as
>     "Non-nil says auto-save a buffer in the file it is visiting, when
> practical.
>     Normally auto-save files are written under other names."
> but setting it does not make for a very usable Emacs -- each time one
> tries to edit the buffer after it is (auto-)saved, one is prompted
> with a
>     "file changed on disk; really edit the buffer? (y, n, r, or C-h)"
> message, which gets annoying. [I guess I could turn on auto-revert-
> mode to fix this, but I don't want auto-revert for changes from
> external sources; I only want auto-save to work.]

You could try reporting this bug with
M-x report-emacs-bug RET
or the Help/Send Bug Report menu.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: A *real* auto-save-mode?
  2008-01-23  6:21 shreevatsa
  2008-01-23  8:15 ` David Kastrup
@ 2008-01-23 13:01 ` Rupert Swarbrick
  1 sibling, 0 replies; 5+ messages in thread
From: Rupert Swarbrick @ 2008-01-23 13:01 UTC (permalink / raw)
  To: help-gnu-emacs

On Tue, 22 Jan 2008 22:21:06 -0800, shreevatsa wrote:

> Hello,
> 
> Emacs has an auto-save-mode, which comes useful on rare occasions such
> as crashes. However, what I (and apparently, many others) would like is
> a feature that automatically saves your files for you -- not to another
> file but to the one your buffer is visiting, and such that you will not
> be prompted to save your file on exit.

No doubt one could hack together some elisp using run-at-time and saving 
or something.

However, you might want to consider that one often writes a few lines, 
then looks at it, then decides whether it should be saved or not. I find 
this useful as a sort of "1st stage quality control check".

Imagine you were hacking on a program, and your (rubbish) changes got 
saved automatically and invisibly. You then get bored of trying to fix 
something that isn't working and navigate to other buffers, forgetting 
about the original file, exiting emacs and losing any undo info that may 
have existed. Then you're back to the last checkout from version control. 
A bit of a disaster, no?

Rupert

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: A *real* auto-save-mode?
@ 2008-01-23 22:37 martin rudalics
  0 siblings, 0 replies; 5+ messages in thread
From: martin rudalics @ 2008-01-23 22:37 UTC (permalink / raw)
  To: shreevatsa.public; +Cc: help-gnu-emacs

 > Emacs has an auto-save-mode, which comes useful on rare occasions such
 > as crashes. However, what I (and apparently, many others) would like
 > is a feature that automatically saves your files for you -- not to
 > another file but to the one your buffer is visiting, and such that you
 > will not be prompted to save your file on exit.

`auto-save-mode' is based on a timer.  There's no guarantee that the
timer has completed its latest round when you "exit".

 > There appears to be a variable auto-save-visited-file-name which is
 > documented as
 >     "Non-nil says auto-save a buffer in the file it is visiting, when
 > practical.
 >     Normally auto-save files are written under other names."
 > but setting it does not make for a very usable Emacs -- each time one
 > tries to edit the buffer after it is (auto-)saved, one is prompted
 > with a
 >     "file changed on disk; really edit the buffer? (y, n, r, or C-h)"
 > message, which gets annoying. [I guess I could turn on auto-revert-
 > mode to fix this, but I don't want auto-revert for changes from
 > external sources; I only want auto-save to work.]

Setting `auto-save-visited-file-name' can be harmful.  See, for example,

http://lists.gnu.org/archive/html/emacs-devel/2003-10/msg00306.html

and

http://lists.gnu.org/archive/html/bug-gnu-emacs/2007-11/msg00077.html

If these threads do not convince you feel free to send a bug report.

Better yet: Help us find out why and how it doesn't work ;-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: A *real* auto-save-mode?
       [not found] <mailman.6455.1201127795.18990.help-gnu-emacs@gnu.org>
@ 2008-02-01  5:28 ` shreevatsa
  0 siblings, 0 replies; 5+ messages in thread
From: shreevatsa @ 2008-02-01  5:28 UTC (permalink / raw)
  To: help-gnu-emacs

On Jan 23, 5:37 pm, martin rudalics <rudal...@gmx.at> wrote:
>  > Emacs has an auto-save-mode, which comes useful on rare occasions such
>  > as crashes. However, what I (and apparently, many others) would like
>  > is a feature that automatically saves your files for you -- not to
>  > another file but to the one your buffer is visiting, and such that you
>  > will not be prompted to save your file on exit.
>
[...]
>
> Setting `auto-save-visited-file-name' can be harmful.  See, for example,
>
> http://lists.gnu.org/archive/html/emacs-devel/2003-10/msg00306.html
>
> and
>
> http://lists.gnu.org/archive/html/bug-gnu-emacs/2007-11/msg00077.html
>
> If these threads do not convince you feel free to send a bug report.
>
> Better yet: Help us find out why and how it doesn't work ;-)

Thanks for those. I was planning to post a detailed post summarising
those two threads and the issues that still exist (I'm convinced
setting `auto-save-visited-file-name' is harmful, not that the bugs
have been fixed), but I no longer feel as interested... I think that
feature should be removed if it's buggy; that's all I can say.

Anyway, for completeness, stating that this is the solution I'm using
now, and it seems to do what I want:

(defun save-buffer-if-visiting-file (&optional args)
"Save the current buffer only if it is visiting a file"
(interactive)
(if (buffer-file-name)
(save-buffer args)))

(add-hook 'auto-save-hook 'save-buffer-if-visiting-file)

Thanks for your help,
I'm sorry I'm not using a "standard" Emacs so I can't submit a bug
report,

-S


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-02-01  5:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-23 22:37 A *real* auto-save-mode? martin rudalics
     [not found] <mailman.6455.1201127795.18990.help-gnu-emacs@gnu.org>
2008-02-01  5:28 ` shreevatsa
  -- strict thread matches above, loose matches on Subject: below --
2008-01-23  6:21 shreevatsa
2008-01-23  8:15 ` David Kastrup
2008-01-23 13:01 ` Rupert Swarbrick

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).