Using Gnu Emacs 23.1.1 on Ubuntu 10.04...

I've decided to go cold turkey with the Gnome menu bar. (but I do want it to be "available" for the teething transition period... tepid turkey? :)

So I'd like to know how to assign a key to toggle it on/off..

I'm currently starting Emacs in full screen mode, with no menu-bar and no tool-bar I'm trying out a tabbar (when in X, but not when in terminal) ..

I'm almost getting used to it, but I find I feel completely lost sometimes without the menubar... I've read that Emacs without the GUI paraphenalia is the way to go.. and I believe it!... the paradigms clash..

But for now I'd like a menu-bar toggle, and it will be good experience to see how it is done..

2 Answers 2


If you just want to toggle the menu bar, there's already a command for that (M-x menu-bar-mode). To bind it to a key, you'd do:

(global-set-key (kbd "<f5>") 'menu-bar-mode)

If you want both the menu and toolbar to be toggled, you can do something like this:

(defun toggle-menu-toolbar-modes ()
  (tool-bar-mode (menu-bar-mode)))
(global-set-key (kbd "<f5>") 'toggle-menu-toolbar-modes)

It's probably worth looking at the Emacs FAQ (also found by C-h C-f). Also, the SO info page for Emacs has a bunch of good links.

  • 2
    Thanks.. nice links too... It works. I tried it 3 times and I've already outgrown it... I discoverd the f10 key which presents the exact same menu in an emacs-style... I'm starting to understand emac's reputation; it's seems to have pretty well everything covered :)
    – Peter.O
    Feb 12, 2011 at 20:16
  • Works only once. If I bind to separate actions, it works: (global-set-key (kbd "<f6>") 'toggle-tool-bar-mode-from-frame) (global-set-key (kbd "<f7>") 'toggle-menu-bar-mode-from-frame)
    – rofrol
    Jun 14, 2018 at 12:05

Here's how I do it.

;; Disable menubar by default
(menu-bar-mode -1)
(tool-bar-mode -1)
(defun toggle-top-menu ()
  "Run toggle-menu-bar-mode-from-frame and toggle-tool-bar-mode-from-frame"
  (menu-bar-mode (if tool-bar-mode -1 1))
  (tool-bar-mode (if tool-bar-mode -1 1)))
(global-set-key (kbd "<f3>") 'toggle-top-menu)

It solves the issue of the function only working once raised in comment by @rofrol

  • +1, i really like the default mode, plus the ability to toggle the visibility when needed
    – douardo
    Mar 29, 2022 at 9:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .