X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/4628bef1eea0f60e846fe6b6591725aa92952de9..758c81e87ded2bad9f5a5a6683fb498965eb508c:/lisp/iswitchb.el diff --git a/lisp/iswitchb.el b/lisp/iswitchb.el index 808a23577d..6493a8f800 100644 --- a/lisp/iswitchb.el +++ b/lisp/iswitchb.el @@ -1,7 +1,6 @@ ;;; iswitchb.el --- switch between buffers using substrings -;; Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2006, -;; 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +;; Copyright (C) 1996-1997, 2000-2012 Free Software Foundation, Inc. ;; Author: Stephen Eglen ;; Maintainer: Stephen Eglen @@ -123,7 +122,7 @@ ;; t IN | INBOX ;; t In | [No match] -;;; Customisation +;;; Customization ;; See the User Variables section below for easy ways to change the ;; functionality of the program. These are accessible using the @@ -164,7 +163,7 @@ ;; Font-Lock ;; font-lock is used to highlight the first matching buffer. To -;; switch this off, set (setq iswitchb-use-faces nil). Colouring of +;; switch this off, set (setq iswitchb-use-faces nil). Coloring of ;; the matching buffer name was suggested by Carsten Dominik ;; (dominik@strw.leidenuniv.nl) @@ -208,7 +207,7 @@ ;; (delete-minibuffer-contents)) ;; ;; (add-hook 'iswitchb-define-mode-map-hook -;; '(lambda () (define-key +;; (lambda () (define-key ;; iswitchb-mode-map "\C-o" ;; 'iswitchb-exclude-nonmatching))) @@ -373,9 +372,14 @@ See also `iswitchb-newbuffer'." :type 'string :group 'iswitchb) -(defvar iswitchb-all-frames 'visible - "*Argument to pass to `walk-windows' when finding visible buffers. -See documentation of `walk-windows' for useful values.") +(defcustom iswitchb-all-frames 'visible + "Argument to pass to `walk-windows' when iswitchb is finding buffers. +See documentation of `walk-windows' for useful values." + :type '(choice (const :tag "Selected frame only" nil) + (const :tag "All existing frames" t) + (const :tag "All visible frames" visible) + (const :tag "All frames on this terminal" 0)) + :group 'iswitchb) (defcustom iswitchb-minibuffer-setup-hook nil "Iswitchb-specific customization of minibuffer setup. @@ -659,7 +663,7 @@ the selection process begins. Used by isearchb.el." (not (iswitchb-existing-buffer-p))) (let ((virt (car iswitchb-virtual-buffers)) (new-buf)) - ;; Keep the name of the buffer returned by find-file-noselect, as + ;; Keep the name of the buffer returned by find-file-noselect, as ;; the buffer 'virt' could be a symlink to a file of a different name. (setq new-buf (buffer-name (find-file-noselect (cdr virt)))) (setq iswitchb-matches (list new-buf) @@ -1016,7 +1020,7 @@ Return the modified list with the last element prepended to it." (display-completion-list (or iswitchb-matches iswitchb-buflist) :help-string "iswitchb " :activate-callback - (lambda (x y z) + (lambda (_x _y _z) (message "doesn't work yet, sorry!"))) ;; else running Emacs (display-completion-list (or iswitchb-matches iswitchb-buflist)))) @@ -1033,7 +1037,9 @@ Return the modified list with the last element prepended to it." (setq buf (car iswitchb-matches)) ;; check to see if buf is non-nil. (if buf - (progn + (let ((bufobjs (mapcar (lambda (name) + (or (get-buffer name) name)) + iswitchb-buflist))) (kill-buffer buf) ;; Check if buffer exists. XEmacs gnuserv.el makes alias @@ -1044,8 +1050,13 @@ Return the modified list with the last element prepended to it." (setq iswitchb-rescan t) ;; Else `kill-buffer' succeeds so re-make the buffer list ;; taking into account packages like uniquify may rename - ;; buffers - (iswitchb-make-buflist iswitchb-default)))))) + ;; buffers, and try to preserve the ordering of buffers. + (setq iswitchb-buflist + (delq nil (mapcar (lambda (b) + (if (bufferp b) + (buffer-name b) + b)) + bufobjs)))))))) ;;; VISIT CHOSEN BUFFER (defun iswitchb-visit-buffer (buffer) @@ -1104,7 +1115,7 @@ Return the modified list with the last element prepended to it." (if (fboundp 'set-buffer-major-mode) (set-buffer-major-mode newbufcreated)) (iswitchb-visit-buffer newbufcreated)) - ;; else wont create new buffer + ;; else won't create new buffer (message "no buffer matching `%s'" buf)))) (defun iswitchb-window-buffer-p (buffer) @@ -1112,10 +1123,9 @@ Return the modified list with the last element prepended to it." If BUFFER is visible in the current frame, return nil." (interactive) (let ((blist (iswitchb-get-buffers-in-frames 'current))) - ;;If the buffer is visible in current frame, return nil - (if (memq buffer blist) - nil - ;; maybe in other frame or icon + ;; If the buffer is visible in current frame, return nil + (unless (member buffer blist) + ;; maybe in other frame or icon (get-buffer-window buffer 0) ; better than 'visible ))) @@ -1419,10 +1429,13 @@ See the variable `iswitchb-case' for details." ;;;###autoload (define-minor-mode iswitchb-mode - "Toggle Iswitchb global minor mode. -With arg, turn Iswitchb mode on if ARG is positive, otherwise turn it off. -This mode enables switching between buffers using substrings. See -`iswitchb' for details." + "Toggle Iswitchb mode. +With a prefix argument ARG, enable Iswitchb mode if ARG is +positive, and disable it otherwise. If called from Lisp, enable +the mode if ARG is omitted or nil. + +Iswitchb mode is a global minor mode that enables switching +between buffers using substrings. See `iswitchb' for details." nil nil iswitchb-global-map :global t :group 'iswitchb (if iswitchb-mode (add-hook 'minibuffer-setup-hook 'iswitchb-minibuffer-setup) @@ -1430,5 +1443,4 @@ This mode enables switching between buffers using substrings. See (provide 'iswitchb) -;; arch-tag: d74198ae-753f-44f2-b34f-0c515398d90a ;;; iswitchb.el ends here