我需要在.emacs中进行不同的设置,具体取决于我的系统(Mac或PC).
这篇文章讲述了如何知道我的emacs正在运行的系统.
??? (when (eq system-type 'windows-nt') )
你可以这样做:
(if (equal system-type 'windows-nt)
(progn
(... various windows-nt stuff ...)))
(if (equal system-type 'darwin)
(progn
(... various mac stuff ...)))
Run Code Online (Sandbox Code Playgroud)
我在.emacs中所做的是根据机器类型和名称设置一个变量(我称之为this-config).然后我到处都使用相同的.emacs.
使用此代码,我可以拉出机器名称:
(defvar this-machine "default")
(if (getenv "HOST")
(setq this-machine (getenv "HOST")))
(if (string-match "default" this-machine)
(if (getenv "HOSTNAME")
(setq this-machine (getenv "HOSTNAME"))))
(if (string-match "default" this-machine)
(setq this-machine system-name))
Run Code Online (Sandbox Code Playgroud)
然后,您可以根据系统类型和/或计算机名称设置this-config.
然后我使用这段代码:
(cond ((or (equal this-machine "machineX")
(equal this-machine "machineY"))
(do some setup for machineX and machineY))
Run Code Online (Sandbox Code Playgroud)
编辑:system-type返回符号,而不是字符串
| 归档时间: |
|
| 查看次数: |
729 次 |
| 最近记录: |