When I click on File
I want to see
and not
What can I change to provide this functionality? This question didn't really get the right answer.
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityWhen I click on File
I want to see
and not
What can I change to provide this functionality? This question didn't really get the right answer.
f1 c (describe-key-briefly
) works for mouse clicks and menu items too. So hit f1 c, click on the menu bar, and you'll see <menu-bar> <mouse-1> at that spot runs the command tmm-menubar-mouse
. Whereas f1 c f10 says <f10> runs the command menu-bar-open
. So to rebind:
(define-key global-map (kbd "<menu-bar> <mouse-1>") 'menu-bar-open)
Clicking on a different option than File will still open the file menu
Right, menu-bar-open
doesn't check xy location of the mouse click. Looking at the code of menu-bar-open
I came up with this:
(defun menu-bar-open-xy (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 x y nil t) nil t)))
(_ (error "unexpected event %S" mouse-event))))
(define-key global-map (kbd "<menu-bar> <mouse-1>") 'menu-bar-open-xy)
The X co-ordinate is a bit off though, not clear why.
Clicking on File once file is open doesn't close the menu, just reopens it
Yeah, I'm not sure how to fix that. I guess that explains why this isn't the default in Emacs yet...
File
will still open the file menu - Clicking on File
once file is open doesn't close the menu, just reopens it
– Aly
May 13 '19 at 22:11