unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Saving Buffer
@ 2003-01-20 18:23 CarlC
  2003-01-20 18:30 ` Phillip Lord
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: CarlC @ 2003-01-20 18:23 UTC (permalink / raw)


The function save-buffers-kill-emacs goes through each modified buffer with
a file assocation and asks "Save file /home/carl/trash? (y, n, !, ., q, C-r
or C-h)". Is this functionality available for a single (current) buffer? I
cannot find a command similar to this. I just want to say kill-buffer, but
ask to save if it is modified. I don't want it to kill-emacs.

Thanks.

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

* Re: Saving Buffer
  2003-01-20 18:23 Saving Buffer CarlC
@ 2003-01-20 18:30 ` Phillip Lord
  2003-01-20 19:33   ` CarlC
  2003-01-20 23:05 ` Galen Boyer
  2003-01-21 15:39 ` Kai Großjohann
  2 siblings, 1 reply; 9+ messages in thread
From: Phillip Lord @ 2003-01-20 18:30 UTC (permalink / raw)


>>>>> "CarlC" == CarlC  <carlc@snowbd.com> writes:

  CarlC> The function save-buffers-kill-emacs goes through each
  CarlC> modified buffer with a file assocation and asks "Save file
  CarlC> /home/carl/trash? (y, n, !, ., q, C-r or C-h)". Is this
  CarlC> functionality available for a single (current) buffer? I
  CarlC> cannot find a command similar to this. I just want to say
  CarlC> kill-buffer, but ask to save if it is modified. I don't want
  CarlC> it to kill-emacs.


This should be the default behaviour. Certainly if I do kill-buffer,
then I get "Buffer blah.txt modified: kill anyway?"

This doesn't happen if the buffer is not associated with a file. So
*scratch* can be killed in this way. If you want to stop this, you'll
need to add a function to "kill-buffer-hook" to query the user first. 

Phil

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

* Re: Saving Buffer
  2003-01-20 18:30 ` Phillip Lord
@ 2003-01-20 19:33   ` CarlC
  0 siblings, 0 replies; 9+ messages in thread
From: CarlC @ 2003-01-20 19:33 UTC (permalink / raw)



"Phillip Lord" <p.lord@russet.org.uk> wrote in message
news:vfk7gzlln4.fsf@rpc71.cs.man.ac.uk...
> >>>>> "CarlC" == CarlC  <carlc@snowbd.com> writes:
>
>   CarlC> The function save-buffers-kill-emacs goes through each
>   CarlC> modified buffer with a file assocation and asks "Save file
>   CarlC> /home/carl/trash? (y, n, !, ., q, C-r or C-h)". Is this
>   CarlC> functionality available for a single (current) buffer? I
>   CarlC> cannot find a command similar to this. I just want to say
>   CarlC> kill-buffer, but ask to save if it is modified. I don't want
>   CarlC> it to kill-emacs.
>
>
> This should be the default behaviour. Certainly if I do kill-buffer,
> then I get "Buffer blah.txt modified: kill anyway?"

Not exactly what one would want. I guess you have to do save-buffer and then
kill-buffer. Ugh.

> This doesn't happen if the buffer is not associated with a file. So
> *scratch* can be killed in this way. If you want to stop this, you'll
> need to add a function to "kill-buffer-hook" to query the user first.

That's what I was afraid of. Seems a shame to have to reinvent the wheel.

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

* Re: Saving Buffer
  2003-01-20 18:23 Saving Buffer CarlC
  2003-01-20 18:30 ` Phillip Lord
@ 2003-01-20 23:05 ` Galen Boyer
  2003-01-21  0:15   ` Stefan Monnier <foo@acm.com>
  2003-01-21  0:31   ` Henrik Enberg
  2003-01-21 15:39 ` Kai Großjohann
  2 siblings, 2 replies; 9+ messages in thread
From: Galen Boyer @ 2003-01-20 23:05 UTC (permalink / raw)


On Mon, 20 Jan 2003, carlc@snowbd.com wrote:
> The function save-buffers-kill-emacs goes through each modified buffer
> with a file assocation and asks "Save file /home/carl/trash? (y, n, !,
> ., q, C-r or C-h)". Is this functionality available for a single
> (current) buffer? I cannot find a command similar to this. I just want
> to say kill-buffer, but ask to save if it is modified. 

C-x k when you are within the buffer you want to kill.

> I don't want it to kill-emacs.

