emacs window systems

在配置emacs的时候,一直想区别对待x-window和terminal两种环境。上周五配的nxhtml时,因为mumamo会给同一个buffer中的不同模式加上背景色,而我一般以终端方式使用emacs,所以当然希望背景全是黑的。

(custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right.

'(mumamo-background-chunk-major ((((class color) (min-colors 8)) (:background "black")))) '(mumamo-background-chunk-submode1 ((((class color) (min-colors 8)) (:background "black")))) '(mumamo-background-chunk-submode2 ((((class color) (min-colors 8)) (:background "black")))) '(mumamo-background-chunk-submode3 ((((class color) (min-colors 8)) (:background "black")))) '(mumamo-background-chunk-submode4 ((((class color) (min-colors 8)) (:background "black")))))

这时候,情况出现了。使用GUI方式时同一buffer的不同模式的背景是黑色,但和GUI默认的代码高亮方案冲突了,所以代码基本没法看。而terminal下面又表现的近乎完美,所以才有想区别对待x-window和terminal两种情况。翻遍emacs lisp才找到原来有个系统变量=window-system=,那么接下来的事情就好办了,为x-window装一个配色解决方案:color-theme: ;; color theme (if (eq window-system 'x) (progn (setq default-font "DejaVu Sans Mono") (add-to-list 'load-path "share.emacs.d/color-theme-6.6.0") (require 'color-theme) (eval-after-load "color-theme" '(progn (color-theme-initialize) (color-theme-hober)))))

下面是emacs lisp手册中的原文描述:

Window Systems Emacs works with several window systems, most notably the X Window System. Both Emacs and X use the term "window", but use it differently. An Emacs frame is a single window as far as X is concerned; the individual Emacs windows are not known to X at all.

topVariable: window-system This variable tells Lisp programs what window system Emacs is running under. The possible values are

x Emacs is displaying using X. pc Emacs is displaying using MSDOS. w32 Emacs is displaying using Windows NT or Windows 95. nil Emacs is using a character-based terminal.

这下就完美了!!!