]> code.delx.au - gnu-emacs/blobdiff - lisp/iswitchb.el
* lisp/gnus/sieve-manage.el (sieve-manage-open): Correctly set sieve-manage-port.
[gnu-emacs] / lisp / iswitchb.el
index ee06db6f78f3777de1f792ae7f8eb3e81f85aedf..48f0edb49e0a9f4ea2d51ba1affb9b9d968674d7 100644 (file)
@@ -1,7 +1,7 @@
 ;;; 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, 2001, 2002, 2003, 2004, 2005, 2006,
+;;   2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Stephen Eglen <stephen@gnu.org>
 ;; Maintainer: Stephen Eglen <stephen@gnu.org>
@@ -1027,13 +1027,15 @@ Return the modified list with the last element prepended to it."
 (defun iswitchb-kill-buffer ()
   "Kill the buffer at the head of `iswitchb-matches'."
   (interactive)
-  (let ( (enable-recursive-minibuffers t)
-        buf)
+  (let ((enable-recursive-minibuffers t)
+        buf)
 
     (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
@@ -1042,8 +1044,15 @@ Return the modified list with the last element prepended to it."
          (if (get-buffer buf)
              ;; buffer couldn't be killed.
              (setq iswitchb-rescan t)
-           ;; else buffer was killed so remove name from list.
-           (setq iswitchb-buflist  (delq buf iswitchb-buflist)))))))
+           ;; Else `kill-buffer' succeeds so re-make the buffer list
+           ;; taking into account packages like uniquify may rename
+           ;; 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)
@@ -1117,19 +1126,6 @@ If BUFFER is visible in the current frame, return nil."
       (get-buffer-window buffer 0) ; better than 'visible
       )))
 
-(defun iswitchb-default-keybindings ()
-  "Set up default keybindings for `iswitchb-buffer'.
-Call this function to override the normal bindings.  This function also
-adds a hook to the minibuffer."
-  (interactive)
-  (add-hook 'minibuffer-setup-hook 'iswitchb-minibuffer-setup)
-  (global-set-key "\C-xb" 'iswitchb-buffer)
-  (global-set-key "\C-x4b" 'iswitchb-buffer-other-window)
-  (global-set-key "\C-x4\C-o" 'iswitchb-display-buffer)
-  (global-set-key "\C-x5b" 'iswitchb-buffer-other-frame))
-
-(make-obsolete 'iswitchb-default-keybindings 'iswitchb-mode "21.1")
-
 (defun iswitchb-buffer ()
   "Switch to another buffer.
 
@@ -1274,7 +1270,7 @@ Modified from `icomplete-completions'."
     ;; consult the list of past visited files, to see if we can find
     ;; the file which the user might thought was still open.
     (when (and iswitchb-use-virtual-buffers (null comps)
-              (or recentf-list bookmark-alist))
+              recentf-list)
       (setq iswitchb-virtual-buffers nil)
       (let ((head recentf-list) name)
        (while head
@@ -1289,30 +1285,15 @@ Modified from `icomplete-completions'."
              (setq iswitchb-virtual-buffers
                    (cons (cons name (car head))
                          iswitchb-virtual-buffers)))
-         (setq head (cdr head))))
-      (let ((head bookmark-alist) name path)
-       (while head
-         (if (and (setq path (cdr (assq 'filename (cdar head))))
-                  (setq name (file-name-nondirectory path))
-                  (string-match (if iswitchb-regexp
-                                    iswitchb-text
-                                  (regexp-quote iswitchb-text)) name)
-                  (null (get-file-buffer path))
-                  (not (assoc name iswitchb-virtual-buffers))
-                  (not (iswitchb-ignore-buffername-p name))
-                  (file-exists-p path))
-             (setq iswitchb-virtual-buffers
-                   (cons (cons name path)
-                         iswitchb-virtual-buffers)))
-         (setq head (cdr head))))
-      (setq iswitchb-virtual-buffers (nreverse iswitchb-virtual-buffers)
-           comps (mapcar 'car iswitchb-virtual-buffers))
+         (setq head (cdr head)))
+       (setq iswitchb-virtual-buffers (nreverse iswitchb-virtual-buffers)
+             comps (mapcar 'car iswitchb-virtual-buffers))
        (let ((comp comps))
          (while comp
            (put-text-property 0 (length (car comp))
                               'face 'iswitchb-virtual-matches
                               (car comp))
-           (setq comp (cdr comp)))))
+           (setq comp (cdr comp))))))
 
     (cond ((null comps) (format " %sNo match%s"
                                open-bracket-determined