X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/a749f1c648f2b9bf1a0b0b10e2da4c1c4e3d431d..c57b0e4b243a7a4a92549e833c7266b0be39f906:/lisp/menu-bar.el diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index 67cb3273d2..a1b6d95ec0 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -381,7 +381,8 @@ (bindings--define-key menu [xref-pop] '(menu-item "Back" xref-pop-marker-stack - :visible (not (xref-marker-stack-empty-p)) + :visible (and (featurep 'xref) + (not (xref-marker-stack-empty-p))) :help "Back to the position of the last search")) (bindings--define-key menu [xref-apropos] @@ -473,13 +474,15 @@ :enable (and (cdr yank-menu) (not buffer-read-only)) :help "Choose a string from the kill ring and paste it")) (bindings--define-key menu [paste] - '(menu-item "Paste" yank - :enable (and (or - (gui-call gui-selection-exists-p 'CLIPBOARD) - (if (featurep 'ns) ; like paste-from-menu - (cdr yank-menu) - kill-ring)) - (not buffer-read-only)) + `(menu-item "Paste" yank + :enable (funcall + ',(lambda () + (and (or + (gui-backend-selection-exists-p 'CLIPBOARD) + (if (featurep 'ns) ; like paste-from-menu + (cdr yank-menu) + kill-ring)) + (not buffer-read-only)))) :help "Paste (yank) text most recently cut/copied")) (bindings--define-key menu [copy] ;; ns-win.el said: Substitute a Copy function that works better @@ -522,9 +525,12 @@ '(and mark-active (not buffer-read-only))) (put 'clipboard-kill-ring-save 'menu-enable 'mark-active) (put 'clipboard-yank 'menu-enable - '(and (or (gui-call gui-selection-exists-p 'PRIMARY) - (gui-call gui-selection-exists-p 'CLIPBOARD)) - (not buffer-read-only))) + `(funcall ',(lambda () + (and (or (gui-backend-selection-exists-p 'PRIMARY) + (gui-backend-selection-exists-p 'CLIPBOARD)) + (not buffer-read-only))))) + +(defvar gui-select-enable-clipboard) (defun clipboard-yank () "Insert the clipboard contents, or the last stretch of killed text." @@ -1746,12 +1752,14 @@ The menu frame is the frame for which we are updating the menu." (frame-visible-p menu-frame)))) (defun menu-bar-non-minibuffer-window-p () - "Return non-nil if selected window of the menu frame is not a minibuf window. - -See the documentation of `menu-bar-menu-frame-live-and-visible-p' -for the definition of the menu frame." + "Return non-nil if the menu frame's selected window is no minibuffer window. +Return nil if the menu frame is dead or its selected window is a +minibuffer window. The menu frame is the frame for which we are +updating the menu." (let ((menu-frame (or menu-updating-frame (selected-frame)))) - (not (window-minibuffer-p (frame-selected-window menu-frame))))) + (and (frame-live-p menu-frame) + (not (window-minibuffer-p + (frame-selected-window menu-frame)))))) (defun kill-this-buffer () ; for the menu bar "Kill the current buffer. @@ -1946,20 +1954,20 @@ It must accept a buffer as its only required argument.") (let ((buffers (buffer-list)) (frames (frame-list)) buffers-menu) - ;; If requested, list only the N most recently selected buffers. - (if (and (integerp buffers-menu-max-size) - (> buffers-menu-max-size 1)) - (if (> (length buffers) buffers-menu-max-size) - (setcdr (nthcdr buffers-menu-max-size buffers) nil))) ;; Make the menu of buffers proper. (setq buffers-menu - (let (alist) + (let ((i 0) + (limit (if (and (integerp buffers-menu-max-size) + (> buffers-menu-max-size 1)) + buffers-menu-max-size most-positive-fixnum)) + alist) ;; Put into each element of buffer-list ;; the name for actual display, ;; perhaps truncated in the middle. - (dolist (buf buffers) - (let ((name (buffer-name buf))) + (while buffers + (let* ((buf (pop buffers)) + (name (buffer-name buf))) (unless (eq ?\s (aref name 0)) (push (menu-bar-update-buffers-1 (cons buf @@ -1973,7 +1981,11 @@ It must accept a buffer as its only required argument.") name (- (/ buffers-menu-buffer-name-length 2)))) name) )) - alist)))) + alist) + ;; If requested, list only the N most recently + ;; selected buffers. + (when (= limit (setq i (1+ i))) + (setq buffers nil))))) (list (menu-bar-buffer-vector alist)))) ;; Make a Frames menu if we have more than one frame.