As an additional step (not really related to your issue,

(setq kill-emacs-query-functions
      (cons (lambda () (yes-or-no-p "Really kill Emacs? "))
			kill-emacs-query-functions))

This makes sure you don't kill Emacs when you didn't mean it. C-x C-c is
too easy to hit.

-- 
Galen deForest Boyer
Sweet dreams and flying machines in pieces on the ground.

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

* Re: Saving Buffer
  2003-01-20 23:05 ` Galen Boyer
@ 2003-01-21  0:15   ` Stefan Monnier <foo@acm.com>
  2003-01-21  0:31   ` Henrik Enberg
  1 sibling, 0 replies; 9+ messages in thread
From: Stefan Monnier <foo@acm.com> @ 2003-01-21  0:15 UTC (permalink / raw)


> (setq kill-emacs-query-functions
>       (cons (lambda () (yes-or-no-p "Really kill Emacs? "))
> 			kill-emacs-query-functions))
> This makes sure you don't kill Emacs when you didn't mean it. C-x C-c is
> too easy to hit.

`kill-emacs-query-functions' could actually contain a single function
rather than a list of functions.  For that reason and a bunch of others,
it is recommended to use

   (add-hook 'kill-emacs-query-functions
             (lambda () (yes-or-no-p "Really kill Emacs? ")))

instead.


        Stefan

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

* Re: Saving Buffer
  2003-01-20 23:05 ` Galen Boyer
  2003-01-21  0:15   ` Stefan Monnier <foo@acm.com>
@ 2003-01-21  0:31   ` Henrik Enberg
  2003-01-21  0:33     ` Henrik Enberg
  1 sibling, 1 reply; 9+ messages in thread
From: Henrik Enberg @ 2003-01-21  0:31 UTC (permalink / raw)


Galen Boyer <galenboyer@hotpop.com> writes:

> (setq kill-emacs-query-functions
>       (cons (lambda () (yes-or-no-p "Really kill Emacs? "))
> 			kill-emacs-query-functions))
>
> This makes sure you don't kill Emacs when you didn't mean it. C-x C-c is
> too easy to hit.

In Emacs 21 there is also `confirm-kill-emacs'.

(setq confirm-kill-emacs 'yes-or-nn-p)

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

* Re: Saving Buffer
  2003-01-21  0:31   ` Henrik Enberg
@ 2003-01-21  0:33     ` Henrik Enberg
  0 siblings, 0 replies; 9+ messages in thread
From: Henrik Enberg @ 2003-01-21  0:33 UTC (permalink / raw)


Henrik Enberg <henrik+news@enberg.org> writes:

> (setq confirm-kill-emacs 'yes-or-nn-p)
                                   ^^
Should be "no".

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

* Re: Saving Buffer
  2003-01-20 18:23 Saving Buffer CarlC
  2003-01-20 18:30 ` Phillip Lord
  2003-01-20 23:05 ` Galen Boyer
@ 2003-01-21 15:39 ` Kai Großjohann
  2003-01-21 16:26   ` Phillip Lord
  2 siblings, 1 reply; 9+ messages in thread
From: Kai Großjohann @ 2003-01-21 15:39 UTC (permalink / raw)


"CarlC" <carlc@snowbd.com> writes:

> The function save-buffers-kill-emacs goes through each modified buffer with
> a file assocation and asks "Save file /home/carl/trash? (y, n, !, ., q, C-r
> or C-h)". Is this functionality available for a single (current) buffer? I
> cannot find a command similar to this. I just want to say kill-buffer, but
> ask to save if it is modified. I don't want it to kill-emacs.

Maybe it's also enough to say C-x s (not C-x C-s)?  That goes through
the list of open files and asks about saving each of them.
-- 
Ambibibentists unite!

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

* Re: Saving Buffer
  2003-01-21 15:39 ` Kai Großjohann
@ 2003-01-21 16:26   ` Phillip Lord
  0 siblings, 0 replies; 9+ messages in thread
From: Phillip Lord @ 2003-01-21 16:26 UTC (permalink / raw)


>>>>> "Kai" == Kai Gro_johann <kai.grossjohann@uni-duisburg.de> writes:

  Kai> "CarlC" <carlc@snowbd.com> writes:
  >> The function save-buffers-kill-emacs goes through each modified
  >> buffer with a file assocation and asks "Save file
  >> /home/carl/trash?  (y, n, !, ., q, C-r or C-h)". Is this
  >> functionality available for a single (current) buffer? I cannot
  >> find a command similar to this. I just want to say kill-buffer,
  >> but ask to save if it is modified. I don't want it to kill-emacs.

  Kai> Maybe it's also enough to say C-x s (not C-x C-s)?  That goes
  Kai> through the list of open files and asks about saving each of
  Kai> them.  


Only on file associated buffers. 

I think what he is worried about is buffers which are not visiting a
file. 

Occasionally it can be annoying when you kill emacs when you wanted to
keep something. Personally I don't think querying for all buffers is
sensible, as there are likely to be more than the OP thinks. There are
a few, like "*mail*" for instance, though where it would be
useful. Although, personally, I think that the best solution is for
"*mail*" to actually be visiting a standard temporary file, which
would solve the problem another way. 

Phil

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

end of thread, other threads:[~2003-01-21 16:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-20 18:23 Saving Buffer CarlC
2003-01-20 18:30 ` Phillip Lord
2003-01-20 19:33   ` CarlC
2003-01-20 23:05 ` Galen Boyer
2003-01-21  0:15   ` Stefan Monnier <foo@acm.com>
2003-01-21  0:31   ` Henrik Enberg
2003-01-21  0:33     ` Henrik Enberg
2003-01-21 15:39 ` Kai Großjohann
2003-01-21 16:26   ` Phillip Lord

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