【问题标题】:.emacs code to identify OS?.emacs 代码来识别操作系统?
【发布时间】:2012-10-30 21:05:49
【问题描述】:
我在 Mac OS X 和 Ubuntu 上都使用 emacs。我的 .emacs 在两个平台上基本相同,有几行涉及本地字体和其他与操作系统相关的内容。由于我通常会在我的 .emacs 文件中添加内容,因此我想以准自动的方式同步它们。
我的问题是——在 Lisp 中有没有办法添加一个条件过程来检测正在运行的操作系统?类似(伪代码):
If OS X:
run this and that command;
If Linux:
run that other command;
Fi
提前致谢。
【问题讨论】:
标签:
macos
ubuntu
emacs
operating-system
elisp
【解决方案1】:
按照 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))
)
)