elisp conditional based on hostname

时光毁灭记忆、已成空白 提交于 2019-12-05 09:12:42

问题


I have a shared .emacs file between different Linux systems. I would like to execute an expression based on the hostname of the system I'm running:

(color-theme-initialize)  ;; required for Ubuntu 10.10 and above.

I suppose one way to avoid checking the hostname would be to factor out the system dependencies from .emacs, but it's been convenient having .emacs in version control. Alternative suggestions are welcome.


回答1:


The system-name variable might be the simplest way to achieve what you're looking for in Emacs below 25.1:

(when (string= system-name "your.ubuntu.host")
  (color-theme-initialize))

This variable is obsolete since 25.1; use (system-name) instead

So in newer Emacs use this:

(when (string= (system-name) "your.ubuntu.host")
  (color-theme-initialize))


来源:https://stackoverflow.com/questions/7549978/elisp-conditional-based-on-hostname

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!