Discussion:
how to make the "file has auto save data..." message unskippable?
Nobuko Three
2009-07-05 17:29:13 UTC
Permalink
I open a file foo.txt and then my emacs displays the message:

foo.txt has auto save data; consider M-x recover-this-file

in the echo area, but the message rarely catches my attention because I
quickly start editing the file and that makes the message disappear before I
notice it.

Normally after emacs is crashed, you know you need to use M-x
recover-session, but it could happen that you go to lunch after crash, you
come back, you start emacs again, you forget to do recover-session and open
foo.bar and then also miss the "foo.txt has auto save data..." message.

How do you deal with this problem?

One idea is to make emacs change its background color whenever it echoes
such message. Even if you miss the message, you will always notice the
changed background color which reminds you to check the *Message* buffer.

Is there a hook I can use for this idea?
--
View this message in context: http://www.nabble.com/how-to-make-the-%22file-has-auto-save-data...%22-message-unskippable--tp24345123p24345123.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
Colin S. Miller
2009-07-05 21:49:20 UTC
Permalink
Post by Nobuko Three
foo.txt has auto save data; consider M-x recover-this-file
Is there a hook I can use for this idea?
Nobuko,
A slightly more drastic way of doing this is
to force you to make a choice when you open the file.

Adding the following code to your .emacs
will make emacs ask you if you want to recover the file
when the file is opened, emacs will beep at you until you answer.

This asks via a Y/N prompt.
If you want Yes/No prompt, change the y-or-n-p
to yes-or-no-p

This is probably not the neatest elisp, but it does the job.

HTH,
Colin S. Miller




(if (not (fboundp 'time-less-p))
; definition from xemacs21
(defun time-less-p (t1 t2)
"Say whether time value T1 is less than time value T2."
(or (< (car t1) (car t2))
(and (= (car t1) (car t2))
(< (nth 1 t1) (nth 1 t2))))))

(defun csm-check-recover ()
(interactive)
(let ((buffer-mtime) (autosave-mtime))
(progn
(setq buffer-mtime (nth 5 (file-attributes (buffer-file-name))))
(setq autosave-mtime (nth 5 (file-attributes (make-auto-save-file-name))))
(if (time-less-p buffer-mtime autosave-mtime)
(if (file-exists-p (make-auto-save-file-name))
(if (not (local-variable-p 'csm-check-recover-loop-block (current-buffer)))
(progn
(make-local-variable 'csm-check-recover-loop-block)
(if (y-or-n-p (concat "file " (buffer-file-name) " has autosave data. Recover? "))
(recover-file (buffer-file-name))
(kill-local-variable 'csm-check-recover-loop-block)))))))))

(add-hook 'find-file-hooks 'csm-check-recover)
--
Replace the obvious in my email address with the first three letters of the hostname to reply.
Thien-Thi Nguyen
2009-07-06 08:57:23 UTC
Permalink
() Nobuko Three <***@yahoo.com>
() Sun, 5 Jul 2009 10:29:13 -0700 (PDT)

Normally after emacs is crashed, you know you need to use M-x
recover-session, but it could happen that you go to lunch after
crash, you come back, you start emacs again, you forget to do
recover-session and open foo.bar and then also miss the
"foo.txt has auto save data..." message.

How do you deal with this problem?

Go to lunch before the crash!
Think faster but type slower!
Or, (setq message-log-max t),
+ `C-h e' every now and then.

thi
ken
2009-07-06 12:14:05 UTC
Permalink
Post by Thien-Thi Nguyen
() Sun, 5 Jul 2009 10:29:13 -0700 (PDT)
Normally after emacs is crashed, you know you need to use M-x
recover-session, but it could happen that you go to lunch after
crash, you come back, you start emacs again, you forget to do
recover-session and open foo.bar and then also miss the
"foo.txt has auto save data..." message.
How do you deal with this problem?
Go to lunch before the crash!
Think faster but type slower!
Or, (setq message-log-max t),
+ `C-h e' every now and then.
thi
In buffers which have auto-save data I'd like to see an orange
background. In addition, I'd like to hear a beep when I try to type
into that buffer with the standard message/prompt in the minibuffer that
there's auto-save data... should I pull it in or discard it.
Kevin Rodgers
2009-07-08 06:09:39 UTC
Permalink
Post by ken
Post by Thien-Thi Nguyen
() Sun, 5 Jul 2009 10:29:13 -0700 (PDT)
Normally after emacs is crashed, you know you need to use M-x
recover-session, but it could happen that you go to lunch after
crash, you come back, you start emacs again, you forget to do
recover-session and open foo.bar and then also miss the
"foo.txt has auto save data..." message.
How do you deal with this problem?
Go to lunch before the crash!
Think faster but type slower!
Or, (setq message-log-max t),
+ `C-h e' every now and then.
thi
In buffers which have auto-save data I'd like to see an orange
background. In addition, I'd like to hear a beep when I try to type
into that buffer with the standard message/prompt in the minibuffer that
there's auto-save data... should I pull it in or discard it.
Attached is code that does that, plus undoes all those effects when
you do recover the file.
--
Kevin Rodgers
Denver, Colorado, USA
Sean Sieger
2009-07-06 18:58:20 UTC
Permalink
Thien-Thi Nguyen <***@gnuvola.org> writes:

`C-h e'

Um, I don't do `C-h ?' enough, and I certainly will start using `C-h e'
instead of C-x b to get to *Messages*, Thi, thank you.
Drew Adams
2009-07-06 19:19:33 UTC
Permalink
Post by Thien-Thi Nguyen
`C-h e'
I certainly will start using `C-h e'
instead of C-x b to get to *Messages*
You can also click `mouse-1' in the echo area (minibuffer space, when the
minibuffer is not active).
Sean Sieger
2009-07-06 20:04:02 UTC
Permalink
Post by Thien-Thi Nguyen
`C-h e'
I certainly will start using `C-h e'
instead of C-x b to get to *Messages*
You can also click `mouse-1' in the echo area (minibuffer space, when the
minibuffer is not active).

Funny thing about my relationship with GNU/Emacs is that I never use a
mouse to interact with it. Never. But I've strayed far from `auto
save' ...
Kevin Rodgers
2009-07-07 06:35:55 UTC
Permalink
Post by Nobuko Three
foo.txt has auto save data; consider M-x recover-this-file
in the echo area, but the message rarely catches my attention because I
quickly start editing the file and that makes the message disappear before I
notice it.
Normally after emacs is crashed, you know you need to use M-x
recover-session, but it could happen that you go to lunch after crash, you
come back, you start emacs again, you forget to do recover-session and open
foo.bar and then also miss the "foo.txt has auto save data..." message.
How do you deal with this problem?
One idea is to make emacs change its background color whenever it echoes
such message. Even if you miss the message, you will always notice the
changed background color which reminds you to check the *Message* buffer.
Is there a hook I can use for this idea?
Here's a start (recover-this-file-find-file-hook.el attached).
--
Kevin Rodgers
Denver, Colorado, USA
Loading...