emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-28 1cdb4d2: * lisp/menu-bar.el (menu-bar-keymap): Add optional arg


From: Juri Linkov
Subject: emacs-28 1cdb4d2: * lisp/menu-bar.el (menu-bar-keymap): Add optional arg KEYMAP (bug#50067).
Date: Thu, 21 Oct 2021 12:56:13 -0400 (EDT)

branch: emacs-28
commit 1cdb4d2077c4e402bf2b2991e8395f0ccdedd1d1
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>

    * lisp/menu-bar.el (menu-bar-keymap): Add optional arg KEYMAP (bug#50067).
    
    * lisp/mouse.el (context-menu-global): Use 'menu-bar-keymap' with
    its arg KEYMAP set to 'global-map'.
---
 lisp/menu-bar.el | 9 ++++++---
 lisp/mouse.el    | 2 +-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index 1cc126b..f19dc9e 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -2696,10 +2696,13 @@ This command is to be used when you click the mouse in 
the menubar."
                        (cdr menu-bar-item-cons)
                      0))))
 
-(defun menu-bar-keymap ()
+(defun menu-bar-keymap (&optional keymap)
   "Return the current menu-bar keymap.
+The ordering of the return value respects `menu-bar-final-items'.
 
-The ordering of the return value respects `menu-bar-final-items'."
+It's possible to use the KEYMAP argument to override the default keymap
+that is the currently active maps.  For example, the argument KEYMAP
+could provide `global-map' where items are limited to the global map only."
   (let ((menu-bar '())
         (menu-end '()))
     (map-keymap
@@ -2712,7 +2715,7 @@ The ordering of the return value respects 
`menu-bar-final-items'."
              ;; sorting.
              (push (cons pos menu-item) menu-end)
            (push menu-item menu-bar))))
-     (lookup-key (menu-bar-current-active-maps) [menu-bar]))
+     (lookup-key (or keymap (menu-bar-current-active-maps)) [menu-bar]))
     `(keymap ,@(nreverse menu-bar)
              ,@(mapcar #'cdr (sort menu-end
                                    (lambda (a b)
diff --git a/lisp/mouse.el b/lisp/mouse.el
index bcb58d1..7bac6dd 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -364,7 +364,7 @@ Some context functions add menu items below the separator."
                 (when (consp binding)
                   (define-key-after menu (vector key)
                     (copy-sequence binding))))
-              (lookup-key global-map [menu-bar]))
+              (menu-bar-keymap global-map))
   menu)
 
 (defun context-menu-local (menu _click)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]