首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在elisp中确定操作系统?

如何在elisp中确定操作系统?
EN

Stack Overflow用户
提问于 2009-11-30 08:14:29
回答 7查看 17.8K关注 0票数 98

如何以编程方式确定在ELisp中运行Emacs的操作系统?

我想根据操作系统在.emacs中运行不同的代码。

EN

回答 7

Stack Overflow用户

回答已采纳

发布于 2009-11-30 08:37:55

system-type变量:

代码语言:javascript
复制
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.
票数 105
EN

Stack Overflow用户

发布于 2010-06-19 11:23:07

对于刚接触elisp的人来说,示例用法如下:

代码语言:javascript
复制
(if (eq system-type 'darwin)
  ; something for OS X if true
  ; optional something if not
)
票数 87
EN

Stack Overflow用户

发布于 2014-10-01 16:48:59

我创建了一个简单的宏,以便根据系统类型轻松运行代码:

代码语言:javascript
复制
(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!"))
票数 22
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1817257

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档