2

Preface: I disabled menu-bar-mode and bound <mouse-3> to menu-bar-open, via (global-set-key [mouse-3] #'menu-bar-open)

With this configuration, how can I get help for menu-bar items?
(My ugly workaround now is to temporary enable menu-bar-mode and call help with that enabled)

Problem is: pressing C-h k and then mouse-3 brings description for menu-bar-open.
What I'd like to get instead, is the same describe-key behaviour as on C-<mouse2> menus.
This should be done in a way, which does not break on emacs updates (i.e: redefining describe-key seems to dangerous).

If there is no way to do above , how could I bind <mouse-3> to open the menu-bar and get the desired help functionality?

Edit: Solution from Tobias is not complete, it does not show local-menu and minor-mode-menus. Function mouse-menu-bar-map, which is called from menu-bar-open collects them all.

Edit2: [C-down-mouse-3] does what I expect, but I can't remap this with:

(global-set-key [mouse-3] (lookup-key (current-global-map) [C-down-mouse-3]))
1

The value of the variable facemenu-menu is bound to C-<mouse2> and that value is a sparse keymap.

Instead of binding #'menu-bar-open to <mouse-3> you can also bind the sparse keymap defining the menu bar to <mouse-3>:

EDIT: As indicated by jue t is better to receive the menu bar keymap from mouse-menu-bar-map than to use the value of (lookup-key [menu-bar]) because the menu bar is changed dynamically. menu-bar-update-hook cannot be used for reacting on dynamical changes of the menu bar since that hook is only run when the menu bar is switched on. But an advice for define-key does the job as far as I could test it up to now.

(defun my-menu-bar-update (&rest _ignore)
  "Update the [mouse-3] menu bar."
  (unless my-menu-bar-update-running
    (let ((my-menu-bar-update-running t))
      (global-set-key [mouse-3] (mouse-menu-bar-map)))))
(my-menu-bar-update)
(add-hook 'menu-bar-update-hook #'my-menu-bar-update)
(advice-add 'define-key :after #'my-menu-bar-update)
  • too bad, this is not a complete solution, because local-menu and minor-mode-menus are not displayed. Have a look at function (mouse-menu-bar-map) it collects them all. – jue Oct 9 at 12:27
  • @jue I am using mouse-menu-bar-map now. Please test again. Thanks. – Tobias Oct 11 at 8:45
  • Sorry it is not yet fully functional, because the menu-bar-menu needs to be updated on more occasions, ie. switching the mode of a buffer (or to buffers with another mode) is not changing the menu as it should. Also note, that the (defvar ...) is not visible in the above answer. – jue Oct 14 at 14:35
  • Maybe this could be solved by using some more hooks, but seems this is not worth the trouble, since the menu is on C-<down-mouse-3> anyway – jue Oct 15 at 7:46

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.