Execute code in .emacs file only for command line version of Emacs?
I'm running Carbon Emacs on Macs here, and my GUI开发者_StackOverflow社区 emacs has an extremely pleasing colour scheme set up to use. Unfortunately, it looks like hell when running "emacs" in a Terminal window, which parses the same .emacs file in my root folder.
So, is there a way to conditionally execute code in my .emacs file so that I can select a different colour scheme for command line and "GUI" emacs?
Thanks!
You can use the window-system
variable to determine if you're running Emacs in a windowed environment. For example, you could add something like the following to your .emacs.el
:
(when window-system
(setq default-frame-alist
(append
'((background-color . "#102e4e")
(background-mode . dark)
...))))
Here's the documentation for the window-system
variable (viewable within Emacs by typing C-h v window-system RET):
Name of window system through which the selected frame is displayed.
The value is a symbol--for instance, `x' for X windows.
The value is nil if the selected frame is on a text-only-terminal.
Macs come with a really old version of emacs. so when you are in a terminal it finds that version first:
Valideres-MacBook-Pro:be james$ which emacs
/usr/bin/emacs
Valideres-MacBook-Pro:be james$ emacs --version
GNU Emacs 22.1.1
Copyright (C) 2007 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
Valideres-MacBook-Pro:be james$ /Applications/Emacs.app/Contents/MacOS/Emacs --version
GNU Emacs 25.1.1
Copyright (C) 2016 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
Valideres-MacBook-Pro:be james$ /Applications/Emacs.app/Contents/MacOS/Emacs -nw ~/code/tmp/greatstuff.lsp
emacs is really great in that the desktop version can also run in terminals. Just pass in the -nw option for "no window". So for me I type:
/Applications/Emacs.app/Contents/MacOS/Emacs -nw ~/code/tmp/greatstuff.lsp
and I get the colour theme of the desktop, the modern packages of the desktop and all the new features of the desktop version, but, its in the terminal. You could do some OS linking to make the new one be the default (I can't be bothered)
精彩评论