all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philip Kaludercic <philipk@posteo.net>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: Removing packages from archive-contents if removed from elpa-packages
Date: Wed, 02 Nov 2022 06:59:27 +0000	[thread overview]
Message-ID: <871qqldepc.fsf@posteo.net> (raw)
In-Reply-To: <jwvfsf2xgiz.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Tue, 01 Nov 2022 22:02:04 -0400")

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> No, you are absolutely right, I just didn't see that.
>>
>> From 62fa93b120f664f1be44c1194f701a1c5d965f2a Mon Sep 17 00:00:00 2001
>> From: Philip Kaludercic <philipk@posteo.net>
>> Date: Mon, 31 Oct 2022 17:01:07 +0100
>> Subject: [PATCH 1/2] Remove deleted packages from archive-contents
>>
>> * elpa-admin.el (elpaa--write-archive-contents): Extract from
>> 'elpaa--update-archive-contents'
>> (elpaa--update-archive-contents): Use 'elpaa--write-archive-contents'.
>> (elpaa--scrub-archive-contents): Add function.
>> (elpaa-batch-make-all-packages): Call 'elpaa--scrub-archive-contents'.
>> ---
>>  elpa-admin.el | 31 ++++++++++++++++++++++++++-----
>>  1 file changed, 26 insertions(+), 5 deletions(-)
>>
>> diff --git a/elpa-admin.el b/elpa-admin.el
>> index c03fea47a1..12306ec818 100644
>> --- a/elpa-admin.el
>> +++ b/elpa-admin.el
>> @@ -154,6 +154,14 @@ Delete backup files also."
>>  	       (backup-file-name-p f))
>>  	   (delete-file f)))))
>>  
>> +(defun elpaa--write-archive-contents (ac dir)
>> +  "Write archive contents AC into directory DIR."
>> +  (with-temp-buffer
>> +    (pp ac (current-buffer))
>> +    (write-region nil nil (expand-file-name "archive-contents" dir)))
>> +  (let ((default-directory (expand-file-name dir)))
>> +    (elpaa--html-make-index (cdr ac))))
>> +
>>  (defun elpaa--update-archive-contents (pkg-desc dir)
>>    "Update the `archive-contents' file in DIR with new package PKG-DESC."
>>    (let* ((filename (expand-file-name "archive-contents" dir))
>> @@ -166,11 +174,7 @@ Delete backup files also."
>>                           (lambda (x y)
>>                             (string-lessp (symbol-name (car x)) (symbol-name (car y))))))
>>      (elpaa--message "new AC: %S" ac)
>> -    (with-temp-buffer
>> -      (pp ac (current-buffer))
>> -      (write-region nil nil filename)
>> -      (let ((default-directory (expand-file-name dir)))
>> -        (elpaa--html-make-index (cdr ac))))))
>> +    (elpaa--write-archive-contents ac dir)))
>>  
>>  (defun elpaa--get-specs ()
>>    (elpaa--form-from-file-contents elpaa--specs-file))
>> @@ -788,6 +792,21 @@ of the current `process-environment'.  Return the modified copy."
>>  	  (list pkgname))
>>        spec)))
>>  
>> +(defun elpaa--scrub-archive-contents (dir specs)
>> +  "Remove dead packages from archive contents in DIR.
>> +SPECS is the list of package specifications."
>> +  (let* ((filename (expand-file-name "archive-contents" dir))
>> +         (ac (if (file-exists-p filename)
>> +                 (elpaa--form-from-file-contents filename)
>> +               '(1))))
>> +    (elpaa--write-archive-contents
>> +     (cons (car ac)
>> +           (mapcan
>> +            (lambda (pkg)
>> +              (and (assoc (car pkg) specs #'string=) (list pkg)))
>> +            (cdr ac)))
>> +     dir)))
>
> LGTM.  Feel free to push.  

Will do.

>                            Just one comment: we could skip the
> `elpaa--write-archive-contents` (and associated
> `elpaa--html-make-index`) in the overwhelmingly common case where
> nothing was scrubbed.

Good point.

>
>         Stefan



      reply	other threads:[~2022-11-02  6:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-31  9:40 Removing packages from archive-contents if removed from elpa-packages Philip Kaludercic
2022-10-31 12:11 ` Stefan Monnier
2022-10-31 14:25   ` Philip Kaludercic
2022-10-31 14:47     ` Stefan Kangas
2022-10-31 15:10       ` Philip Kaludercic
2022-10-31 16:06     ` Philip Kaludercic
2022-10-31 17:53       ` Stefan Monnier
2022-11-01 10:42         ` Philip Kaludercic
2022-11-02  2:02           ` Stefan Monnier
2022-11-02  6:59             ` Philip Kaludercic [this message]

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

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

  git send-email \
    --in-reply-to=871qqldepc.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.