2009-12-08 88 views
3

我在Mac上運行Carbon Emacs,我的GUI emacs有一個非常令人滿意的配色方案。不幸的是,當在終端窗口中運行「emacs」時,它看起來像是地獄,它會解析我的根文件夾中相同的.emacs文件。僅在命令行版本的Emacs中執行.emacs文件中的代碼?

那麼,有沒有辦法在我的.emacs文件中有條件地執行代碼,以便我可以爲命令行和「GUI」emacs選擇不同的配色方案?

謝謝!

回答

10

您可以使用window-system變量來確定您是否在窗口環境中運行Emacs。例如,您可以添加類似下面給您.emacs.el

(when window-system 
    (setq default-frame-alist 
    (append 
     '((background-color . "#102e4e") 
     (background-mode . dark) 
     ...)))) 

這裏是爲window-system變量的文件(通過鍵入在Emacs可視章3V窗口系統RET):

顯示選定框架的窗口系統的名稱。
該值是一個符號 - 例如,X窗口的「x」。
如果所選幀位於純文本終端上,則該值爲零。

+0

乾杯。訣竅了。 – MarcWan 2009-12-09 07:30:23

0

Mac帶有一個真正舊版本的emacs。所以當你在一個終端首先發現版本:

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是在桌面版本還可以在終端運行的真的很棒。只需傳入「無窗口」的-nw選項即可。所以對我來說我鍵入:

/Applications/Emacs.app/Contents/MacOS/Emacs -nw ~/code/tmp/greatstuff.lsp 

,我得到了桌面的顏色主題,桌面的現代包裝和所有的桌面版的新功能,但是,它在終端。你可以做一些操作系統鏈接,使新的默認(我不能打擾)