changeset 82298:0b0e460b400a

(mouse-buffer-menu): Pass mode-name through format-mode-line because it may be a list, e.g., (sgml-xml-mode "XML" "SGML"), and not a string.
author Sam Steingold <sds@gnu.org>
date Mon, 06 Aug 2007 17:19:26 +0000
parents 51a0886252f1
children 047f17a0a67f
files lisp/ChangeLog lisp/mouse.el
diffstat 2 files changed, 23 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Mon Aug 06 16:02:12 2007 +0000
+++ b/lisp/ChangeLog	Mon Aug 06 17:19:26 2007 +0000
@@ -1,3 +1,9 @@
+2007-08-06  Sam Steingold  <sds@gnu.org>
+
+	* mouse.el (mouse-buffer-menu): Pass mode-name through
+	format-mode-line because it may be a list,
+	e.g., (sgml-xml-mode "XML" "SGML"), and not a string.
+
 2007-08-06  Vinicius Jose Latorre  <viniciusig@ig.com.br>
 
 	* printing.el (pr-update-menus): Docstring fix.
--- a/lisp/mouse.el	Mon Aug 06 16:02:12 2007 +0000
+++ b/lisp/mouse.el	Mon Aug 06 17:19:26 2007 +0000
@@ -1814,27 +1814,23 @@
   (mouse-minibuffer-check event)
   (let ((buffers (buffer-list))  alist menu split-by-major-mode sum-of-squares)
     ;; Make an alist of elements that look like (MENU-ITEM . BUFFER).
-    (let ((tail buffers))
-      (while tail
-	;; Divide all buffers into buckets for various major modes.
-	;; Each bucket looks like (MODE NAMESTRING BUFFERS...).
-	(with-current-buffer (car tail)
-	  (let* ((adjusted-major-mode major-mode) elt)
-	    (let ((tail mouse-buffer-menu-mode-groups))
-	      (while tail
-		(if (string-match (car (car tail)) mode-name)
-		    (setq adjusted-major-mode (cdr (car tail))))
-		(setq tail (cdr tail))))
-	    (setq elt (assoc adjusted-major-mode split-by-major-mode))
-	    (if (null elt)
-		(setq elt (list adjusted-major-mode
-				(if (stringp adjusted-major-mode)
-				    adjusted-major-mode
-				  mode-name))
-		      split-by-major-mode (cons elt split-by-major-mode)))
-	    (or (memq (car tail) (cdr (cdr elt)))
-		(setcdr (cdr elt) (cons (car tail) (cdr (cdr elt)))))))
-	(setq tail (cdr tail))))
+    (dolist (buf buffers)
+      ;; Divide all buffers into buckets for various major modes.
+      ;; Each bucket looks like (MODE NAMESTRING BUFFERS...).
+      (with-current-buffer buf
+        (let* ((adjusted-major-mode major-mode) elt)
+          (dolist (group mouse-buffer-menu-mode-groups)
+            (when (string-match (car group) (format-mode-line mode-name))
+              (setq adjusted-major-mode (cdr group))))
+          (setq elt (assoc adjusted-major-mode split-by-major-mode))
+          (unless elt
+            (setq elt (list adjusted-major-mode
+                            (if (stringp adjusted-major-mode)
+                                adjusted-major-mode
+                                mode-name))
+                  split-by-major-mode (cons elt split-by-major-mode)))
+          (or (memq buf (cdr (cdr elt)))
+              (setcdr (cdr elt) (cons buf (cdr (cdr elt))))))))
     ;; Compute the sum of squares of sizes of the major-mode buckets.
     (let ((tail split-by-major-mode))
       (setq sum-of-squares 0)