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

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

[elpa] externals/compat 5d4fdf41db 01/10: Merge byte compilation output


From: ELPA Syncer
Subject: [elpa] externals/compat 5d4fdf41db 01/10: Merge byte compilation output into a single file
Date: Mon, 28 Feb 2022 03:57:32 -0500 (EST)

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

    Merge byte compilation output into a single file
---
 compat.el | 44 ++++++++++++++++++++++++++++++++++++++------
 1 file changed, 38 insertions(+), 6 deletions(-)

diff --git a/compat.el b/compat.el
index d3f2e50a71..2a71f68902 100644
--- a/compat.el
+++ b/compat.el
@@ -140,12 +140,44 @@ advice."
         (not (eq (cdr (compat-func-arity func t)) n))
       (void-function t))))
 
-;; Load the actual compatibility definitions:
-(require 'compat-24.4)
-(require 'compat-25.1)
-(require 'compat-26.1)
-(require 'compat-27.1)
-(require 'compat-28.1)
+;; To accelerate the loading process, we insert the contents of
+;; compat-N.M.el directly into the compat.elc.
+(eval-and-compile
+  (defmacro compat-insert (version)
+    (if (boundp 'compat-testing)
+        (load (format "compat-%s.el" version))
+      (let* ((file (expand-file-name
+                    (format "compat-%s.el" version)
+                    (file-name-directory
+                     (or (and (boundp 'byte-compile-current-file) 
byte-compile-current-file)
+                         load-file-name
+                         buffer-file-name))))
+             (byte-compile-current-file file)
+             defs)
+        (unless (file-exists-p file)
+          (error "Cannot load %S" file))
+        (let ((load-file-name file))
+          (with-temp-buffer
+            (insert-file-contents file)
+            (emacs-lisp-mode)
+            (while (progn
+                     (forward-comment 1)
+                     (not (eobp)))
+              (let ((sexp (read (current-buffer))))
+                (push (if (or (eq (car-safe sexp) 'compat-defun)
+                              (eq (car-safe sexp) 'compat-defmacro)
+                              (eq (car-safe sexp) 'compat-advise)
+                              (eq (car-safe sexp) 'compat-defvar))
+                          (macroexpand-all sexp)
+                        sexp)
+                      defs)))
+            (cons 'progn (nreverse defs))))))))
+
+(compat-insert "24.4")
+(compat-insert "25.1")
+(compat-insert "26.1")
+(compat-insert "27.1")
+(compat-insert "28.1")
 
 ;;;; Etcetera
 



reply via email to

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