aboutsummaryrefslogtreecommitdiff
path: root/compat-macs.el
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2023-01-04 12:47:45 +0100
committerDaniel Mendler <mail@daniel-mendler.de>2023-01-04 12:47:45 +0100
commitde7346396aab592610e05990aab154a02b73f46d (patch)
treea0610cc55078f4fba31286a4fea623435f76fd3b /compat-macs.el
parent601387077ad229c8d31a0c2b698626659e1f5939 (diff)
Add compat-feature macro
Diffstat (limited to 'compat-macs.el')
-rw-r--r--compat-macs.el7
1 files changed, 7 insertions, 0 deletions
diff --git a/compat-macs.el b/compat-macs.el
index c06fc00..4e3e549 100644
--- a/compat-macs.el
+++ b/compat-macs.el
@@ -29,6 +29,13 @@
(setq compat--current-version version)
nil)
+(defmacro compat-feature (feature &rest body)
+ (declare (indent 1))
+ (when feature
+ (unless (require feature nil t)
+ (setq feature nil)))
+ (compat--with-feature feature (macroexp-progn body)))
+
(defun compat--with-feature (feature body)
"Protect BODY with `eval-after-load' if FEATURE is non-nil."
(declare (indent 1))