I use Emacs. However, I am not familiar with Lisp although I do know some functional programming, and hence I never really understood how to customize the init.el.

So basically, I want to be able to enable the toolbar mode and menubar mode only if I am in R-mode.

I know that to enable these mode simply requires:

(tool-bar-mode 1) and (menu-bar-mode 1)

but what if I want to do this locally, i.e. enable them only if I am in R-mode.

What should I put in the init.el ?

  • 6
    You posted the exact same question on Stack Overflow at almost exactly the same time. Please do not abuse the sites like this: people on Emacs.SE will not know about comments/answers on S.O. and vice-versa unless they happen to be checking both.
    – Dan
    Commented Jan 24, 2015 at 15:04
  • I didn't realise there was Emacs.SE until after I posted the question on StackOverflow. I am sorry about this. Commented Jan 24, 2015 at 17:38

1 Answer 1


tool-bar-mode and menu-bar-mode being a global modes, you can enable them using a mode hook, but all buffers in all frames will be affected.

Never used it, but you may be interested by toolbar-here-mode

In addition to defining minor mode tool-bar-pop-up-mode, this
library defines minor mode tool-bar-here-mode, which is the
same as the global tool-bar-mode except that it affects only
the current frame.

For menu-bar-mode, you have the toggle-menu-bar-mode-from-frame function:

(toggle-menu-bar-mode-from-frame &optional ARG)

Toggle menu bar on or off, based on the status of the current frame. See `menu-bar-mode' for more information

And use it with a key, for example in your init file:

(global-set-key [f2] 'toggle-menu-bar-mode-from-frame)

  • 1
    tool-bar-here-mode and the pop-up tool bar of tool-bar-pop-up-mode are described here.
    – Drew
    Commented Jan 24, 2015 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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