[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/compat a9afe05baa 3/5: Add compat-funcall and compat-fu
From: |
ELPA Syncer |
Subject: |
[elpa] externals/compat a9afe05baa 3/5: Add compat-funcall and compat-function macros |
Date: |
Tue, 3 Jan 2023 14:57:28 -0500 (EST) |
branch: externals/compat
commit a9afe05baa5c768077244ee18ef55870a4fbfc4b
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Add compat-funcall and compat-function macros
---
compat-24.el | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/compat-24.el b/compat-24.el
index 6add3c056d..46bc069ebb 100644
--- a/compat-24.el
+++ b/compat-24.el
@@ -32,6 +32,21 @@
;;; Code:
+(defmacro compat-function (fun)
+ "Return compatibility function symbol for FUN.
+
+If the Emacs version provides a sufficiently recent version of
+FUN, the symbol FUN is returned itself."
+ (let ((compat (intern (format "compat--%s" fun))))
+ `#',(if (fboundp compat) compat fun)))
+
+(defmacro compat-funcall (fun &rest args)
+ "Call compatibility function FUN with ARGS.
+
+See `compat-function' for the compatibility function resolution."
+ (let ((compat (intern (format "compat--%s" fun))))
+ `(,(if (fboundp compat) compat fun) ,@args)))
+
(eval-when-compile (load "compat-macs.el" nil t t))
(compat-declare-version "24.4")