]> code.delx.au - gnu-emacs/blobdiff - lisp/menu-bar.el
Initial revision
[gnu-emacs] / lisp / menu-bar.el
index 0f174f1fab9f9557ff4d3ec5628fcb9d00af3af9..c4a2ea013b8db68d44b48efa57a0bd223e5f237b 100644 (file)
@@ -47,6 +47,8 @@
 
 (define-key menu-bar-edit-menu [fill] '("Fill" . fill-region))
 (define-key menu-bar-edit-menu [clear] '("Clear" . delete-region))
+(define-key menu-bar-edit-menu [choose-next-paste]
+  '("Choose Next Paste" . mouse-menu-choose-yank))
 (define-key menu-bar-edit-menu [paste] '("Paste" . yank))
 (define-key menu-bar-edit-menu [copy] '("Copy" . kill-ring-save))
 (define-key menu-bar-edit-menu [cut] '("Cut" . kill-region))
@@ -121,16 +123,20 @@ A subsequent \\[yank] yanks the choice just selected."
                                                     0 yank-menu-length)))
                         (prog1 (cons string count)
                           (setq count (1+ count))))
-                      kill-ring)))
-    (rotate-yank-pointer (x-popup-menu event 
-                                      (list "Yank Menu"
-                                            (cons "Pick Selection" menu))))
-    (if (interactive-p)
-       (message "The next yank will insert the selected text.")
-      (current-kill 0))))
-
-(define-key menu-bar-edit-menu [choose-selection]
-  '("Choose Pasting Selection" . mouse-menu-choose-yank))
+                      kill-ring))
+        (arg (x-popup-menu event 
+                           (list "Yank Menu"
+                                 (cons "Choose Next Yank" menu)))))
+    ;; A mouse click outside the menu returns nil.
+    ;; Avoid a confusing error from passing nil to rotate-yank-pointer.
+    ;; XXX should this perhaps do something other than simply return? -rm
+    (if arg
+       (progn
+         (rotate-yank-pointer arg)
+         (if (interactive-p)
+             (message "The next yank will insert the selected text.")
+           (current-kill 0))))))
+(put 'mouse-menu-choose-yank 'menu-enable 'kill-ring)
 \f
 (define-key global-map [menu-bar buffer] '("Buffers" . mouse-menu-bar-buffers))
 
@@ -160,8 +166,16 @@ and selects that window."
          (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 "^ "
@@ -169,8 +183,13 @@ and selects that window."
                                (setq head (cons
                                            (cons
                                             (format
-                                             "%14s   %s"
+                                             (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)))
@@ -178,7 +197,7 @@ and selects that window."
                                 (setq maxlen (length (car (car head))))))
                          (setq tail (cdr tail)))
                        (nconc (reverse head)
-                              (list (cons (concat (make-string (- (/ maxlen 2) 8) ?\ )
+                              (list (cons (concat (make-string (max 0 (- (/ maxlen 2) 8)) ?\ )
                                                   "List All Buffers")
                                           'list-buffers)))))))