From d23723cfb24b87170f53ce615bff083ef2d7e76a Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Thu, 26 Nov 2020 11:00:35 +0100 Subject: [PATCH] Allow following symlinks when recompiling directories * doc/lispref/compile.texi (Compilation Functions): Document it. * lisp/emacs-lisp/bytecomp.el (byte-recompile-directory): Allow following symlinks (bug#10292). --- doc/lispref/compile.texi | 6 +++++- etc/NEWS | 4 ++++ lisp/emacs-lisp/bytecomp.el | 11 ++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/doc/lispref/compile.texi b/doc/lispref/compile.texi index ad8afaae608..51a4b04486a 100644 --- a/doc/lispref/compile.texi +++ b/doc/lispref/compile.texi @@ -199,7 +199,7 @@ $ ls -l push* @end example @end deffn -@deffn Command byte-recompile-directory directory &optional flag force +@deffn Command byte-recompile-directory directory &optional flag force follow-symlinks @cindex library compilation This command recompiles every @samp{.el} file in @var{directory} (or its subdirectories) that needs recompilation. A file needs @@ -218,6 +218,10 @@ Interactively, @code{byte-recompile-directory} prompts for If @var{force} is non-@code{nil}, this command recompiles every @samp{.el} file that has a @samp{.elc} file. +This command will normally not compile @samp{.el} files that are +symlinked. If the optional @var{follow-symlink} parameter is +non-@code{nil}, symlinked @samp{.el} will also be compiled. + The returned value is unpredictable. @end deffn diff --git a/etc/NEWS b/etc/NEWS index e0916f56b87..2fb33e342e7 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2017,6 +2017,10 @@ to lexical binding, where dynamic (special) variables bound in one file can affect code in another. For details, see the manual section "(Elisp) Converting to Lexical Binding". ++++ +** 'byte-recompile-directory' can now compile symlinked .el files. +This is achieved by giving a non-nil FOLLOW-SYMLINKS parameter. + --- ** 'unload-feature' now also tries to undo additions to buffer-local hooks. diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index e6f6a12b53d..9ece8ec6f02 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -1746,7 +1746,7 @@ Files in subdirectories of DIRECTORY are processed also." (byte-recompile-directory directory nil t)) ;;;###autoload -(defun byte-recompile-directory (directory &optional arg force) +(defun byte-recompile-directory (directory &optional arg force follow-symlinks) "Recompile every `.el' file in DIRECTORY that needs recompilation. This happens when a `.elc' file exists but is older than the `.el' file. Files in subdirectories of DIRECTORY are processed also. @@ -1759,7 +1759,11 @@ compile it. A nonzero ARG also means ask about each subdirectory before scanning it. If the third argument FORCE is non-nil, recompile every `.el' file -that already has a `.elc' file." +that already has a `.elc' file. + +This command will normally not follow symlinks when compiling +files. If FOLLOW-SYMLINKS is non-nil, symlinked `.el' files will +also be compiled." (interactive "DByte recompile directory: \nP") (if arg (setq arg (prefix-numeric-value arg))) (if noninteractive @@ -1792,7 +1796,8 @@ that already has a `.elc' file." (if (file-directory-p source) (and (not (member file '("RCS" "CVS"))) (not (eq ?\. (aref file 0))) - (not (file-symlink-p source)) + (or follow-symlinks + (not (file-symlink-p source))) ;; This file is a subdirectory. Handle them differently. (or (null arg) (eq 0 arg) (y-or-n-p (concat "Check " source "? "))) -- 2.39.5