[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] New convenience macros
From: |
Stefan Monnier |
Subject: |
Re: [PATCH] New convenience macros |
Date: |
Mon, 20 Aug 2007 00:09:47 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) |
> 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))
nil
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.
Stefan
- Re: [PATCH] New convenience macros, (continued)
- Re: [PATCH] New convenience macros, Kim F. Storm, 2007/08/20
- Re: [PATCH] New convenience macros, Richard Stallman, 2007/08/20
- Re: [PATCH] New convenience macros, Steve Youngs, 2007/08/23
- Re: [PATCH] New convenience macros, Johan Bockgård, 2007/08/23
- Re: [PATCH] New convenience macros, Stefan Monnier, 2007/08/23
- Re: [PATCH] New convenience macros, Steve Youngs, 2007/08/23
- Re: [PATCH] New convenience macros, Stefan Monnier, 2007/08/23
- Re: [PATCH] New convenience macros, Steve Youngs, 2007/08/26
- Re: [PATCH] New convenience macros, Richard Stallman, 2007/08/26
- Re: [PATCH] New convenience macros, Steve Youngs, 2007/08/26
Re: [PATCH] New convenience macros,
Stefan Monnier <=