help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Killing Buffers


From: Kevin Rodgers
Subject: Re: Killing Buffers
Date: Tue, 13 Jan 2004 09:07:26 -0700
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2

Brian Palmer wrote:
> Bruce Ingalls <bingalls@fit-zones.NO-SPAM.com> writes:
>>Brian Palmer wrote:
>>>(defun kill-all-other-buffer-frames (&optional prefix)
>>
>>Thanks for pointing out inelegancies in the code. Unfortunately, your
>>changes always leave the *scratch* buffer, and never the current
>>buffer. :(
>
> Sorry 'bout that. It's as simple as changing, in
> kill-all-other-buffer-frames
> (buffers-to-kill (buffer-list)))
> to
> (buffers-to-kill (mapcar 'buffer-name (buffer-list))))

How could that have any effect?  Each element of buffers-to-kill is
passed directly to kill-buffer, which handles a buffer or a buffer name
the same.  And if you used buffers instead of names, you could use delq
instead of delete.

On a stylistic note, you use setf from the Common Lisp compatibility
library, but call mapcar without side effect instead of using the
(CL-inspired) mapc built-in function.

> (Tested and verified).
>
> (defun kill-all-other-buffer-frames (&optional prefix)
>   "Close other open files, and kill other frames and windows.  With
> prefix argument, kill all buffers, leaving only the default *scratch*
> buffer."
>    (interactive "P")
>    (let ((cur-buf-name (buffer-name))
>          (buffers-to-kill (mapcar 'buffer-name (buffer-list))))
>      (if (null prefix)
>        (setf buffers-to-kill (delete cur-buf-name buffers-to-kill)))
>
>      (mapcar 'delete-frame (cdr (visible-frame-list)))
>      (or (one-window-p)
>          (delete-window))
>      (mapcar 'kill-buffer buffers-to-kill)
>      (delete-other-windows)))

--
Kevin Rodgers



reply via email to

[Prev in Thread] Current Thread [Next in Thread]