Indeed, there are two different ways to show TTY menus:
- either
tmm-menubar
(the "ugly" menu),
- or
popup-menu
(the "nicer" menu).
It appears <f10>
calls popup-menu
by default, but this is customizable if ever we want to downgrade this to tmm-menubar
:
tty-menu-open-use-tmm is a variable defined in menu-bar.el.gz.
Value
nil
Documentation
If non-nil, <f10> on a TTY will invoke tmm-menubar.
If nil, <f10> will drop down the menu corresponding to the
first (leftmost) menu-bar item; you can select other items by typing
C-f, C-b, <right> and <left>.
This variable was added, or its default value changed, in Emacs 24.4.
Anyway, it's feasible to come up with a lisp solution to have <mouse-1>
behave the same.
Here is a proof of concept, inspired by this answer by @npostavs, itself inspired by menu-bar.el
:
(defun menu-bar-get-minimal-x (menu-symbol x y)
(let ((xx (- x 1)))
(if (< xx tty-menu--initial-menu-x)
x
(if (equal (menu-bar-menu-at-x-y xx y (selected-frame)) menu-symbol)
(menu-bar-get-minimal-x menu-symbol xx y)
x))))
(defun menu-bar-open-x-y (mouse-event)
(interactive "e")
(pcase mouse-event
(`(mouse-1 (,_ menu-bar (,x . ,y) . ,_))
(let ((menu (menu-bar-menu-at-x-y x y)))
(popup-menu (or
(lookup-key-ignore-too-long
global-map (vector 'menu-bar menu))
(lookup-key-ignore-too-long
(current-local-map) (vector 'menu-bar menu))
(cdar (minor-mode-key-binding (vector 'menu-bar menu)))
(mouse-menu-bar-map))
(posn-at-x-y (menu-bar-get-minimal-x menu x y) y nil t)
nil t)))
(_ (message "unsupported event %S" (car mouse-event)))))
(define-key global-map (kbd "<menu-bar> <mouse-1>") 'menu-bar-open-x-y)