Good question.  I think this is a non-bug for the package-list menu.  Launching the menu indeed refreshes the package list every time, respecting the most recent package-archive values.

It was more that running package-upgrade after adding a package-archive didn't refresh the list, not knowing that key values had changed, invalidating the package cache.  From now on, I'll combine changes with either launching the menu or running package-refresh-contents manually.  This will likely never happen again, now that my configuration is where I want it to be.

Please close.

On Wed, Feb 26, 2025 at 11:46 AM Stefan Kangas <stefankangas@gmail.com> wrote:
Ship Mints <shipmints@gmail.com> writes:

> I noticed that I have to force a refresh via 'package-refresh-contents'
> after changing either 'package-archives' or 'package-pinned-packages' as
> 'package-menu--refresh' accounts only for changes to
> 'package--old-archive-priorities'.
>
> If agreed, I'd be happy to submit a patch so that package.el will honor
> changes to variables in between refreshes, and "invalidate" the implied
> cache.
>
> -Stephane

Do you have a recipe to reproduce it?