.emacs代码以识别OS



我在Mac OS X和Ubuntu上都使用Emacs。我的.emacs在两个平台上大多都是相同的,其中有几行涉及本地字体和其他与OS相关的内容。就像我通常在.emacs文件中添加的那样,我想以准自动的方式同步它们。我的问题是--- LISP中有没有办法添加有条件的过程来检测运行的操作系统?类似(伪代码):

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

预先感谢。

按照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))
    )
)

您可以使用系统类型变量。

最新更新