From: Bruce Ingalls <bingalls@fit-zones.NO-SPAM.com>
Subject: Killing Buffers
Date: Fri, 02 Jan 2004 18:49:08 GMT [thread overview]
Message-ID: <E2jJb.45068$cM1.7819212@twister.nyc.rr.com> (raw)
In-Reply-To: <opr0x2mzbluj0cst@news.singnet.com.sg>
;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
;;__________________________________________________________________________
;;;;;; kill-buffer-frame
(defun kill-buffer-frame ()
"Tries `delete-frame', then `delete-window', then `kill-buffer' to close
the current file, only."
(interactive)
(condition-case err ;Handle any exceptions
(delete-frame)
(error
(let ((buffer (current-buffer)))
(or (one-window-p) (delete-window))
(kill-buffer buffer)))))
;;__________________________________________________________________________
;;;;;; kill-all-other-buffer-frames
(defun kill-all-other-buffer-frames (&optional prefix)
"Closes all open files, except current buffer, window and frame.
If prefixed with 'C-u', leaves only *scratch* buffer, instead."
(interactive "P")
(let ((cur-buf-name (buffer-name nil))
(buf-list (buffer-list)))
(mapcar (lambda (x) (delete-frame x)) ;close all frames but one, first
(cdr (visible-frame-list)))
(or (one-window-p) (delete-window)) ;close all windows but one, next
(if prefix ;C-u prefix: leave only *scratch*
(progn
(mapcar (lambda (x) (kill-buffer x)) (buffer-list))
(delete-other-windows))
;;else leave the current window
(setf buf-list (delete-if #'(lambda (buf)
(string= (buffer-name buf) cur-buf-name))
buf-list))
(map 'nil #'kill-buffer buf-list))))
;;__________________________________________________________________________
(global-set-key [(control f4)] 'kill-buffer-frame) ;cua binding
;;Note: C-u prefix leaves only the *scratch* buffer, instead of current
;;buffer
(global-set-key [(meta control f4)] 'kill-all-other-buffer-frames)
next prev parent reply other threads:[~2004-01-02 18:49 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 [this message]
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
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='E2jJb.45068$cM1.7819212@twister.nyc.rr.com' \
--to=bingalls@fit-zones.no-spam.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.
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.