aboutsummaryrefslogtreecommitdiff
path: root/compat.el
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2023-02-11 01:46:07 +0100
committerDaniel Mendler <mail@daniel-mendler.de>2023-02-11 01:46:07 +0100
commit5bd2c405cfbf0b7adff3dbd2316baec650271eea (patch)
tree8b9574f0368793e6ee86adc6a1c61e6da65b2ae3 /compat.el
parent99facb3a764aa282a22c256bedf39113a29041b5 (diff)
More robust method to require libraries conditionally
Diffstat (limited to 'compat.el')
-rw-r--r--compat.el10
1 files changed, 8 insertions, 2 deletions
diff --git a/compat.el b/compat.el
index 56bed48..ed34965 100644
--- a/compat.el
+++ b/compat.el
@@ -46,8 +46,14 @@
;;; Code:
-(when (eval-when-compile (< emacs-major-version 29))
- (require 'compat-29))
+;; Ensure that the newest compatibility layer is required at compile
+;; time and runtime, but only if needed.
+(eval-when-compile
+ (defmacro compat--maybe-require-29 ()
+ (when (< emacs-major-version 29)
+ (require 'compat-29)
+ '(require 'compat-29))))
+(compat--maybe-require-29)
;;;; Macros for extended compatibility function calls