osdir.com
mailing list archive F.A.Q. -since 2001!

Subject: Re: how to make the "file has auto save
data..." message unskippable? - msg#00114

List: help-gnu-emacs-gnu

Mail Archive Navigation:
by Date: Prev Next Date Index by Thread: Prev Next Thread Index
Nobuko Three wrote:
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


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.

Thread at a glance:

Previous Message by Date:

how to make the "file has auto save data..." message unskippable?

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.

Next Message by Date:

Re: Arrow Keys?

use.address@xxxxxxxxxxxxxxxxxxx (Chris Gordon-Smith) writes: > Perhaps an expert can type slightly faster using C-N etc., but much > of my time in front of a keyboard is in any case spent thinking, so > any increase in typing speed would be marginal. Note that there are other good reasons besides the "home row advantage" (though that is quite real) to use the standard Emacs keybindings. They represent a sort of "system", and getting used to the C-f etc help you become familiar with it. By "system", I mean that e.g., C-f moves forward a character, M-f moves forward a word, C-M-f moves forward an expression, etc. By using C-u prefixes, you can then "amplify" these movements, again with fairly minimal finger movement (e.g. C-u C-u C-f moves forward 16 characters, etc -- and this is simpler to type than it looks: it's really "C- u u f", and the u and f keys are right under your fingers). Once your fingers start to feel comfortable with this, it _really_ helps make movement fast, easy, and precise. Then you'll start to understand why long-term Emacs users consider the arrow keys clumsy and awkward... -Miles -- "She looks like the wax version of herself." [Comment under a Paris Hilton fashion pic]

Previous Message by Thread:

how to make the "file has auto save data..." message unskippable?

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.

Next Message by Thread:

Re: Arrow Keys?

use.address@xxxxxxxxxxxxxxxxxxx (Chris Gordon-Smith) writes: > Perhaps an expert can type slightly faster using C-N etc., but much > of my time in front of a keyboard is in any case spent thinking, so > any increase in typing speed would be marginal. Note that there are other good reasons besides the "home row advantage" (though that is quite real) to use the standard Emacs keybindings. They represent a sort of "system", and getting used to the C-f etc help you become familiar with it. By "system", I mean that e.g., C-f moves forward a character, M-f moves forward a word, C-M-f moves forward an expression, etc. By using C-u prefixes, you can then "amplify" these movements, again with fairly minimal finger movement (e.g. C-u C-u C-f moves forward 16 characters, etc -- and this is simpler to type than it looks: it's really "C- u u f", and the u and f keys are right under your fingers). Once your fingers start to feel comfortable with this, it _really_ helps make movement fast, easy, and precise. Then you'll start to understand why long-term Emacs users consider the arrow keys clumsy and awkward... -Miles -- "She looks like the wax version of herself." [Comment under a Paris Hilton fashion pic]

Home | News | Sitemap | FAQ | advertise | OSDir is an Inevitable website. GBiz & git.net are too!

Advertising by