Testing for platform in elisp?
I'm sharing my emacs configuration files between a linux box and an OS X box. The config breaks however when I define a specific font for Emacs.app in the config which is then not available on linux.
Is there a way I can test for the current platform and then execute or skip the OS X specific instructions?开发者_开发技巧
The elisp variable system-type is what you want. So you can write
(if (eq system-type 'darwin)
(your-macosx-specific-configuration))
another possibility to consider is testing directly for the font
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 from console emacs in OS X, which just testing for the system wouldn't catch
精彩评论