branch: externals/compat
commit a9afe05baa5c768077244ee18ef55870a4fbfc4b
Author: Daniel Mendler <m...@daniel-mendler.de>
Commit: Daniel Mendler <m...@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")
 

Reply via email to