all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Keep losing work in non-file-visiting buffers
@ 2003-12-02 21:15 sebyte
  2003-12-02 23:42 ` Kevin Rodgers
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: sebyte @ 2003-12-02 21:15 UTC (permalink / raw)


Hi all.

	Anyone know of a variable/method/function that will prompt you to save your 
work in non-file-visiting buffers before you kill them or kill your emacs session?

sebyte

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

* Re: Keep losing work in non-file-visiting buffers
  2003-12-02 21:15 Keep losing work in non-file-visiting buffers sebyte
@ 2003-12-02 23:42 ` Kevin Rodgers
  2003-12-03 17:34   ` sebyte
  2003-12-03 22:09   ` sebyte
  2003-12-04 16:56 ` Johan Bockgård
  2003-12-04 23:29 ` Stefan Monnier
  2 siblings, 2 replies; 13+ messages in thread
From: Kevin Rodgers @ 2003-12-02 23:42 UTC (permalink / raw)


sebyte wrote:

>     Anyone know of a variable/method/function that will prompt you to 
> save your work in non-file-visiting buffers before you kill them or kill 
> your emacs session?

(setq-default buffer-offer-save t)	; for save-buffers-kill-emacs


(add-hook 'kill-buffer-query-functions	; for kill-buffer
           (lambda ()
             (or buffer-file-name
                 (not (buffer-modified-p))
                 (yes-or-no-p (format "Buffer %s modified; kill anyway? "
                                      (buffer-name))))))

-- 
Kevin Rodgers

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

* Re: Keep losing work in non-file-visiting buffers
  2003-12-02 23:42 ` Kevin Rodgers
@ 2003-12-03 17:34   ` sebyte
  2003-12-03 22:09   ` sebyte
  1 sibling, 0 replies; 13+ messages in thread
From: sebyte @ 2003-12-03 17:34 UTC (permalink / raw)


> (setq-default buffer-offer-save t)    ; for save-buffers-kill-emacs
> 
> 
> (add-hook 'kill-buffer-query-functions    ; for kill-buffer
>           (lambda ()
>             (or buffer-file-name
>                 (not (buffer-modified-p))
>                 (yes-or-no-p (format "Buffer %s modified; kill anyway? "
>                                      (buffer-name))))))

thanks Kevin. works like a dream.

sebyte

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

* Re: Keep losing work in non-file-visiting buffers
  2003-12-02 23:42 ` Kevin Rodgers
  2003-12-03 17:34   ` sebyte
@ 2003-12-03 22:09   ` sebyte
  2003-12-03 23:18     ` Kevin Rodgers
  1 sibling, 1 reply; 13+ messages in thread
From: sebyte @ 2003-12-03 22:09 UTC (permalink / raw)


> (setq-default buffer-offer-save t)    ; for save-buffers-kill-emacs
> 
> 
> (add-hook 'kill-buffer-query-functions    ; for kill-buffer
>           (lambda ()
>             (or buffer-file-name
>                 (not (buffer-modified-p))
>                 (yes-or-no-p (format "Buffer %s modified; kill anyway? "
>                                      (buffer-name))))))

actually works too well! am forever being prompted re: buffers that *should* be 
killed without asking, eg, info, help, gnus buffers etc.  oh well, can't have 
everything your own way i suppose.

sebyte

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

* Re: Keep losing work in non-file-visiting buffers
  2003-12-03 22:09   ` sebyte
@ 2003-12-03 23:18     ` Kevin Rodgers
  2003-12-04 21:15       ` sebyte
  2003-12-04 23:14       ` sebyte
  0 siblings, 2 replies; 13+ messages in thread
From: Kevin Rodgers @ 2003-12-03 23:18 UTC (permalink / raw)


sebyte wrote:

> actually works too well! am forever being prompted re: buffers that 
> *should* be killed without asking, eg, info, help, gnus buffers etc.  oh 
> well, can't have everything your own way i suppose.

Since *info* and *Help* buffers are never(?) marked as modified, I guess

it's actually save-buffers-kill-emacs (C-x C-c) that's holding you up, not
kill-buffer (C-x k).  And that means it's buffer-offer-save that's at fault,
not kill-buffer-query-functions.


So maybe you just want to turn on buffer-offer-save for buffers you explictly
create, as with switch-to-buffer (C-x b), instead of buffers Emacs creates for
you:

(defadvice switch-to-buffer (after buffer-offer-save activate)
   "Set `buffer-offer-save' when called interactively."
   (and (interactive-p)
        (setq buffer-offer-save t))) ; automatically local in all buffers

-- 
Kevin Rodgers

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

