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

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

[elpa] externals/compat d4624d9aed 7/7: Always load prefixed definitions


From: ELPA Syncer
Subject: [elpa] externals/compat d4624d9aed 7/7: Always load prefixed definitions
Date: Tue, 3 Jan 2023 09:57:27 -0500 (EST)

branch: externals/compat
commit d4624d9aed1eaf3f91108c16b661ad2902100e28
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Always load prefixed definitions
    
    We will move away from prefixed definitions later on and introduce
    `compat-function' and `compat-funcall' macros. These macros make it 
possible to
    call compatibility functions with different calling conventions. The 
prefixed
    definitions will be deprecated. The problem with the prefixed definitions 
is two-fold:
    
    1. They pollute the namespace and the API surface of Compat will become 
larger
    and larger with every version.
    
    2. Since Compat is not part of Emacs itself, the prefixed definitions 
cannot be
    used by :core packages. By adding the `compat-funcall' and `compat-function'
    macro to the core itself, which is a minimal addition, using compatibility
    function with modified calling convention becomes possible.
---
 compat-24.el    |  4 ++--
 compat-25.el    |  2 +-
 compat-26.el    |  2 +-
 compat-27.el    | 10 +++++-----
 compat-28.el    |  2 +-
 compat-macs.el  | 13 +------------
 compat-tests.el |  6 ++----
 compat.el       | 17 ++++++-----------
 8 files changed, 19 insertions(+), 37 deletions(-)

diff --git a/compat-24.el b/compat-24.el
index 2a4e8a8a75..e6ca7928f2 100644
--- a/compat-24.el
+++ b/compat-24.el
@@ -478,7 +478,7 @@ function for defining FACE and recalculating its 
attributes."
   (unless spec-type
     (setq spec-type 'face-override-spec))
   (if (memq spec-type '(face-defface-spec face-override-spec
-                       customized-face saved-face))
+                        customized-face saved-face))
       (put face spec-type spec))
   (if (memq spec-type '(reset saved-face))
       (put face 'customized-face nil))
@@ -495,5 +495,5 @@ function for defining FACE and recalculating its 
attributes."
   (dolist (frame (frame-list))
     (face-spec-recalc face frame)))
 
-(compat--inhibit-prefixed (provide 'compat-24))
+(provide 'compat-24)
 ;;; compat-24.el ends here
diff --git a/compat-25.el b/compat-25.el
index 181dada278..84ef300d37 100644
--- a/compat-25.el
+++ b/compat-25.el
@@ -340,5 +340,5 @@ recursion."
             (push (concat dir "/" file) files)))))
     (nconc result (nreverse files))))
 
-(compat--inhibit-prefixed (provide 'compat-25))
+(provide 'compat-25)
 ;;; compat-25.el ends here
diff --git a/compat-26.el b/compat-26.el
index 127777cad8..eb3bd5eb4e 100644
--- a/compat-26.el
+++ b/compat-26.el
@@ -671,5 +671,5 @@ optional DESCRIPTION field."
         (sit-for 1))
       choice)))
 
-(compat--inhibit-prefixed (provide 'compat-26))
+(provide 'compat-26)
 ;;; compat-26.el ends here
diff --git a/compat-27.el b/compat-27.el
index 9202d5ccc3..0997597ee7 100644
--- a/compat-27.el
+++ b/compat-27.el
@@ -494,14 +494,14 @@ Elements of ALIST that are not conses are ignored."
   :prefix t
   (unless test (setq test #'equal))
   (while (and (consp (car alist))
-             (funcall test (caar alist) key))
+              (funcall test (caar alist) key))
     (setq alist (cdr alist)))
   (let ((tail alist) tail-cdr)
     (while (setq tail-cdr (cdr tail))
       (if (and (consp (car tail-cdr))
-              (funcall test (caar tail-cdr) key))
-         (setcdr tail (cdr tail-cdr))
-       (setq tail tail-cdr))))
+               (funcall test (caar tail-cdr) key))
+          (setcdr tail (cdr tail-cdr))
+        (setq tail tail-cdr))))
   alist)
 
 ;;;; Defined in simple.el
