unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* how to make the "file has auto save data..." message unskippable?
@ 2009-07-05 17:29 Nobuko Three
  2009-07-06  8:57 ` Thien-Thi Nguyen
  2009-07-07  6:35 ` how to make the "file has auto save data..." message unskippable? Kevin Rodgers
  0 siblings, 2 replies; 9+ messages in thread
From: Nobuko Three @ 2009-07-05 17:29 UTC (permalink / raw)
  To: Help-gnu-emacs


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.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to make the "file has auto save data..." message unskippable?
       [not found] <mailman.1874.1246814962.2239.help-gnu-emacs@gnu.org>
@ 2009-07-05 21:49 ` Colin S. Miller
  0 siblings, 0 replies; 9+ messages in thread
From: Colin S. Miller @ 2009-07-05 21:49 UTC (permalink / raw)
  To: help-gnu-emacs

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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to make the "file has auto save data..." message unskippable?
  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-06 18:58   ` Sean Sieger
  2009-07-07  6:35 ` how to make the "file has auto save data..." message unskippable? Kevin Rodgers
  1 sibling, 2 replies; 9+ messages in thread
From: Thien-Thi Nguyen @ 2009-07-06  8:57 UTC (permalink / raw)
  To: Help-gnu-emacs

() Nobuko Three <nbko3@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




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to make the "file has auto save data..." message unskippable?
  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
  1 sibling, 1 reply; 9+ messages in thread
From: ken @ 2009-07-06 12:14 UTC (permalink / raw)
  To: GNU Emacs List


On 07/06/2009 04:57 AM Thien-Thi Nguyen wrote:
> () Nobuko Three <nbko3@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

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.







^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to make the "file has auto save data..." message unskippable?
  2009-07-06  8:57 ` Thien-Thi Nguyen
  2009-07-06 12:14   ` ken
@ 2009-07-06 18:58   ` Sean Sieger
  2009-07-06 19:19     ` how to make the "file has auto save data..." messageunskippable? Drew Adams
  1 sibling, 1 reply; 9+ messages in thread
From: Sean Sieger @ 2009-07-06 18:58 UTC (permalink / raw)
  To: help-gnu-emacs

Thien-Thi Nguyen <ttn@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.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: how to make the "file has auto save data..." messageunskippable?
  2009-07-06 18:58   ` Sean Sieger
@ 2009-07-06 19:19     ` Drew Adams
  2009-07-06 20:04       ` Sean Sieger
  0 siblings, 1 reply; 9+ messages in thread
From: Drew Adams @ 2009-07-06 19:19 UTC (permalink / raw)
  To: 'Sean Sieger', help-gnu-emacs

>     `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).





^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to make the "file has auto save data..." messageunskippable?
  2009-07-06 19:19     ` how to make the "file has auto save data..." messageunskippable? Drew Adams
@ 2009-07-06 20:04       ` Sean Sieger
  0 siblings, 0 replies; 9+ messages in thread
From: Sean Sieger @ 2009-07-06 20:04 UTC (permalink / raw)
  To: help-gnu-emacs

"Drew Adams" <drew.adams@oracle.com> writes:

    >     `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' ...





^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to make the "file has auto save data..." message unskippable?
  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-07  6:35 ` Kevin Rodgers
  1 sibling, 0 replies; 9+ messages in thread
From: Kevin Rodgers @ 2009-07-07  6:35 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1032 bytes --]

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
> 
> 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

[-- Attachment #2: recover-this-file-find-file-hook.el --]
[-- Type: application/emacs-lisp, Size: 891 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to make the "file has auto save data..." message unskippable?
  2009-07-06 12:14   ` ken
@ 2009-07-08  6:09     ` Kevin Rodgers
  0 siblings, 0 replies; 9+ messages in thread
From: Kevin Rodgers @ 2009-07-08  6:09 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1059 bytes --]

ken wrote:
> On 07/06/2009 04:57 AM Thien-Thi Nguyen wrote:
>> () Nobuko Three <nbko3@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
> 
> 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

[-- Attachment #2: recover-this-file-find-file-hook.el --]
[-- Type: application/emacs-lisp, Size: 2829 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-07-08  6:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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-06 19:19     ` how to make the "file has auto save data..." messageunskippable? Drew Adams
2009-07-06 20:04       ` Sean Sieger
2009-07-07  6:35 ` how to make the "file has auto save data..." message unskippable? Kevin Rodgers
     [not found] <mailman.1874.1246814962.2239.help-gnu-emacs@gnu.org>
2009-07-05 21:49 ` Colin S. Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).