emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/compat 21c70607aa 01/13: Have minimal definitions expan


From: ELPA Syncer
Subject: [elpa] externals/compat 21c70607aa 01/13: Have minimal definitions expand to a defalias if possible
Date: Sun, 13 Mar 2022 19:57:31 -0400 (EDT)

branch: externals/compat
commit 21c70607aacfb5e457e3d51bbeb49323b40cc9e7
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>

    Have minimal definitions expand to a defalias if possible
---
 compat-macs.el | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/compat-macs.el b/compat-macs.el
index 1b762d8428..a0e2bfb68d 100644
--- a/compat-macs.el
+++ b/compat-macs.el
@@ -104,17 +104,27 @@ DEF-FN, INSTALL-FN, CHECK-FN, ATTR and TYPE."
                   '(compat--ignore))
                  (`(when (and ,(if cond cond t)
                               ,(funcall check-fn)))))))
-    (if (and (not (plist-get attr :prefix))
-             (plist-get attr :realname))
-        `(progn
-           ,(funcall def-fn realname version)
-           (,@check
-            ,(let ((body (funcall install-fn realname version)))
-               (if feature
-                   ;; See https://nullprogram.com/blog/2018/02/22/:
-                   `(eval-after-load ,feature `(funcall ',(lambda () ,body)))
-                 body))))
-      (let* ((body (if (eq type 'advice)
+    (cond
+     ((and (plist-get attr :prefix) (memq type '(func macro))
+           (string-match "\\`compat-\\(.+\\)\\'" (symbol-name name))
+           (let* ((actual-name (intern (match-string 1 (symbol-name name))))
+                  (body (funcall install-fn actual-name  version)))
+             (when (fboundp actual-name)
+               `(,@check
+                 ,(if feature
+                      ;; See https://nullprogram.com/blog/2018/02/22/:
+                      `(eval-after-load ,feature `(funcall ',(lambda () 
,body)))
+                    body))))))
+     ((plist-get attr :realname)
+      `(progn
+         ,(funcall def-fn realname version)
+         (,@check
+          ,(let ((body (funcall install-fn realname version)))
+             (if feature
+                 ;; See https://nullprogram.com/blog/2018/02/22/:
+                 `(eval-after-load ,feature `(funcall ',(lambda () ,body)))
+               body)))))
+     ((let* ((body (if (eq type 'advice)
                        `(,@check
                          ,(funcall def-fn realname version)
                          ,(funcall install-fn realname version))
@@ -122,7 +132,7 @@ DEF-FN, INSTALL-FN, CHECK-FN, ATTR and TYPE."
         (if feature
             ;; See https://nullprogram.com/blog/2018/02/22/:
             `(eval-after-load ,feature `(funcall ',(lambda () ,body)))
-          body)))))
+          body))))))
 
 (defun compat--generate-minimal-no-prefix (name def-fn install-fn check-fn 
attr type)
   "Generate a leaner compatibility definition.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]