H开发者_C百科ow can I tell (from inside of .emacs) whether or not the Emacs version is Cocoa? I only want some configuration options to apply when they are loaded in Cocoa Emacs and not in the command-line version.
Try (featurep 'ns)
to check for the NextStep emacs feature. See also C-h v window-system
, can check if that variable is 'ns
.
It's sufficient to do something similar to the following:
To see if you're on a Mac and not running in the command-line version:
(when (and (eq system-type 'darwin) window-system)
(setq my-option "cocoa"))
To see if you're on a Mac and are running in the command-line version:
(when (and (eq system-type 'darwin) (not window-system))
(setq my-option "command-line"))
EDIT: I edited my answer to check for both Mac (system-type) and not command-line (window-system).
精彩评论