aboutsummaryrefslogtreecommitdiff
path: root/compat.texi
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2023-09-03 16:13:31 +0200
committerDaniel Mendler <mail@daniel-mendler.de>2023-09-03 16:18:58 +0200
commitabe97399f840929e6cff55fe9f5fb9110b6a7c97 (patch)
treed1c40cdc1a2e6d24eaa30d060bb52a9cab0003b8 /compat.texi
parentbf4b9aaa2e80cae253f23561b93a2feacf74d004 (diff)
compat-30: Add static-if
Diffstat (limited to 'compat.texi')
-rw-r--r--compat.texi25
1 files changed, 25 insertions, 0 deletions
diff --git a/compat.texi b/compat.texi
index 178106c..a6ea20b 100644
--- a/compat.texi
+++ b/compat.texi
@@ -3348,6 +3348,31 @@ older than 30.1. Note that due to upstream changes, it might happen
that there will be the need for changes, so use these functions with
care.
+@defmac static-if condition then-form else-forms...
+Test @var{condition} at macro-expansion time. If its value is
+non-@code{nil}, expand the macro to @var{then-form}, otherwise expand
+it to @var{else-forms} enclosed in a @code{progn}. @var{else-forms}
+may be empty.
+
+Here is an example of its use from CC Mode, which prevents a
+@code{defadvice} form being compiled in newer versions of Emacs:
+@example
+@group
+(static-if (boundp 'comment-line-break-function)
+ (progn)
+ (defvar c-inside-line-break-advice nil)
+ (defadvice indent-new-comment-line (around c-line-break-advice
+ activate preactivate)
+ "Call `c-indent-new-comment-line' if in CC Mode."
+ (if (or c-inside-line-break-advice
+ (not c-buffer-is-cc-mode))
+ ad-do-it
+ (let ((c-inside-line-break-advice t))
+ (c-indent-new-comment-line (ad-get-arg 0))))))
+@end group
+@end example
+@end defmac
+
@subsection Extended Definitions
These functions must be called explicitly via @code{compat-call},
since their calling convention or behavior was extended in Emacs 30.1: