Platform testing in elisp?

I share emacs configuration files between the Linux box and the OS X box. However, the configuration breaks when I define a specific font for Emacs.app in the configuration, which is then not available on Linux.

Is there a way to check the current platform and then execute or skip specific OS X instructions?

+6
emacs elisp
source share
2 answers

The elisp system type variable is what you want. So you can write

(if (eq system-type 'darwin) (your-macosx-specific-configuration)) 
+8
source share

Another option to consider is direct font testing.

in my .emacs file I have the following:

 (let ((prefered-fonts '("-apple-espresso mono-medium-r-normal--0-0-0-0-m-0-iso10646-1"))) (dolist (font prefered-fonts) (if (and (functionp 'x-list-fonts) (x-list-fonts font)) (progn (add-to-list 'initial-frame-alist (cons 'font font)) (add-to-list 'default-frame-alist (cons 'font font)))))) 

this works even with emacs consoles in OS X that just testing for the system will not catch

+3
source share

All Articles