The problem: In terminal Emacs, clicking on an item in the menu bar will open "tmm-menubar".
Expected behavior: "menu-bar-open" should be run instead (i.e. a
drop-down menu should appear instead of tmm-menubar).
For example, if I left-click on the "Edit" menu item in the menu
bar, I expect the "Edit" drop-down to appear. Currently however, a
left-click on a menu item will open tmm-menubar in a *Completions*
window. This is surprising behavior.
By default, in terminal Emacs, "<menu-bar> <mouse-1>"
is bound to "tmm-menubar-mouse". There doesn't seem to be an easy
way to change this to the drop-down menu instead.
There exist a question about this issue on Emacs Stack Exchange
site: https://emacs.stackexchange.com/questions/50478/replace-clicking-a-menu-bar-option-from-m-to-f10-behavior
The proposed "solution" there is similar to this:
(define-key global-map [menu-bar mouse-1] (lambda (event) (interactive "e") ;; Adapted from the implementation of "menu-bar-open" in Emacs 25.2.2. (let* ((x (car (posn-x-y (event-start event)))) (menu (menu-bar-menu-at-x-y x 0))) (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 x 0 nil t) nil t))))
However, there are serious flaws with this "solution":