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

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

[elpa] externals/compat 0331e24121: Move compat--generate-verbose to com


From: ELPA Syncer
Subject: [elpa] externals/compat 0331e24121: Move compat--generate-verbose to compat-tests.el
Date: Thu, 28 Jul 2022 18:57:23 -0400 (EDT)

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

    Move compat--generate-verbose to compat-tests.el
---
 compat-macs.el  | 61 +++++----------------------------------------------------
 compat-tests.el | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 63 insertions(+), 57 deletions(-)

diff --git a/compat-macs.el b/compat-macs.el
index a2de41da7b..f661fd1158 100644
--- a/compat-macs.el
+++ b/compat-macs.el
@@ -40,7 +40,7 @@ is loaded (in this case `compat-26').")
   `(unless (bound-and-true-p compat--inhibit-prefixed)
      ,@body))
 
-(defvar compat--generate-function #'compat--generate-minimal
+(defvar compat--generate-function #'compat--generate-default
   "Function used to generate compatibility code.
 The function must take six arguments: NAME, DEF-FN, INSTALL-FN,
 CHECK-FN, ATTR and TYPE.  The resulting body is constructed by
@@ -85,7 +85,7 @@ ignored:
 
 TYPE is used to set the symbol property `compat-type' for NAME.")
 
-(defun compat--generate-minimal (name def-fn install-fn check-fn attr type)
+(defun compat--generate-default (name def-fn install-fn check-fn attr type)
   "Generate a leaner compatibility definition.
 See `compat-generate-function' for details on the arguments NAME,
 DEF-FN, INSTALL-FN, CHECK-FN, ATTR and TYPE."
@@ -93,7 +93,9 @@ DEF-FN, INSTALL-FN, CHECK-FN, ATTR and TYPE."
          (max-version (plist-get attr :max-version))
          (feature (plist-get attr :feature))
          (cond (plist-get attr :cond))
-         (version ; If you edit this, also edit `compat--generate-verbose'.
+         (version
+          ;; If you edit this, also edit `compat--generate-testable' in
+          ;; `compat-tests.el'.
           (or (plist-get attr :version)
               (let* ((file (car (last current-load-list)))
                      (file (if (stringp file)
@@ -155,59 +157,6 @@ DEF-FN, INSTALL-FN, CHECK-FN, ATTR and TYPE."
             `(eval-after-load ,feature `(funcall ',(lambda () ,body)))
           body))))))
 
-(defun compat--generate-verbose (name def-fn install-fn check-fn attr type)
-  "Generate a more verbose compatibility definition, fit for testing.
-See `compat-generate-function' for details on the arguments NAME,
-DEF-FN, INSTALL-FN, CHECK-FN, ATTR and TYPE."
-  (let* ((min-version (plist-get attr :min-version))
-         (max-version (plist-get attr :max-version))
-         (feature (plist-get attr :feature))
-         (cond (plist-get attr :cond))
-         (version ; If you edit this, also edit `compat--generate-minimal'.
-          (or (plist-get attr :version)
-              (let* ((file (car (last current-load-list)))
-                     (file (if (stringp file)
-                               file
-                             (or (bound-and-true-p byte-compile-current-file)
-                                 (buffer-file-name)))))
-                (if (and file
-                         (string-match
-                          "compat-\\([[:digit:]]+\\)\\.\\(?:elc?\\)\\'" file))
-                    (concat (match-string 1 file) ".1")
-                  (error "BUG: No version number could be extracted")))))
-         (realname (or (plist-get attr :realname)
-                       (intern (format "compat--%S" name))))
-         (body `(progn
-                  (unless (or (null (get ',name 'compat-def))
-                              (eq (get ',name 'compat-def) ',realname))
-                    (error "Duplicate compatibility definition: %s (was %s, 
now %s)"
-                           ',name (get ',name 'compat-def) ',realname))
-                  (put ',name 'compat-def ',realname)
-                  ,(funcall install-fn realname version))))
-    `(progn
-       (put ',realname 'compat-type ',type)
-       (put ',realname 'compat-version ,version)
-       (put ',realname 'compat-min-version ,min-version)
-       (put ',realname 'compat-max-version ,max-version)
-       (put ',realname 'compat-doc ,(plist-get attr :note))
-       ,(funcall def-fn realname version)
-       (,@(cond
-           ((or (and min-version
-                     (version< emacs-version min-version))
-                (and max-version
-                     (version< max-version emacs-version)))
-            '(compat--ignore))
-           ((plist-get attr :prefix)
-            '(compat--inhibit-prefixed))
-           ((and version (version<= version emacs-version) (not cond))
-            '(compat--ignore))
-           (`(when (and ,(if cond cond t)
-                        ,(funcall check-fn)))))
-        ,(if feature
-             ;; See https://nullprogram.com/blog/2018/02/22/:
-             `(eval-after-load ,feature `(funcall ',(lambda () ,body)))
-           body)))))
-
 (defun compat-generate-common (name def-fn install-fn check-fn attr type)
   "Common code for generating compatibility definitions.
 See `compat-generate-function' for details on the arguments NAME,
diff --git a/compat-tests.el b/compat-tests.el
index 70b7829453..47135cc2d2 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -35,8 +35,65 @@
 (require 'ert)
 
 (require 'compat-macs)
+
+(defun compat--generate-testable (name def-fn install-fn check-fn attr type)
+  "Generate a more verbose compatibility definition, fit for testing.
+See `compat-generate-function' for details on the arguments NAME,
+DEF-FN, INSTALL-FN, CHECK-FN, ATTR and TYPE."
+  (let* ((min-version (plist-get attr :min-version))
+         (max-version (plist-get attr :max-version))
+         (feature (plist-get attr :feature))
+         (cond (plist-get attr :cond))
+         (version
+          ;; If you edit this, also edit `compat--generate-default' in
+          ;; compat-macs.el.
+          (or (plist-get attr :version)
+              (let* ((file (car (last current-load-list)))
+                     (file (if (stringp file)
+                               file
+                             (or (bound-and-true-p byte-compile-current-file)
+                                 (buffer-file-name)))))
+                (if (and file
+                         (string-match
+                          "compat-\\([[:digit:]]+\\)\\.\\(?:elc?\\)\\'" file))
+                    (concat (match-string 1 file) ".1")
+                  (error "BUG: No version number could be extracted")))))
+         (realname (or (plist-get attr :realname)
+                       (intern (format "compat--%S" name))))
+         (body `(progn
+                  (unless (or (null (get ',name 'compat-def))
+                              (eq (get ',name 'compat-def) ',realname))
+                    (error "Duplicate compatibility definition: %s (was %s, 
now %s)"
+                           ',name (get ',name 'compat-def) ',realname))
+                  (put ',name 'compat-def ',realname)
+                  ,(funcall install-fn realname version))))
+    `(progn
+       (put ',realname 'compat-type ',type)
+       (put ',realname 'compat-version ,version)
+       (put ',realname 'compat-min-version ,min-version)
+       (put ',realname 'compat-max-version ,max-version)
+       (put ',realname 'compat-doc ,(plist-get attr :note))
+       ,(funcall def-fn realname version)
+       (,@(cond
+           ((or (and min-version
+                     (version< emacs-version min-version))
+                (and max-version
+                     (version< max-version emacs-version)))
+            '(compat--ignore))
+           ((plist-get attr :prefix)
+            '(compat--inhibit-prefixed))
+           ((and version (version<= version emacs-version) (not cond))
+            '(compat--ignore))
+           (`(when (and ,(if cond cond t)
+                        ,(funcall check-fn)))))
+        ,(if feature
+             ;; See https://nullprogram.com/blog/2018/02/22/:
+             `(eval-after-load ,feature `(funcall ',(lambda () ,body)))
+           body)))))
+
+(setq compat--generate-function #'compat--generate-testable)
+
 (defvar compat-testing)
-(setq compat--generate-function #'compat--generate-verbose)
 (let ((compat-testing t))
   (load "compat.el"))
 



reply via email to

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