mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
Improve menu-bar-item-at-x
* lisp/menu-bar.el (menu-bar-item-at-x): Handle case of duplicate keys in the menu-bar definition.
This commit is contained in:
parent
d1d85e0f35
commit
4183705018
1 changed files with 17 additions and 14 deletions
|
|
@ -2900,24 +2900,27 @@ returns nil."
|
|||
(menu-bar (menu-bar-keymap))
|
||||
prev-key
|
||||
prev-column
|
||||
keys-seen
|
||||
found)
|
||||
(catch 'done
|
||||
(map-keymap
|
||||
(lambda (key binding)
|
||||
(when (> column x-position)
|
||||
(setq found t)
|
||||
(throw 'done nil))
|
||||
(setq prev-key key)
|
||||
(pcase binding
|
||||
((or `(,(and (pred stringp) name) . ,_) ;Simple menu item.
|
||||
`(menu-item ,name ,_cmd ;Extended menu item.
|
||||
. ,(and props
|
||||
(guard (let ((visible
|
||||
(plist-get props :visible)))
|
||||
(or (null visible)
|
||||
(eval visible)))))))
|
||||
(setq prev-column column
|
||||
column (+ column (length name) 1)))))
|
||||
(unless (memq key keys-seen)
|
||||
(push key keys-seen)
|
||||
(when (> column x-position)
|
||||
(setq found t)
|
||||
(throw 'done nil))
|
||||
(setq prev-key key)
|
||||
(pcase binding
|
||||
((or `(,(and (pred stringp) name) . ,_) ;Simple menu item.
|
||||
`(menu-item ,name ,_cmd ;Extended menu item.
|
||||
. ,(and props
|
||||
(guard (let ((visible
|
||||
(plist-get props :visible)))
|
||||
(or (null visible)
|
||||
(eval visible)))))))
|
||||
(setq prev-column column
|
||||
column (+ column (length name) 1))))))
|
||||
menu-bar)
|
||||
;; Check the last menu item.
|
||||
(when (> column x-position)
|
||||
|
|
|
|||
Loading…
Reference in a new issue