2012-11-10 182 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)) 
    ) 
)