Search code examples
emacslispelispemacs23

How to change/remove Emacs menu items?


I intend to change certain features/functions in Emacs. I'm familiar with different modes however my question is how certain functions are removed from the Graphical Interface - e.g. removing Games from Tools item in Menu bar or add new items to it?


Solution

  • You can add menu items with define-key or define-key-after. For example, to add a Forward char menu item at the start of the Go To submenu, you'd write:

    (define-key (lookup-key global-map [menu-bar edit goto])
      [go-to-forward] '("Forward-char" . forward-char))
    

    ...and to put it after the Goto Line... item:

    (define-key-after (lookup-key global-map [menu-bar edit goto])
      [go-to-forward] '("Forward char" . forward-char) 'go-to-line)
    

    With this, and the info in the referred post, you should be able to change menus as you like.

    As always, everything is documented: http://www.gnu.org/software/emacs/manual/html_node/elisp/Menu-Keymaps.html