emacs-diffs
[Top][All Lists]
Advanced

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

master 246d68bd2a5 2/2: Add 'native-compile-directory' (bug#73303)


From: Andrea Corallo
Subject: master 246d68bd2a5 2/2: Add 'native-compile-directory' (bug#73303)
Date: Tue, 22 Oct 2024 12:23:46 -0400 (EDT)

branch: master
commit 246d68bd2a5468bd428a0406402e7ad2b3005314
Author: Andrea Corallo <acorallo@gnu.org>
Commit: Andrea Corallo <acorallo@gnu.org>

    Add 'native-compile-directory' (bug#73303)
    
    * lisp/emacs-lisp/comp.el (native-compile-directory): New function.
    * etc/NEWS (native-compile-directory): Add to NEWS.
---
 etc/NEWS                |  5 +++++
 lisp/emacs-lisp/comp.el | 11 +++++++++++
 2 files changed, 16 insertions(+)

diff --git a/etc/NEWS b/etc/NEWS
index 028e92c57c9..63c294fac41 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -630,6 +630,11 @@ sup-mouse.el, terminal.el, vi.el, vip.el, ws-mode.el, and 
yow.el.
 
 * Lisp Changes in Emacs 31.1
 
+---
+** New function 'native-compile-directory'.
+This function native compiles all Lisp files in a directory and in its
+sub-directories (if they are not already native compiled).
+
 +++
 ** The 'defcustom' ':local' keyword can now be 'permanent-only'.
 This means that the variable's 'permanent-local' property is set to t,
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index fc87014202c..8866f47aa66 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -3662,6 +3662,17 @@ the compilation was successful return the compiled 
function."
                             (or native-comp-function string))))
   (comp--native-compile function-or-file nil output))
 
+;;;###autoload
+(defun native-compile-directory (directory)
+  "Native compile if necessary all the .el files present in DIRECTORY.
+Each .el file is native compiled if the corresponding .eln file is not
+found inside the current `native-comp-eln-load-path'. The search within
+DIRECTORY is perfomed recursively."
+  (mapc (lambda (file)
+         (unless (comp-lookup-eln file)
+           (native-compile file)))
+       (directory-files-recursively directory ".+\\.el\\'")))
+
 ;;;###autoload
 (defun batch-native-compile (&optional for-tarball)
   "Perform batch native compilation of remaining command-line arguments.



reply via email to

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