]> git.eshelyaron.com Git - emacs.git/commitdiff
* menu-bar.el (kill-this-buffer-enabled-p): Avoid looping over entire buffer list...
authorMartin Rudalics <rudalics@gmx.at>
Sun, 29 May 2011 19:11:23 +0000 (15:11 -0400)
committerChong Yidong <cyd@stupidchicken.com>
Sun, 29 May 2011 19:11:23 +0000 (15:11 -0400)
lisp/ChangeLog
lisp/menu-bar.el

index 6c21786bce8920684b22fbdcfe35207b158bcd66..c54e48ef52a21000ab98d88659c2f9c6f6202e9c 100644 (file)
@@ -1,3 +1,8 @@
+2011-05-29  Martin Rudalics  <rudalics@gmx.at>
+
+       * menu-bar.el (kill-this-buffer-enabled-p): Avoid looping over
+       entire buffer list (Bug#8184).
+
 2011-05-29  Chong Yidong  <cyd@stupidchicken.com>
 
        * image.el (imagemagick-types-inhibit)
index 8a33381b618ddf8450ecac688eb1cebdfe0d5098..343a9c6dd0c949c60f1fea619b1c14266d524276 100644 (file)
@@ -1823,14 +1823,17 @@ using `abort-recursive-edit'."
     (abort-recursive-edit)))
 
 (defun kill-this-buffer-enabled-p ()
-  (let ((count 0)
-       (buffers (buffer-list)))
-    (while buffers
-      (or (string-match "^ " (buffer-name (car buffers)))
-         (setq count (1+ count)))
-      (setq buffers (cdr buffers)))
-    (or (not (menu-bar-non-minibuffer-window-p))
-       (> count 1))))
+  "Return non-nil if the `kill-this-buffer' menu item should be enabled."
+  (or (not (menu-bar-non-minibuffer-window-p))
+      (let (found-1)
+       ;; Instead of looping over entire buffer list, stop once we've
+       ;; found two "killable" buffers (Bug#8184).
+       (catch 'found-2
+         (dolist (buffer (buffer-list))
+           (unless (string-match-p "^ " (buffer-name buffer))
+             (if (not found-1)
+                 (setq found-1 t)
+               (throw 'found-2 t))))))))
 
 (put 'dired 'menu-enable '(menu-bar-non-minibuffer-window-p))