@@ -1001,5 +1001,5 @@ and if a matching region is found, place point at the 
start of the region."
         (and (not (eq ended t))
              ended))))))
 
-(compat--inhibit-prefixed (provide 'compat-27))
+(provide 'compat-27)
 ;;; compat-27.el ends here
diff --git a/compat-28.el b/compat-28.el
index fc877b47e3..6213d7b214 100644
--- a/compat-28.el
+++ b/compat-28.el
@@ -878,5 +878,5 @@ are 30 days long."
      (* (or (nth 4 time) 0) 60 60 24 30)
      (* (or (nth 5 time) 0) 60 60 24 365)))
 
-(compat--inhibit-prefixed (provide 'compat-28))
+(provide 'compat-28)
 ;;; compat-28.el ends here
diff --git a/compat-macs.el b/compat-macs.el
index 75a2e9a3a8..e0220dde70 100644
--- a/compat-macs.el
+++ b/compat-macs.el
@@ -29,17 +29,6 @@
   "Ignore all arguments."
   nil)
 
-(defvar compat--inhibit-prefixed nil
-  "Non-nil means that prefixed definitions are not loaded.
-A prefixed function is something like `compat-assoc', that is
-only made visible when the respective compatibility version file
-is loaded (in this case `compat-26').")
-
-(defmacro compat--inhibit-prefixed (&rest body)
-  "Ignore BODY unless `compat--inhibit-prefixed' is true."
-  `(unless (bound-and-true-p compat--inhibit-prefixed)
-     ,@body))
-
 (defvar compat-current-version nil
   "Default version to use when no explicit version was given.")
 
@@ -114,7 +103,7 @@ DEF-FN, INSTALL-FN, CHECK-FN, ATTR and TYPE."
                            (version< max-version emacs-version)))
                   '(compat--ignore))
                  ((plist-get attr :prefix)
-                  '(compat--inhibit-prefixed))
+                  '(progn))
                  ((and version (version<= version emacs-version) (not cond))
                   '(compat--ignore))
                  (`(when (and ,(if cond cond t)
diff --git a/compat-tests.el b/compat-tests.el
index cdbe9affa8..3594cf8f84 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -70,7 +70,7 @@ DEF-FN, INSTALL-FN, CHECK-FN, ATTR and TYPE."
                      (version< max-version emacs-version)))
             '(compat--ignore))
            ((plist-get attr :prefix)
-            '(compat--inhibit-prefixed))
+            '(progn))
            ((and version (version<= version emacs-version) (not cond))
             '(compat--ignore))
            (`(when (and ,(if cond cond t)
@@ -82,9 +82,7 @@ DEF-FN, INSTALL-FN, CHECK-FN, ATTR and TYPE."
 
 (setq compat--generate-function #'compat--generate-testable)
 
-(defvar compat-testing)
-(let ((compat-testing t))
-  (load "compat.el"))
+(require 'compat)
 
 (defvar compat-test-counter)
 
diff --git a/compat.el b/compat.el
index cfe3bf7e53..7c400cedd7 100644
--- a/compat.el
+++ b/compat.el
@@ -40,17 +40,12 @@
 
 ;;; Code:
 
-(defvar compat--inhibit-prefixed)
-(let ((compat--inhibit-prefixed (not (bound-and-true-p compat-testing))))
-  ;; Instead of using `require', we manually check `features' and call
-  ;; `load' to avoid the issue of not using `provide' at the end of
-  ;; the file (which is disabled by `compat--inhibit-prefixed', so
-  ;; that the file can be loaded again at some later point when the
-  ;; prefixed definitions are needed).
-  (dolist (version '(24 25 26 27 28 29))
-    (let ((feature-name (format "compat-%d" version)))
-      (unless (memq (intern feature-name) features)
-        (load feature-name nil t)))))
+(require 'compat-24)
+(require 'compat-25)
+(require 'compat-26)
+(require 'compat-27)
+(require 'compat-28)
+(require 'compat-29)
 
 (provide 'compat)
 ;;; compat.el ends here



reply via email to

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