]> code.delx.au - gnu-emacs/blobdiff - lisp/menu-bar.el
Initial revision
[gnu-emacs] / lisp / menu-bar.el
index 67df0d261850a636c69675da820ef9801830671a..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))
 
@@ -191,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)))))))