I added these to SXEmacs a little while ago. They are a couple of
macros that can be used when you need to conditionalise on emacs
flavour. And at the same time not generate byte-compiler warnings,
regardless of the flavour of emacs you are using to compile the .el.
We've done it differently in Emacs-22 (and maybe even Emacs-21: can't
remember exactly when it was introduced): (featurep 'xemacs) is known by the
source-level optimizer as a constant of value nil, so
(if (featurep 'xemacs) a b)
will only look at `b' and won't generate any warnings about code in `a'.
The corresponding code is very simple (in byte-opt.el):
(put 'featurep 'byte-optimizer 'byte-optimize-featurep)
(defun byte-optimize-featurep (form)
;; Emacs-21's byte-code doesn't run under XEmacs anyway, so we can
;; safely optimize away this test.
(if (equal '((quote xemacs)) (cdr-safe form))
I haven't come across any (featurep 'sxemacs) yet, so the code hasn't been
updated for that use yet, but it's trivial to do so, obviously.
The advantage over a macro is that the elisp code will work regardless of
whether this optimization is implemented (it only affects byte-compiler
warnings anyway), so it's trivially backward&forward compatible.
XEmacs-Patches mailing list