changeset 92745:871ad7e118ff

(menu-bar-update-buffers-maxbuf): Remove. (menu-bar-select-buffer): Remove. (menu-bar-select-frame): Make non-interactive and take a frame arg. (menu-bar-update-buffers): Don't use buffer-names or frame names as events.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 11 Mar 2008 17:44:39 +0000
parents 52faf3a2d5c7
children 26e567ab8830
files lisp/ChangeLog lisp/menu-bar.el
diffstat 2 files changed, 50 insertions(+), 66 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Tue Mar 11 16:27:52 2008 +0000
+++ b/lisp/ChangeLog	Tue Mar 11 17:44:39 2008 +0000
@@ -1,3 +1,10 @@
+2008-03-11  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* menu-bar.el (menu-bar-update-buffers-maxbuf): Remove.
+	(menu-bar-select-buffer): Remove.
+	(menu-bar-select-frame): Make non-interactive and take a frame arg.
+	(menu-bar-update-buffers): Don't use buffer-names or frame names as events.
+
 2008-03-11  Juanma Barranquero  <lekktu@gmail.com>
 
 	* icomplete.el (icomplete-completions): Remove obsolete code.
@@ -1018,8 +1025,8 @@
 2008-02-28  Kenichi Handa  <handa@ni.aist.go.jp>
 
 	* isearch.el (isearch-printing-char): Don't check
-	keyboard-coding-system.  Call
-	isearch-process-search-multibyte-characters only when
+	keyboard-coding-system.
+	Call isearch-process-search-multibyte-characters only when
 	current-input-method is non-nil.
 
 2008-02-27  Kim F. Storm  <storm@cua.dk>
--- a/lisp/menu-bar.el	Tue Mar 11 16:27:52 2008 +0000
+++ b/lisp/menu-bar.el	Tue Mar 11 17:44:39 2008 +0000
@@ -1537,23 +1537,10 @@
 
 (defvar list-buffers-directory nil)
 
-(defvar menu-bar-update-buffers-maxbuf)
-
-(defun menu-bar-select-buffer ()
-  (interactive)
-  (switch-to-buffer last-command-event))
-
-(defun menu-bar-select-frame ()
-  (interactive)
-  (let (frame)
-    (dolist (f (frame-list))
-      (when (equal last-command-event (frame-parameter f 'name))
-	(setq frame f)))
-    ;; FRAME can be nil when user specifies the selected frame.
-    (setq frame (or frame (selected-frame)))
-    (make-frame-visible frame)
-    (raise-frame frame)
-    (select-frame frame)))
+(defun menu-bar-select-frame (frame)
+  (make-frame-visible frame)
+  (raise-frame frame)
+  (select-frame frame))
 
 (defun menu-bar-update-buffers-1 (elt)
   (let* ((buf (car elt))
@@ -1597,60 +1584,50 @@
 
 	 ;; Make the menu of buffers proper.
 	 (setq buffers-menu
-	       (let* ((buffer-list
-		       (mapcar 'list buffers))
-		      (menu-bar-update-buffers-maxbuf 0)
-		      alist)
+	       (let (alist)
 		 ;; Put into each element of buffer-list
 		 ;; the name for actual display,
 		 ;; perhaps truncated in the middle.
-		 (dolist (buf buffer-list)
-		   (let ((name (buffer-name (car buf))))
-		     (setcdr buf
-			     (if (> (length name) 27)
-				 (concat (substring name 0 12)
-					 "..."
-					 (substring name -12))
-			       name))))
-		 ;; Compute the maximum length of any name.
-		 (dolist (buf buffer-list)
-		   (unless (eq ?\s (aref (cdr buf) 0))
-		     (setq menu-bar-update-buffers-maxbuf
-			   (max menu-bar-update-buffers-maxbuf
-				(length (cdr buf))))))
-		 ;; Set ALIST to an alist of the form
-		 ;; ITEM-STRING . BUFFER
-		 (dolist (buf buffer-list)
-		   (unless (eq ?\s (aref (cdr buf) 0))
-		     (push (menu-bar-update-buffers-1 buf) alist)))
-		 ;; Now make the actual list of items, and add
-		 ;; some miscellaneous buffer commands to the end.
-		 (mapcar (lambda (pair)
-			   ;; This is somewhat risque, to use
-			   ;; the buffer name itself as the event
-			   ;; type to define, but it works.
-			   ;; It would not work to use the buffer
-			   ;; since a buffer as an event has its
-			   ;; own meaning.
-			   (nconc (list (buffer-name (cdr pair))
-					(car pair)
+		 (dolist (buf buffers)
+		   (let ((name (buffer-name buf)))
+                     (unless (eq ?\s (aref name 0))
+                       (push (menu-bar-update-buffers-1
+                              (cons buf
+                                    (if (> (length name) 27)
+                                        (concat (substring name 0 12)
+                                                "..."
+                                                (substring name -12))
+                                      name)))
+                             alist))))
+		 ;; Now make the actual list of items.
+                 (let ((buffers-vec (make-vector (length alist) nil))
+                       (i (length alist)))
+                   (dolist (pair alist)
+                     (setq i (1- i))
+                     (aset buffers-vec i
+			   (nconc (list (car pair)
 					(cons nil nil))
-				  'menu-bar-select-buffer))
-			 (nreverse alist))))
+				  `(lambda ()
+                                     (interactive)
+                                     (switch-to-buffer ,(cdr pair))))))
+                   (list buffers-vec))))
 
 	 ;; Make a Frames menu if we have more than one frame.
 	 (when (cdr frames)
-	   (let ((frames-menu
-		  (cons 'keymap
-			(cons "Select Frame"
-			      (mapcar
-			       (lambda (frame)
-				 (nconc
-				  (list (frame-parameter frame 'name)
-					(frame-parameter frame 'name)
-					(cons nil nil))
-				  'menu-bar-select-frame))
-			       frames)))))
+	   (let* ((frames-vec (make-vector (length frames) nil))
+                  (frames-menu
+                   (cons 'keymap
+                         (list "Select Frame" frames-vec)))
+                  (i 0))
+             (dolist (frame frames)
+               (aset frames-vec i
+                     (nconc
+                      (list
+                       (frame-parameter frame 'name)
+                       (cons nil nil))
+                      `(lambda ()
+                         (interactive) (menu-bar-select-frame ,frame))))
+               (setq i (1+ i)))
 	     ;; Put it after the normal buffers
 	     (setq buffers-menu
 		   (nconc buffers-menu