~pkal/public-inbox

1

setup.el: Excessive calls to package-refresh-contents

Ralf Schmitt <ralf@systemexit.de>
Details
Message ID
<FFC8A913-AEFA-4215-83CA-B8C4F8191013@systemexit.de>
DKIM signature
permerror
Download raw message
Hi Philip,

Many thanks for your work on the setup.el . There seems to be a problem with the :package keyword.
It uses  (memq package package-archive-contents) to check whether to call package-refresh-contents. This always returns nil and the contents is refreshed for every package being installed.

I’ve tested it on emacs 29.3:

*** Welcome to IELM ***  Type (describe-mode) or press C-h m for help.
ELISP> (package-refresh-contents)
nil
ELISP> (memq 'setup package-archive-contents)
nil
ELISP> (assoc 'setup package-archive-contents)
(setup #s(package-desc :name setup :version
			(1 3 2)
			:summary "Helpful Configuration Macro" :reqs
			((emacs
			  (26 1)))
			:kind tar :archive "gnu" :dir nil :extras
			((:url . "https://git.sr.ht/~pkal/setup")
			 (:keywords "lisp" "local")
			 (:maintainer "Philip Kaludercic" . "~pkal/public-inbox@lists.sr.ht")
			 (:authors
			   ("Philip Kaludercic" . "philipk@posteo.net"))
			 (:commit . "28926bd11eef6118f4e169d10c1c36b8c4e545ae"))
			:signed nil))

ELISP> (emacs-version)
"GNU Emacs 29.3 (build 1, aarch64-apple-darwin23.3.0, NS appkit-2487.40 Version 14.3.1 (Build 23D60))"
ELISP> 


Looks like the fix is to use assoc instead of memq.

Cheers
Ralf
Details
Message ID
<87wmp5n0o8.fsf@posteo.net>
In-Reply-To
<FFC8A913-AEFA-4215-83CA-B8C4F8191013@systemexit.de> (view parent)
DKIM signature
pass
Download raw message
Ralf Schmitt <ralf@systemexit.de> writes:

> Hi Philip,
>
> Many thanks for your work on the setup.el . There seems to be a problem with the :package keyword.
> It uses (memq package package-archive-contents) to check whether to
> call package-refresh-contents. This always returns nil and the
> contents is refreshed for every package being installed.
>
> I’ve tested it on emacs 29.3:
>
> *** Welcome to IELM ***  Type (describe-mode) or press C-h m for help.
> ELISP> (package-refresh-contents)
> nil
> ELISP> (memq 'setup package-archive-contents)
> nil
> ELISP> (assoc 'setup package-archive-contents)
> (setup #s(package-desc :name setup :version
> 			(1 3 2)
> 			:summary "Helpful Configuration Macro" :reqs
> 			((emacs
> 			  (26 1)))
> 			:kind tar :archive "gnu" :dir nil :extras
> 			((:url . "https://git.sr.ht/~pkal/setup")
> 			 (:keywords "lisp" "local")
> 			 (:maintainer "Philip Kaludercic" . "~pkal/public-inbox@lists.sr.ht")
> 			 (:authors
> 			   ("Philip Kaludercic" . "philipk@posteo.net"))
> 			 (:commit . "28926bd11eef6118f4e169d10c1c36b8c4e545ae"))
> 			:signed nil))
>
> ELISP> (emacs-version)
> "GNU Emacs 29.3 (build 1, aarch64-apple-darwin23.3.0, NS appkit-2487.40 Version 14.3.1 (Build 23D60))"
> ELISP> 
>
>
> Looks like the fix is to use assoc instead of memq.

That certainly makes sense, but I would just use `assq' instead of
`assoc' since it is more specific.  I'll push a commit and prepare a
new release of setup.el in the next few days.

Thanks you for noticing and your kind words!

> Cheers
> Ralf
>

-- 
	Philip Kaludercic on peregrine
Reply to thread Export thread (mbox)