Subject: 29.0.50; batch-byte-recompile-directory doesn't recompile file as expected
From: David Ponce <[email-masked]>
To: [email-masked]
Date: Wed, 9 Nov 2022 02:19:22 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello,

I recently observed that batch-byte-recompile-directory no more
recompile .el files newer than their .elc file.

Here is the shell command I use:

emacs -batch --no-init-file --no-site-file --eval "(setq load-path [my
load path])" -f batch-byte-recompile-directory .

After some investigation, I found that commit
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=8638aace3fbe01529f33870f469fa60bf5e43ee7
could be the culprit.

The attached patch fixed the above commit and solved the issue for me.

Thanks

In GNU Emacs 29.0.50 (build 6, x86_64-pc-linux-gnu, GTK+ Version
  3.24.34, cairo version 1.17.6) of 2022-11-07 built on kilauea
Repository revision: d04433b96215d7d3387573f19cc315de86f2341a
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12014000
System Description: Fedora Linux 36 (KDE Plasma)

Configured using:
  'configure --prefix=/home/dponce --with-x-toolkit=gtk3
  PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB

Important settings:
   value of $LC_TIME: fr_FR.utf8
   value of $LANG: fr_FR.UTF-8
   locale-coding-system: utf-8-unix
index 4d258da..c81c42e 100644
--- a/emacs/lisp/emacs-lisp/bytecomp.el
+++ b/bytecomp.el
@@ -1941,11 +1941,10 @@ also be compiled."
 		      ;; This file is a subdirectory.  Handle them differently.
 		      (or (null arg) (eq 0 arg)
 			  (y-or-n-p (concat "Check " source "? ")))
-		      (setq directories (nconc directories (list source)))
                       ;; Directory is requested to be ignored
-                      (string-match-p
-                       (regexp-opt byte-compile-ignore-files)
-                       source)
+                      (not (string-match-p
+                            (regexp-opt byte-compile-ignore-files)
+                            source))
                       (setq directories (nconc directories (list source))))
                ;; It is an ordinary file.  Decide whether to compile it.
                (if (and (string-match emacs-lisp-file-regexp source)
@@ -1955,9 +1954,9 @@ also be compiled."
                         (not (auto-save-file-name-p source))
                         (not (member source (dir-locals--all-files directory)))
                         ;; File is requested to be ignored
-                        (string-match-p
-                         (regexp-opt byte-compile-ignore-files)
-                         source))
+                        (not (string-match-p
+                              (regexp-opt byte-compile-ignore-files)
+                              source)))
                    (progn (cl-incf
                            (pcase (byte-recompile-file source force arg)
                              ('no-byte-compile skip-count)