Subject: Re: how to make the "file has auto save
data..." message unskippable?
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?
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
This is probably not the neatest elisp, but it does the job.
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))))))
fun csm-check-recover ()
(let ((buffer-mtime) (autosave-mtime))
(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
(if (y-or-n-p (concat "file " (buffer-file-name)...
" has autosave
data. Recover? "))
(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.