unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: Killing Buffers
Date: Tue, 13 Jan 2004 09:07:26 -0700	[thread overview]
Message-ID: <400417BD.7050203@yahoo.com> (raw)
In-Reply-To: 0whbrp9tdkl.fsf@rescomp.Stanford.EDU

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	other threads:[~2004-01-13 16:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-29 13:34 Killing Buffers Edward Wijaya
2003-12-29  6:27 ` Friedrich Dominicus
2003-12-29  6:55 ` Eli Zaretskii
2004-01-02 18:49 ` Bruce Ingalls
2004-01-02 20:54   ` Brian Palmer
2004-01-03  3:46     ` Andi Kleen
2004-01-05 19:27       ` Kevin Rodgers
2004-01-03 13:51     ` Bruce Ingalls
2004-01-12 15:02       ` Brian Palmer
2004-01-13 16:07         ` Kevin Rodgers [this message]
2004-01-14 18:21           ` Brian Palmer
  -- strict thread matches above, loose matches on Subject: below --
2004-01-02 22:28 Edward Wijaya

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=400417BD.7050203@yahoo.com \
    --to=ihs_4664@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).