2010-08-17

Determining running environment and platform capabilities in Emacs.

To proper work on different Emacs releases and on different platforms large/complex .emacs config file must check certain condition.

I collect come of them and by this post make it public.

So check variables:

emacs-major-version emacs-minor-version window-system - 'nil' if in terminal, 'w32' if native Windows build, 'x' if under X Window window-system-version - for windows only operating-system-release - release of the operating system Emacs is running on system-configuration - like configuration triplet: cpu-manufacturer-os system-name - host name of the machine you are running on system-time-locale system-type - indicating the type of operating system you are using: 'gnu' (GNU Hurd), 'gnu/linux', 'gnu/kfreebsd' (FreeBSD), 'darwin' (GNU-Darwin, Mac OS X), 'ms-dos', 'windows-nt', 'cygwin' system-uses-terminfo window-size-fixed
and check functions:
(fboundp ...) - return t if SYMBOL's function definition is not void (featurep ...) - returns t if FEATURE is present in this Emacs (display-graphic-p) - return non-nil if DISPLAY is a graphic display; graphical displays are those which are capable of displaying several frames and several different fonts at once (display-multi-font-p) - same as 'display-graphic-p' (display-multi-frame-p) - same as 'display-graphic-p' (display-color-p) - return t if DISPLAY supports color (display-images-p) - return non-nil if DISPLAY can display images (display-grayscale-p) - return non-nil if frames on DISPLAY can display shades of gray (display-mouse-p) - return non-nil if DISPLAY has a mouse available (display-popup-menus-p) - return non-nil if popup menus are supported on DISPLAY (display-selections-p) - return non-nil if DISPLAY supports selections
Run those checks as below:
(when window-system ...) (when (eq window-system 'x) ...) (when (>= emacs-major-version 22) ...) (when (fboundp '...) ...) (when (featurep '...) ...)