基于主机名的elisp条件 [英] elisp conditional based on hostname

查看:61
本文介绍了基于主机名的elisp条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在不同的Linux系统之间有一个共享的.emacs文件。我想根据正在运行的系统的主机名执行一个表达式:

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.

我想一种避免检查主机名的方法是从.emacs中排除系统依赖性,但是在版本控制中使用.emacs很方便。欢迎提出其他建议。

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.

推荐答案

系统名称变量可能是在25.1以下的Emacs中获得所需内容的最简单方法:

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))




此变量自25.1起已作废;
使用(系统名称)代替

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

因此在较新的Emacs中使用以下命令:

So in newer Emacs use this:

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

这篇关于基于主机名的elisp条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