From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Colin S. Miller" Newsgroups: gmane.emacs.help Subject: Re: how to make the "file has auto save data..." message unskippable? Date: Sun, 05 Jul 2009 22:49:20 +0100 Organization: SunSITE.dk - Supporting Open source Message-ID: <4a511fcb$0$48234$14726298@news.sunsite.dk> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1246833665 29004 80.91.229.12 (5 Jul 2009 22:41:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 5 Jul 2009 22:41:05 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jul 06 00:40:59 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MNaOH-0002Gr-Nj for geh-help-gnu-emacs@m.gmane.org; Mon, 06 Jul 2009 00:40:58 +0200 Original-Received: from localhost ([127.0.0.1]:54834 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MNaOH-0002Zs-5B for geh-help-gnu-emacs@m.gmane.org; Sun, 05 Jul 2009 18:40:57 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!kanaga.switch.ch!switch.ch!newsfeed3.funet.fi!newsfeed1.funet.fi!newsfeeds.funet.fi!uio.no!news.banetele.no!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail User-Agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103) Original-Newsgroups: gnu.emacs.help In-Reply-To: Original-Lines: 57 Original-NNTP-Posting-Host: 62.56.59.26 Original-X-Trace: news.sunsite.dk DXC=UnH]>g56dliG1[Bg<0aH5`\VT\m5_SIbfU_42Df:PaKhTcL2h5ahoTokF_>m>CYcVoJ List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:65793 Archived-At: 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.