all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Brian Palmer <bpalmer@rescomp.Stanford.EDU>
Subject: Re: Killing Buffers
Date: 02 Jan 2004 12:54:49 -0800	[thread overview]
Message-ID: <0whr7yim5pi.fsf@rescomp.Stanford.EDU> (raw)
In-Reply-To: E2jJb.45068$cM1.7819212@twister.nyc.rr.com

Bruce Ingalls <bingalls@fit-zones.NO-SPAM.com> writes:

> ;I believe I have merged recent posts of buffer killing code into the
> ;best practices of all, combined here.
> ;Since the code works, I am too lazy to re-use
> ;kill-all-other-buffer-frames() to call kill-buffer-frame() but will
> ;gladly accept patches. Happy Holidays, Bruce

Interesting; I doubt I'll use these, since I'm relatively content with
just C-x C-b and marking all the buffers to delete, but here are some
revisions I've made to the code. Feel free to accept any changes you
like (I release any part belonging to me into the public domain, if
possible, and license it for any and all use if not).

The big changes I made were shortening the first sentence in the
docstring so that apropos kill.*buffer is meaningful, and eliminating
some of your lambdas (mapcar (lambda (x) (f x)) l) is the same as
(mapcar 'f l) in elisp, I believe, and even in cl it only makes a
difference if you're trying to capture existing variables). Similarly,
I replaced (map nil ....) with mapcar, and used delete instead of
delete-if (since string= is a special form of equal, which is what
delete uses).

At any rate, lightly tested on xemacs 21.4.8

(defun kill-buffer-frame () 
  "Kill the current frame, or current buffer and delete its window."
   (interactive)
   (condition-case nil
       (delete-frame)
     (error
      (let ((buffer (current-buffer)))
        (or (one-window-p) 
            (delete-window))
        (kill-buffer buffer)))))

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

;;__________________________________________________________________________
(global-set-key [(control f4)]  'kill-buffer-frame)     ;cua binding
(global-set-key [(meta control f4)] 'kill-all-other-buffer-frames)

-- 
I'm awfully glad I'm a Beta, because I don't work so hard.

  reply	other threads:[~2004-01-02 20:54 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 [this message]
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
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

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

  git send-email \
    --in-reply-to=0whr7yim5pi.fsf@rescomp.Stanford.EDU \
    --to=bpalmer@rescomp.stanford.edu \
    /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.
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.