* Re: Keep losing work in non-file-visiting buffers
  2003-12-02 21:15 Keep losing work in non-file-visiting buffers sebyte
  2003-12-02 23:42 ` Kevin Rodgers
@ 2003-12-04 16:56 ` Johan Bockgård
  2003-12-04 23:29 ` Stefan Monnier
  2 siblings, 0 replies; 13+ messages in thread
From: Johan Bockgård @ 2003-12-04 16:56 UTC (permalink / raw)


sebyte <sdt133@netscape.net> writes:

> work in non-file-visiting buffers

Simple answer: Don't do that!

-- 
Johan Bockgård

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

* Re: Keep losing work in non-file-visiting buffers
  2003-12-03 23:18     ` Kevin Rodgers
@ 2003-12-04 21:15       ` sebyte
  2003-12-04 23:14       ` sebyte
  1 sibling, 0 replies; 13+ messages in thread
From: sebyte @ 2003-12-04 21:15 UTC (permalink / raw)


Kevin,

> Since *info* and *Help* buffers are never(?) marked as modified, I guess
> it's actually save-buffers-kill-emacs (C-x C-c) that's holding you up, not
> kill-buffer (C-x k).  And that means it's buffer-offer-save that's at 
> fault, not kill-buffer-query-functions.
> 
> So maybe you just want to turn on buffer-offer-save for buffers you 
> explictly create, as with switch-to-buffer (C-x b), instead of buffers Emacs 
> creates for you:
> 
> (defadvice switch-to-buffer (after buffer-offer-save activate)
>   "Set `buffer-offer-save' when called interactively."
>   (and (interactive-p)
>        (setq buffer-offer-save t))) ; automatically local in all buffers
> 

this time it really does work like a dream.  Johan Bockgard's hack also works 
but offers no failed memory protection and is consequently not very helpful.  i 
therefore extend my thanks just to you.

sebyte

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

* Re: Keep losing work in non-file-visiting buffers
  2003-12-03 23:18     ` Kevin Rodgers
  2003-12-04 21:15       ` sebyte
@ 2003-12-04 23:14       ` sebyte
  2003-12-05 18:26         ` Kevin Rodgers
  1 sibling, 1 reply; 13+ messages in thread
From: sebyte @ 2003-12-04 23:14 UTC (permalink / raw)


 > Since *info* and *Help* buffers are never(?) marked as modified, I guess
 > it's actually save-buffers-kill-emacs (C-x C-c) that's holding you up, not
 > kill-buffer (C-x k).  And that means it's buffer-offer-save that's at fault,
 > not kill-buffer-query-functions.
 >
 > So maybe you just want to turn on buffer-offer-save for buffers you explictly 
 > create, as with switch-to-buffer (C-x b), instead of buffers Emacs creates 
for > you:
 >
 > (defadvice switch-to-buffer (after buffer-offer-save activate)
 >   "Set `buffer-offer-save' when called interactively."
 >   (and (interactive-p)
 >        (setq buffer-offer-save t))) ; automatically local in all buffers

once again i've spoken too soon. things are much better but still not perfect. 
there are buffers in use that don't appear in *Buffer List* such as *temp* which 
i have to kill each time I use 'C-x d' to view a directory.  also Python mode 
uses temporary buffers which I now have to 'confirm kill'.

this is proving to be a lot more involved than i thought.  i just wish i knew 
even a tiny little amount of elisp and could do some problem solving on this one 
myself.  i will learn, eventually...

sebyte

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

* Re: Keep losing work in non-file-visiting buffers
  2003-12-02 21:15 Keep losing work in non-file-visiting buffers sebyte
  2003-12-02 23:42 ` Kevin Rodgers
  2003-12-04 16:56 ` Johan Bockgård
@ 2003-12-04 23:29 ` Stefan Monnier
  2003-12-04 23:35   ` Jesper Harder
  2 siblings, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2003-12-04 23:29 UTC (permalink / raw)


> 	Anyone know of a variable/method/function that will prompt you to
> 	save your work in non-file-visiting buffers before you kill them or
> 	kill your emacs session?

Good point.  I suffer from something similar with Gnus message buffers
getting lost when my Emacs crashes (or my network connection goes down).
Does anyone know how to make them autosave into the drafts buffer


        Stefan

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

