2012-11-10 107 views
7

我在Mac OS X和Ubuntu上都使用emacs。我的.emacs在两个平台上基本相同,有几行涉及本地字体和其他操作系统相关的东西。正如我通常添加到我的.emacs文件,我想以准自动方式同步它们。 我的问题是---是否有一种方法在Lisp中添加一个条件过程来检测运行的操作系统?类似于(伪代码):.emacs代码来识别操作系统?

If OS X: 
    run this and that command; 
If Linux: 
    run that other command; 
Fi 

在此先感谢。

回答

9

继bmeric的建议,该解决方案为我工作:

(cond 
    ((string-equal system-type "gnu/linux") 
     ;; window size 
     (add-to-list 'default-frame-alist '(left . 0)) 
     (add-to-list 'default-frame-alist '(top . 0)) 
     (add-to-list 'default-frame-alist '(height . 32)) 
     (add-to-list 'default-frame-alist '(width . 70)) 
     ) 
    ((string-equal system-type "darwin") 
    ;; window size 
     (add-to-list 'default-frame-alist '(left . 0)) 
     (add-to-list 'default-frame-alist '(top . 0)) 
     (add-to-list 'default-frame-alist '(height . 63)) 
     (add-to-list 'default-frame-alist '(width . 100)) 
    ) 
)