如何以编程方式确定在ELisp中运行Emacs的操作系统?
我想根据操作系统在.emacs
中运行不同的代码。
发布于 2009-11-30 08:37:55
system-type
变量:
system-type is a variable defined in `C source code'.
Its value is darwin
Documentation:
Value is symbol indicating type of operating system you are using.
Special values:
`gnu' compiled for a GNU Hurd system.
`gnu/linux' compiled for a GNU/Linux system.
`darwin' compiled for Darwin (GNU-Darwin, Mac OS X, ...).
`ms-dos' compiled as an MS-DOS application.
`windows-nt' compiled as a native W32 application.
`cygwin' compiled using the Cygwin library.
Anything else indicates some sort of Unix system.
发布于 2010-06-19 11:23:07
对于刚接触elisp的人来说,示例用法如下:
(if (eq system-type 'darwin)
; something for OS X if true
; optional something if not
)
发布于 2014-10-01 16:48:59
我创建了一个简单的宏,以便根据系统类型轻松运行代码:
(defmacro with-system (type &rest body)
"Evaluate BODY if `system-type' equals TYPE."
(declare (indent defun))
`(when (eq system-type ',type)
,@body))
(with-system gnu/linux
(message "Free as in Beer")
(message "Free as in Freedom!"))
https://stackoverflow.com/questions/1817257
复制相似问题