]> git.eshelyaron.com Git - emacs.git/commitdiff
* menu-bar.el (menu-bar-update-buffers): Properly count buffers.
authorArtur Malabarba <bruce.connor.am@gmail.com>
Sun, 22 Mar 2015 19:29:57 +0000 (19:29 +0000)
committerArtur Malabarba <bruce.connor.am@gmail.com>
Sun, 22 Mar 2015 19:29:57 +0000 (19:29 +0000)
lisp/ChangeLog
lisp/menu-bar.el

index 2f9c430e45db74a0b1e8265ad14c008b9be6875d..52c6a726432d6530afae20c851147d9e485079ba 100644 (file)
@@ -1,3 +1,8 @@
+2015-03-22  Artur Malabarba  <bruce.connor.am@gmail.com>
+
+       * menu-bar.el (menu-bar-update-buffers): Count displayed buffers
+       for `buffers-menu-max-size', not total buffers.
+
 2015-03-21  Titus von der Malsburg  <malsburg@posteo.de>
 
        * window.el (window-font-width, window-font-height)
index 5fdb9377a48900b9741476cdb2b70ad1be54c53f..2ace3162c900254042c8f339e24ae4a76d0b2608 100644 (file)
@@ -1949,20 +1949,20 @@ It must accept a buffer as its only required argument.")
        (let ((buffers (buffer-list))
             (frames (frame-list))
             buffers-menu)
-        ;; If requested, list only the N most recently selected buffers.
-        (if (and (integerp buffers-menu-max-size)
-                 (> buffers-menu-max-size 1))
-            (if (> (length buffers) buffers-menu-max-size)
-                (setcdr (nthcdr buffers-menu-max-size buffers) nil)))
 
         ;; Make the menu of buffers proper.
         (setq buffers-menu
-              (let (alist)
+               (let ((i 0)
+                     (limit (if (and (integerp buffers-menu-max-size)
+                                     (> buffers-menu-max-size 1))
+                                buffers-menu-max-size most-positive-fixnum))
+                     alist)
                 ;; Put into each element of buffer-list
                 ;; the name for actual display,
                 ;; perhaps truncated in the middle.
-                (dolist (buf buffers)
-                  (let ((name (buffer-name buf)))
+                 (while buffers
+                   (let* ((buf (pop buffers))
+                          (name (buffer-name buf)))
                      (unless (eq ?\s (aref name 0))
                        (push (menu-bar-update-buffers-1
                               (cons buf
@@ -1976,7 +1976,11 @@ It must accept a buffer as its only required argument.")
                                          name (- (/ buffers-menu-buffer-name-length 2))))
                                      name)
                                     ))
-                             alist))))
+                             alist)
+                       ;; If requested, list only the N most recently
+                       ;; selected buffers.
+                       (when (= limit (setq i (1+ i)))
+                         (setq buffers nil)))))
                 (list (menu-bar-buffer-vector alist))))
 
         ;; Make a Frames menu if we have more than one frame.