Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine operating system in elisp?

Tags:

emacs

elisp

How do I programmatically determine which OS Emacs is running under in ELisp?

I would like to run different code in .emacs depending on the OS.

like image 919
ljs Avatar asked Nov 30 '09 00:11

ljs


2 Answers

The system-type variable:

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. 
like image 197
scottfrazer Avatar answered Nov 23 '22 21:11

scottfrazer


For folks newer to elisp, a sample usage:

(if (eq system-type 'darwin)   ; something for OS X if true   ; optional something if not ) 
like image 25
Endrju Avatar answered Nov 23 '22 23:11

Endrju