开发者

Run certain Emacs init commands only in GUI mode

开发者 https://www.devze.com 2023-01-08 14:56 出处:网络
Is there a way to run certain commands (from init.el) only when I am in GUI mode and not in terminal mode. I want to set a certain color scheme when I run the GUI version, but that scheme screws up th

Is there a way to run certain commands (from init.el) only when I am in GUI mode and not in terminal mode. I want to set a certain color scheme when I run the GUI version, but that scheme screws up the terminal window's colors pretty badly. I开发者_JAVA百科'm looking for some variable/function which would look something like this:

(if gui-mode (color-scheme-blah))

or:

(unless terminal-mode (color-scheme-blah))


You want something like

(if window-system (color-scheme-blah))

window-system can be 'x or 'mswindows or possibly even other values, but it's always nil when you are on a terminal.


To generally test for a graphic display you want to use the following:

(display-graphic-p &optional DISPLAY)

It returns non-nil if DISPLAY is a graphic display. Using for example the window-system variable also works, but requires you to refer to a specific environment (such as X or Microsoft Windows).


When using emacsclient and frames GUI or terminal mode is not necessarily a global concept. See the very useful answer to my question at https://superuser.com/questions/165335/how-can-i-show-the-emacs-menu-in-gui-emacs-frames-but-not-in-tty-frames-when-usin .

0

精彩评论

暂无评论...
验证码 换一张
取 消