How to check if Emacs is in GUI mode (and execute `tool-bar-mode` only then)?
I have this line in my .emacs
file:
(tool-bar-mode 0)
because I hate the toolbars in my GUI emacs (/Applications/Emacs.app/Contents/MacOS/Emacs
).
But when I start up my other, text-based emacs in the terminal (/opt/local/bin/emacs
) it complains about that command:
Symbol's function definition is void: tool-bar-mode
How can I add an if
condition so that it executes the tool-bar-mode
command only when I'm in the GUI emacs?
Thanks!
Okay, found it myself. Just add
;; turn off toolbar
(if window-system
(tool-bar-mode 0))
another way to do it would be:
(if (functionp 'tool-bar-mode) (tool-bar-mode 0))
like this, the function is called only if it exists