[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master c47479c: Sort items in tmm properly, and allow clicking the final
From: |
Lars Ingebrigtsen |
Subject: |
master c47479c: Sort items in tmm properly, and allow clicking the final item |
Date: |
Mon, 5 Oct 2020 04:21:08 -0400 (EDT) |
branch: master
commit c47479cf171cac3d2b867fc4663398c3c3531524
Author: Jared Finder <jared@finder.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Sort items in tmm properly, and allow clicking the final item
* lisp/tmm.el (tmm-menubar-keymap): Sort the final items properly.
(tmm-menubar): Allow clicking the final menu item (bug#43756).
---
lisp/tmm.el | 24 ++++++++++++++++--------
src/keyboard.c | 3 ++-
2 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/lisp/tmm.el b/lisp/tmm.el
index e9f3f5b..0e83f42 100644
--- a/lisp/tmm.el
+++ b/lisp/tmm.el
@@ -50,14 +50,19 @@ The ordering of the return value respects
`menu-bar-final-items'."
(menu-end '()))
(map-keymap
(lambda (key binding)
- (push (cons key binding)
- ;; If KEY is the name of an item that we want to put last,
- ;; move it to the end.
- (if (memq key menu-bar-final-items)
- menu-end
- menu-bar)))
+ (let ((pos (seq-position menu-bar-final-items key))
+ (menu-item (cons key binding)))
+ (if pos
+ ;; If KEY is the name of an item that we want to put
+ ;; last, store it separately with explicit ordering for
+ ;; sorting.
+ (push (cons pos menu-item) menu-end)
+ (push menu-item menu-bar))))
(tmm-get-keybind [menu-bar]))
- `(keymap ,@(nreverse menu-bar) ,@(nreverse menu-end))))
+ `(keymap ,@(nreverse menu-bar)
+ ,@(mapcar #'cdr (sort menu-end
+ (lambda (a b)
+ (< (car a) (car b))))))))
;;;###autoload (define-key global-map "\M-`" 'tmm-menubar)
;;;###autoload (define-key global-map [menu-bar mouse-1] 'tmm-menubar-mouse)
@@ -96,7 +101,10 @@ to invoke `tmm-menubar' instead, customize the variable
(or (null visible)
(eval visible)))))))
(setq column (+ column (length name) 1)))))
- menu-bar))))
+ menu-bar)
+ ;; Check the last menu item.
+ (when (> column x-position)
+ (setq menu-bar-item prev-key)))))
(tmm-prompt menu-bar nil menu-bar-item)))
;;;###autoload
diff --git a/src/keyboard.c b/src/keyboard.c
index af075a4..8cf3ec1 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -12106,7 +12106,8 @@ See also `pre-command-hook'. */);
DEFVAR_LISP ("menu-bar-final-items", Vmenu_bar_final_items,
doc: /* List of menu bar items to move to the end of the menu
bar.
-The elements of the list are event types that may have menu bar bindings. */);
+The elements of the list are event types that may have menu bar
+bindings. The order of this list controls the order of the items. */);
Vmenu_bar_final_items = Qnil;
DEFVAR_LISP ("tab-bar-separator-image-expression",
Vtab_bar_separator_image_expression,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master c47479c: Sort items in tmm properly, and allow clicking the final item,
Lars Ingebrigtsen <=