unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Philip Kaludercic <philipk@posteo.net>
To: Tony Zorman <tonyzorman@mailbox.org>
Cc: emacs-devel@gnu.org
Subject: Re: package-vc support for :files keyword
Date: Wed, 27 Sep 2023 14:03:15 +0000	[thread overview]
Message-ID: <87pm231zoc.fsf@posteo.net> (raw)
In-Reply-To: <87h6niml91.fsf@hyperspace> (Tony Zorman's message of "Mon, 25 Sep 2023 15:32:26 +0200")

[-- Attachment #1: Type: text/plain, Size: 1167 bytes --]

Tony Zorman <tonyzorman@mailbox.org> writes:

> On Sun, Sep 24 2023 16:31, Philip Kaludercic wrote:
>> Tony Zorman <tonyzorman@mailbox.org> writes:
>>
>>> On Wed, Sep 20 2023 07:32, Philip Kaludercic wrote:
>>>> +        (unless (string-match-p ignored-files file)
>>>
>>> One thing that did jump out to me just now, which I hadn't considered
>>> before: when ignored-files is the empty string, this will always match
>>> any file—not what we want :)
>>
>> Do you mean because the empty glob expression doesn't match everything,
>> but the empty regular expression does?
>>
>> The easiest solution seems to be to just check if the empty string is
>> listed and handle that separately (whatever the correct behaviour is in
>> that case), but on the other hand, why should a user list an empty
>> string in the list of ignored files?
>
> The point I was making was that `(mapconcat (λ…) nil) ≡ ""`, since
> mapconcat always returns a string. Even if there were no :ignored-files
> listed, the ignored-files variable would then be the empty string,
> matching each and every file.

Oops, right, in that case this should be preferable:


[-- Attachment #2: Type: text/plain, Size: 3287 bytes --]

diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el
index a8393cb7e75..d100e0bcb58 100644
--- a/lisp/emacs-lisp/package-vc.el
+++ b/lisp/emacs-lisp/package-vc.el
@@ -213,7 +213,7 @@ package-vc--desc->spec
 name for PKG-DESC."
   (alist-get
    (setq name (or name (package-desc-name pkg-desc)))
-   (if (and (package-desc-archive pkg-desc)
+   (if (and pkg-desc (package-desc-archive pkg-desc)
             (not (alist-get name package-vc-selected-packages
                             nil nil #'string=)))
        (alist-get (intern (package-desc-archive pkg-desc))
@@ -501,7 +501,8 @@ package-vc--unpack-1
 autoloads, generating a package description file (used to
 identify a package as a VC package later on), building
 documentation and marking the package as installed."
-  (let (missing)
+  (let ((pkg-spec (package-vc--desc->spec pkg-desc))
+        missing)
     ;; Remove any previous instance of PKG-DESC from `package-alist'
     (let ((pkgs (assq (package-desc-name pkg-desc) package-alist)))
       (when pkgs
@@ -510,17 +511,29 @@ package-vc--unpack-1
     ;; In case the package was installed directly from source, the
     ;; dependency list wasn't know beforehand, and they might have
     ;; to be installed explicitly.
-    (let ((deps '()))
+    (let ((ignored-files
+           (if (plist-get pkg-spec :ignored-files)
+               (mapconcat
+                (lambda (ignore)
+                  (wildcard-to-regexp
+                   (if (string-match-p "\\`/" ignore)
+                       (concat pkg-dir ignore)
+                     (concat "*/" ignore))))
+                (plist-get pkg-spec :ignored-files)
+                "\\|")
+             regexp-unmatchable))
+          (deps '()))
       (dolist (file (directory-files pkg-dir t "\\.el\\'" t))
-        (with-temp-buffer
-          (insert-file-contents file)
-          (when-let* ((require-lines (lm-header-multiline "package-requires")))
-            (thread-last
-              (mapconcat #'identity require-lines " ")
-              package-read-from-string
-              package--prepare-dependencies
-              (nconc deps)
-              (setq deps)))))
+        (unless (string-match-p ignored-files file)
+          (with-temp-buffer
+            (insert-file-contents file)
+            (when-let* ((require-lines (lm-header-multiline "package-requires")))
+              (thread-last
+                (mapconcat #'identity require-lines " ")
+                package-read-from-string
+                package--prepare-dependencies
+                (nconc deps)
+                (setq deps))))))
       (dolist (dep deps)
         (cl-callf version-to-list (cadr dep)))
       (setf missing (package-vc-install-dependencies (delete-dups deps)))
@@ -529,8 +542,7 @@ package-vc--unpack-1
                           missing)))
 
     (let ((default-directory (file-name-as-directory pkg-dir))
-          (pkg-file (expand-file-name (package--description-file pkg-dir) pkg-dir))
-          (pkg-spec (package-vc--desc->spec pkg-desc)))
+          (pkg-file (expand-file-name (package--description-file pkg-dir) pkg-dir)))
       ;; Generate autoloads
       (let* ((name (package-desc-name pkg-desc))
              (auto-name (format "%s-autoloads.el" name))

  reply	other threads:[~2023-09-27 14:03 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-10 10:53 package-vc support for :files keyword Daniel Fleischer
2023-06-10 13:23 ` Philip Kaludercic
2023-06-10 14:20   ` Daniel Fleischer
2023-06-11  8:55     ` Philip Kaludercic
2023-06-11  9:30       ` Daniel Fleischer
2023-06-11 10:24         ` Philip Kaludercic
2023-09-18  7:25   ` Tony Zorman
2023-09-18  9:10     ` Philip Kaludercic
2023-09-18 14:43       ` Tony Zorman
2023-09-18 15:52         ` Philip Kaludercic
2023-09-18 18:54           ` Adam Porter
2023-09-19  8:37             ` Philip Kaludercic
2023-09-19 12:23               ` Adam Porter
2023-09-19 13:56                 ` Philip Kaludercic
2023-09-19 14:14                   ` Adam Porter
2023-09-18 19:40           ` Tony Zorman
2023-09-19  8:47             ` Philip Kaludercic
2023-09-19 13:48               ` Adam Porter
2023-09-19 14:00                 ` Philip Kaludercic
2023-09-19 14:17               ` Tony Zorman
2023-09-20  7:32                 ` Philip Kaludercic
2023-09-21 13:28                   ` Tony Zorman
2023-09-21 16:32                     ` Philip Kaludercic
     [not found]                   ` <87jzsgm82h.fsf@hyperspace>
2023-09-24 14:31                     ` Philip Kaludercic
2023-09-25 13:32                       ` Tony Zorman
2023-09-27 14:03                         ` Philip Kaludercic [this message]
2023-10-04  6:44                           ` Tony Zorman
2023-09-19 22:51             ` Jonas Bernoulli
2023-09-22 12:38               ` Stefan Kangas
2023-09-22 13:26                 ` Philip Kaludercic

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=87pm231zoc.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=emacs-devel@gnu.org \
    --cc=tonyzorman@mailbox.org \
    /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).