3

I run both gui frames and tty frames on the same server. I'd like to only have the gui frames have the menu-bar and I want all tty frames to not have a menu bar.

I'm confused by the menu bar docs, is there a way to do this?

8

The function display-graphic-p returns nil for non-GUI Emacs. So something like the following should work:

(unless (display-graphic-p)
   (menu-bar-mode -1))

EDIT

My original answer only works for Emacs run only in a tty. Since you are using both GUI and TTY frames run from the same server, you need to modify individual frame parameters:

(defun contextual-menubar (&optional frame)
  "Display the menubar in FRAME (default: selected frame) if on a
    graphical display, but hide it if in terminal."
  (interactive)
  (set-frame-parameter frame 'menu-bar-lines 
                             (if (display-graphic-p frame)
                                  1 0)))

(add-hook 'after-make-frame-functions 'contextual-menubar)

Source: https://stackoverflow.com/questions/24956521/how-can-i-hide-the-menu-bar-from-a-specific-frame-in-emacs

  • Where would I put that? Like a before-make-frame-hook? – Aaron Jensen Dec 20 '16 at 18:17
  • I tried before-make-frame-hook and that did not work. – Aaron Jensen Dec 20 '16 at 18:24
  • The recommendation from Emacs dev is to use display-graphic-p now, instead of window-system. I forget why. ;-) (But either will work.) – Drew Dec 20 '16 at 20:53
  • Works for me thanks! Could you please remove the trailing space after menu-bar-lines? – Midiparse Nov 20 '17 at 12:08

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.