unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Philip Kaludercic <philipk@posteo.net>
To: Jim Porter <jporterbugs@gmail.com>
Cc: 64985@debbugs.gnu.org
Subject: bug#64985: 29.1; [PATCH] Byte-compilation of packages via package-vc doesn't correctly handle .elpaignore wildcards
Date: Tue, 01 Aug 2023 12:20:36 +0000	[thread overview]
Message-ID: <87edknj6nf.fsf@posteo.net> (raw)
In-Reply-To: <8e555eb8-529d-d11c-66c7-bd16f5d45be7@gmail.com> (Jim Porter's message of "Mon, 31 Jul 2023 23:20:21 -0700")

Jim Porter <jporterbugs@gmail.com> writes:

> When using the various package-vc installation functions, Emacs
> byte-compiles the source (good). However, it doesn't ignore sources
> that match wildcards in ".elpaignore" (bad). That's because, even
> though 'byte-compile-ignore-files' is documented to be a list of
> regexps, 'byte-recompile-directory' treats it as a list of strings.

I am a bit confused about this point.  Why do you think that
`byte-recompile-directory' treads `byte-compile-ignore-files' as a list
of non-regexp strings?

> To reproduce this, install a package via VC, for example via M-x
> package-vc-install RET https://github.com/jimporter/urgrep.git
> RET. Then notice how "urgrep-tests.el" got compiled, even though it
> matches a wildcard in ".elpaignore".
>
> Patch attached to fix this. Eli, would this be safe enough for 29.2?
> 'byte-compile-ignore-files' is a new feature in 29.1, so hopefully no
> one else is relying on its current semantics just yet.
>
> From ec4e198fb9c87653d1e65288969bed1ff548683c Mon Sep 17 00:00:00 2001
> From: Jim Porter <jporterbugs@gmail.com>
> Date: Mon, 31 Jul 2023 23:10:03 -0700
> Subject: [PATCH] Fix handling of ".elpaignore" file when compiling packages
>
> * lisp/emacs-lisp/bytecomp.el (byte-recompile-directory): Treat
> 'byte-compile-ignore-files' as a list of regexps per its docstring.
> ---
>  lisp/emacs-lisp/bytecomp.el | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
> index 5b1d958e6c2..d123e68a088 100644
> --- a/lisp/emacs-lisp/bytecomp.el
> +++ b/lisp/emacs-lisp/bytecomp.el
> @@ -1995,9 +1995,8 @@ byte-recompile-directory
>  		      (or (null arg) (eq 0 arg)
>  			  (y-or-n-p (concat "Check " source "? ")))
>                        ;; Directory is requested to be ignored
> -                      (not (string-match-p
> -                            (regexp-opt byte-compile-ignore-files)
> -                            source))
> +                      (not (seq-some (lambda (ex) (string-match-p ex source))
> +                                     byte-compile-ignore-files))

Here also, instead of merging a list of regular expressions into a
disjunctive one, you match each individually.  Am I missing something,
or what does this change?

(string-match-p (regexp-opt '("foo" "bar" "baz")) "foo") ;=> 0
(seq-some (lambda (ex) (string-match-p ex "foo")) '("foo" "bar" "baz")) ;=> 0

(string-match-p (regexp-opt '("foo" "bar" "baz")) "quux") ;=> nil
(seq-some (lambda (ex) (string-match-p ex "quux")) '("foo" "bar" "baz")) ;=> nil

>                        (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)
> @@ -2007,9 +2006,8 @@ byte-recompile-directory
>                          (not (auto-save-file-name-p source))
>                          (not (member source (dir-locals--all-files directory)))
>                          ;; File is requested to be ignored
> -                        (not (string-match-p
> -                              (regexp-opt byte-compile-ignore-files)
> -                              source)))
> +                        (not (seq-some (lambda (ex) (string-match-p ex source))
> +                                       byte-compile-ignore-files)))
>                     (progn (cl-incf
>                             (pcase (byte-recompile-file source force arg)
>                               ('no-byte-compile skip-count)





  parent reply	other threads:[~2023-08-01 12:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-01  6:20 bug#64985: 29.1; [PATCH] Byte-compilation of packages via package-vc doesn't correctly handle .elpaignore wildcards Jim Porter
2023-08-01 11:21 ` Eli Zaretskii
2023-08-01 19:22   ` Jim Porter
2023-08-01 12:20 ` Philip Kaludercic [this message]
2023-08-01 16:10   ` Jim Porter
2023-08-01 16:18     ` Jim Porter
2023-08-01 17:29 ` Mattias Engdegård
2023-08-01 18:10   ` Jim Porter
2023-08-01 18:32     ` Philip Kaludercic
2023-08-01 19:18       ` Jim Porter
2023-08-01 19:21         ` Philip Kaludercic
2023-08-02 18:08           ` Jim Porter
2023-08-04 19:37 ` bug#64985: 30.0.50; package-recompile-all and package-recompile do not recompile anything, seems related to the patch associated with bug #64985 Vincenzo Pupillo
2023-08-04 20:05   ` Jim Porter
2023-08-05 17:12 ` Mattias Engdegård
2023-08-05 17:16   ` Jim Porter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87edknj6nf.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=64985@debbugs.gnu.org \
    --cc=jporterbugs@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).