changeset 4160:4c4910d66232

(mouse-menu-bar-buffers): Add Frames pane if there are multiple panes.
author Roland McGrath <roland@gnu.org>
date Mon, 19 Jul 1993 05:44:27 +0000
parents e0bddf2ba112
children 8e236d4ce64b
files lisp/menu-bar.el
diffstat 1 files changed, 76 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/menu-bar.el	Mon Jul 19 04:03:52 1993 +0000
+++ b/lisp/menu-bar.el	Mon Jul 19 05:44:27 1993 +0000
@@ -173,68 +173,88 @@
 	(if (> (length buffers) buffers-menu-max-size)
 	    (setcdr (nthcdr buffers-menu-max-size buffers) nil)))
     (setq menu
-	  (list "Buffer Menu"
-		(cons "Select Buffer"
-		      (let ((tail buffers)
-			    (maxbuf 0)
-			    (maxlen 0)
-			    head)
-			(while tail
-			  (or (eq ?\ (aref (buffer-name (car tail)) 0))
-			      (setq maxbuf
-				    (max maxbuf
-					 (length (buffer-name (car tail))))))
-			  (setq tail (cdr tail)))
-			(setq tail buffers)
-			(while tail
-			  (let ((elt (car tail)))
-			    (if (not (string-match "^ "
-						   (buffer-name elt)))
-				(setq head (cons
-					    (cons
-					     (format
-					      (format "%%%ds  %%s%%s  %%s"
-						      maxbuf)
-					      (buffer-name elt)
-					      (if (buffer-modified-p elt) "*" " ")
-					      (save-excursion
-						(set-buffer elt)
-						(if buffer-read-only "%" " "))
-					      (or (buffer-file-name elt) ""))
-					     elt)
-					    head)))
-			    (and head (> (length (car (car head))) maxlen)
-				 (setq maxlen (length (car (car head))))))
-			  (setq tail (cdr tail)))
-			(nconc (reverse head)
-			       (list (cons (concat (make-string (max 0 (- (/ maxlen 2) 8)) ?\ )
-						   "List All Buffers")
-					   'list-buffers)))))))
+	  (cons "Select Buffer"
+		(let ((tail buffers)
+		      (maxbuf 0)
+		      (maxlen 0)
+		      head)
+		  (while tail
+		    (or (eq ?\ (aref (buffer-name (car tail)) 0))
+			(setq maxbuf
+			      (max maxbuf
+				   (length (buffer-name (car tail))))))
+		    (setq tail (cdr tail)))
+		  (setq tail buffers)
+		  (while tail
+		    (let ((elt (car tail)))
+		      (if (not (string-match "^ "
+					     (buffer-name elt)))
+			  (setq head (cons
+				      (cons
+				       (format
+					(format "%%%ds  %%s%%s  %%s"
+						maxbuf)
+					(buffer-name elt)
+					(if (buffer-modified-p elt)
+					    "*" " ")
+					(save-excursion
+					  (set-buffer elt)
+					  (if buffer-read-only "%" " "))
+					(or (buffer-file-name elt) ""))
+				       elt)
+				      head)))
+		      (and head (> (length (car (car head))) maxlen)
+			   (setq maxlen (length (car (car head))))))
+		    (setq tail (cdr tail)))
+		  (nconc (nreverse head)
+			 (list (cons
+				(concat (make-string (max (- (/ maxlen
+								2)
+							     8)
+							  0) ?\ )
+					"List All Buffers")
+				'list-buffers))))))
+    (setq menu (list menu))
 
+    (if (cdr (frame-list))
+	(setq menu
+	      (cons (cons "Select Frame"
+			  (mapcar (lambda (frame)
+				    (cons (cdr (assq 'name
+						     (frame-parameters frame)))
+					  frame))
+				  (frame-list)))
+		    menu)))
+    (setq menu (cons "Buffer and Frame Menu" menu))
 
     (let ((buf (x-popup-menu (if (listp event) event
 			       (cons '(0 0) (selected-frame)))
 			     menu))
 	  (window (and (listp event) (posn-window (event-start event)))))
-      (if (eq buf 'list-buffers)
-	  (list-buffers)
-	(if buf
-	    (if complex-buffers-menu-p
-		(let ((action (x-popup-menu (if (listp event) event
-					      (cons '(0 0) (selected-frame)))
-					    '("Buffer Action"
-					      (""
-					       ("Save Buffer" . save-buffer)
-					       ("Kill Buffer" . kill-buffer)
-					       ("Select Buffer" . switch-to-buffer))))))
-		  (if (eq action 'save-buffer)
-		      (save-excursion
-			(set-buffer buf)
-			(save-buffer))
-		    (funcall action buf)))
-	      (and (windowp window)
-		   (select-window window))
-	      (switch-to-buffer buf)))))))
+      (cond ((framep buf)
+	     (make-frame-visible buf)
+	     (raise-frame buf)
+	     (select-frame buf))
+	    ((eq buf 'list-buffers)
+	     (list-buffers))
+	    (buf
+	     (if complex-buffers-menu-p
+		 (let ((action (x-popup-menu
+				(if (listp event) event
+				  (cons '(0 0) (selected-frame)))
+				'("Buffer Action"
+				  (""
+				   ("Save Buffer" . save-buffer)
+				   ("Kill Buffer" . kill-buffer)
+				   ("Select Buffer" . switch-to-buffer))))))
+		   (if (eq action 'save-buffer)
+		       (save-excursion
+			 (set-buffer buf)
+			 (save-buffer))
+		     (funcall action buf)))
+	       (and (windowp window)
+		    (select-window window))
+	       (switch-to-buffer buf)))))))
 
 ;; this version is too slow
 ;;;(defun format-buffers-menu-line (buffer)