From: Leo Liu <sdl.web@gmail.com>
Date: Thu, 28 Oct 2010 01:30:01 +0000 (-0400)
Subject: * lisp/iswitchb.el (iswitchb-kill-buffer): Avoid `iswitchb-make-buflist'
X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~438^2~45^2~432
X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=19677c71262113e3993b545259aeb2fc3c397fb7;p=emacs.git

* lisp/iswitchb.el (iswitchb-kill-buffer): Avoid `iswitchb-make-buflist'
which changes the order of matches seen by users.

Fixes: debbugs:7231
---

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9150d39848f..758d75bb688 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,4 +1,9 @@
-2010-10-28  Jes Bodi Klinke  <jes@bodi-klinke.dk>
+2010-10-28  Leo  <sdl.web@gmail.com>
+
+	* iswitchb.el (iswitchb-kill-buffer): Avoid `iswitchb-make-buflist'
+	which changes the order of matches seen by users (bug#7231).
+
+2010-10-28  Jes Bodi Klinke  <jes@bodi-klinke.dk>  (tiny change)
 
 	* progmodes/compile.el (compilation-mode-font-lock-keywords):
 	Don't confuse -omega as "-o mega".
diff --git a/lisp/iswitchb.el b/lisp/iswitchb.el
index 808a23577d1..48f0edb49e0 100644
--- a/lisp/iswitchb.el
+++ b/lisp/iswitchb.el
@@ -1033,7 +1033,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 +1046,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)