0

When I click on File I want to see f10 and not M-`

What can I change to provide this functionality? This question didn't really get the right answer.

1

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...

  • This works pretty well but there are two glaring problems: - Clicking on a different option than File will still open the file menu - Clicking on File once file is open doesn't close the menu, just reopens it – Soren May 13 at 22:11
  • @Soren see edit, 2nd problem seems quite tough – npostavs May 14 at 0:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.