Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

elisp conditional based on hostname

Tags:

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.

like image 594
Jeff Bauer Avatar asked Sep 26 '11 01:09

Jeff Bauer


1 Answers

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)) 
like image 129
Hugh Avatar answered Oct 12 '22 04:10

Hugh