New conditional compilation macro static-if.
* etc/NEWS: Record the new macro. * lisp/subr.el (static-if): New macro.
This commit is contained in:
parent
6278e15f62
commit
97652d0e7a
2 changed files with 22 additions and 1 deletions
8
etc/NEWS
8
etc/NEWS
|
@ -55,7 +55,7 @@ the signature) the automatically inferred function type as well.
|
|||
---
|
||||
** New user option 'describe-bindings-outline-rules'.
|
||||
This user option controls outline visibility in the output buffer of
|
||||
'describe-bindings' when 'describe-bindings-outline' in non-nil.
|
||||
'describe-bindings' when 'describe-bindings-outline' is non-nil.
|
||||
|
||||
** X selection requests are now handled much faster and asynchronously.
|
||||
This means it should be less necessary to disable the likes of
|
||||
|
@ -861,6 +861,12 @@ Use 'define-minor-mode' and 'define-globalized-minor-mode' instead.
|
|||
See the "(elisp) Porting Old Advice" node for help converting them
|
||||
to use 'advice-add' or 'define-advice' instead.
|
||||
|
||||
+++
|
||||
** New macro 'static-if' for conditional compilation of code.
|
||||
This macro hides a form from the compiler based on a compile-time
|
||||
condition. This is handy for avoiding byte-compilation warnings about
|
||||
code that will never actually run under some conditions.
|
||||
|
||||
+++
|
||||
** Desktop notifications are now supported on the Haiku operating system.
|
||||
The new function 'haiku-notifications-notify' provides a subset of the
|
||||
|
|
15
lisp/subr.el
15
lisp/subr.el
|
@ -277,6 +277,21 @@ change the list."
|
|||
(macroexp-let2 macroexp-copyable-p x getter
|
||||
`(prog1 ,x ,(funcall setter `(cdr ,x))))))))
|
||||
|
||||
;; Note: `static-if' can be copied into a package to enable it to be
|
||||
;; used in Emacsen older than Emacs 30.1. If the package is used in
|
||||
;; very old Emacsen or XEmacs (in which `eval' takes exactly one
|
||||
;; argument) the copy will need amending.
|
||||
(defmacro static-if (condition then-form &rest else-forms)
|
||||
"A conditional compilation macro.
|
||||
Evaluate CONDITION at macro-expansion time. If it is non-nil,
|
||||
expand the macro to THEN-FORM. Otherwise expand it to ELSE-FORMS
|
||||
enclosed in a `progn' form. ELSE-FORMS may be empty."
|
||||
(declare (indent 2)
|
||||
(debug (sexp sexp &rest sexp)))
|
||||
(if (eval condition lexical-binding)
|
||||
then-form
|
||||
(cons 'progn else-forms)))
|
||||
|
||||
(defmacro when (cond &rest body)
|
||||
"If COND yields non-nil, do BODY, else return nil.
|
||||
When COND yields non-nil, eval BODY forms sequentially and return
|
||||
|
|
Loading…
Add table
Reference in a new issue