all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Colin S. Miller" <no-spam-thank-you@csmiller.demon.co.uk>
To: help-gnu-emacs@gnu.org
Subject: Re: how to make the "file has auto save data..." message unskippable?
Date: Sun, 05 Jul 2009 22:49:20 +0100	[thread overview]
Message-ID: <4a511fcb$0$48234$14726298@news.sunsite.dk> (raw)
In-Reply-To: <mailman.1874.1246814962.2239.help-gnu-emacs@gnu.org>

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.


       reply	other threads:[~2009-07-05 21:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.1874.1246814962.2239.help-gnu-emacs@gnu.org>
2009-07-05 21:49 ` Colin S. Miller [this message]
2009-07-05 17:29 how to make the "file has auto save data..." message unskippable? Nobuko Three
2009-07-06  8:57 ` Thien-Thi Nguyen
2009-07-06 12:14   ` ken
2009-07-08  6:09     ` Kevin Rodgers
2009-07-06 18:58   ` Sean Sieger
2009-07-07  6:35 ` Kevin Rodgers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='4a511fcb$0$48234$14726298@news.sunsite.dk' \
    --to=no-spam-thank-you@csmiller.demon.co.uk \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.