* Re: Keep losing work in non-file-visiting buffers
  2003-12-04 23:29 ` Stefan Monnier
@ 2003-12-04 23:35   ` Jesper Harder
  2003-12-05  0:05     ` Stefan Monnier
  0 siblings, 1 reply; 13+ messages in thread
From: Jesper Harder @ 2003-12-04 23:35 UTC (permalink / raw)


Stefan Monnier <monnier@iro.umontreal.ca> writes:

> Good point.  I suffer from something similar with Gnus message buffers
> getting lost when my Emacs crashes (or my network connection goes down).
> Does anyone know how to make them autosave into the drafts buffer

This seems to be the default in Gnus 5.10 -- in this Message buffer I
get:

,----[ C-h v buffer-auto-save-file-name RET ]
| buffer-auto-save-file-name's value is 
| "/home/harder/News/drafts/drafts/#31#"
| Local in buffer *followup to Stefan Monnier on gnu.emacs.help,gnu.emacs.gnus*; global value is nil
| Automatically becomes buffer-local when set in any fashion.
| 
| Name of file for auto-saving current buffer.
| If it is nil, that means don't auto-save this buffer.
`----

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

* Re: Keep losing work in non-file-visiting buffers
  2003-12-04 23:35   ` Jesper Harder
@ 2003-12-05  0:05     ` Stefan Monnier
  2003-12-05  9:37       ` Jesper Harder
  0 siblings, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2003-12-05  0:05 UTC (permalink / raw)


>> Good point.  I suffer from something similar with Gnus message buffers
>> getting lost when my Emacs crashes (or my network connection goes down).
>> Does anyone know how to make them autosave into the drafts buffer

> This seems to be the default in Gnus 5.10 -- in this Message buffer I get:

> ,----[ C-h v buffer-auto-save-file-name RET ]
> | buffer-auto-save-file-name's value is 
> | "/home/harder/News/drafts/drafts/#31#"

But does it actually get auto-saved ?  I have pretty much the same value
as you do (with Gnus-5.9 from Emacs-CVS) but nothing gets saved: neither
drafts/#31# nor drafts/31.

Oh, I see it now: it only gets saved if I make modifications.
So I just need to get Emacs to mark the buffer as modified from the start
and it will get saved.  Good.

Now on to the next step: how do I make it so that #31# is listed in
the nndrafts:drafts folder ?

You see, I'd like to be able to hit `F' or `R' on messages to which I want
to reply and be sure that this will be remembered in nndrafts:drafts in case
I forget to reply and leave Emacs (willfully or not).


        Stefan

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

* Re: Keep losing work in non-file-visiting buffers
  2003-12-05  0:05     ` Stefan Monnier
@ 2003-12-05  9:37       ` Jesper Harder
  0 siblings, 0 replies; 13+ messages in thread
From: Jesper Harder @ 2003-12-05  9:37 UTC (permalink / raw)


Stefan Monnier <monnier@iro.umontreal.ca> writes:

> Now on to the next step: how do I make it so that #31# is listed in
> the nndrafts:drafts folder ?

It works for me.  It's possibly fixed since 5.9 -- ISTR some changes
related to this.

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

* Re: Keep losing work in non-file-visiting buffers
  2003-12-04 23:14       ` sebyte
@ 2003-12-05 18:26         ` Kevin Rodgers
  0 siblings, 0 replies; 13+ messages in thread
From: Kevin Rodgers @ 2003-12-05 18:26 UTC (permalink / raw)


sebyte wrote:

> once again i've spoken too soon. things are much better but still not 
> perfect. there are buffers in use that don't appear in *Buffer List* 
> such as *temp* which i have to kill each time I use 'C-x d' to view a 
> directory.  also Python mode uses temporary buffers which I now have to 
> 'confirm kill'.

The buffers that are omitted from *Buffer List* have names that begin with

a space (C-h k C-x C-b):

(add-hook 'kill-buffer-query-functions	; for kill-buffer
           (lambda ()
             (or buffer-file-name
                 (not (buffer-modified-p))
		(equal (string-to-char (buffer-name)) ? )	; or *?
                 (yes-or-no-p (format "Buffer %s modified; kill anyway? "
                                      (buffer-name))))))

-- 
Kevin Rodgers

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

end of thread, other threads:[~2003-12-05 18:26 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-02 21:15 Keep losing work in non-file-visiting buffers sebyte
2003-12-02 23:42 ` Kevin Rodgers
2003-12-03 17:34   ` sebyte
2003-12-03 22:09   ` sebyte
2003-12-03 23:18     ` Kevin Rodgers
2003-12-04 21:15       ` sebyte
2003-12-04 23:14       ` sebyte
2003-12-05 18:26         ` Kevin Rodgers
2003-12-04 16:56 ` Johan Bockgård
2003-12-04 23:29 ` Stefan Monnier
2003-12-04 23:35   ` Jesper Harder
2003-12-05  0:05     ` Stefan Monnier
2003-12-05  9:37       ` Jesper Harder

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.