Subject: Re: bug#45330: 28.0.50; debbugs-gnu: Can't select reports before having started Gnus

From: Eric Abrahamsen <[email-masked]>
Date: Thu, 23 Dec 2021 14:42:04 -0800

On 12/12/21 03:46 AM, Michael Heerdegen wrote:
> Eric Abrahamsen <[email-masked]> writes:
>
>> I can switch the test to be something more explicit, but how about --
>
> Please let's not forget about this again.
>
> What has yet to be done to fix this issue?

Okay, dang it, here we go. Having thought about it, it seems like the
solutions might be simpler than I thought. `gnus-registry-initialize'
looks like this:

(defun gnus-registry-initialize ()
  "Initialize the Gnus registry."
  (interactive)
  (gnus-message 5 "Initializing the registry")
  (gnus-registry-install-hooks) => sets gnus-registry-enabled = t
  (gnus-registry-install-shortcuts)
  (if (gnus-alive-p)
      (gnus-registry-load)
    (add-hook 'gnus-read-newsrc-el-hook #'gnus-registry-load)))

It makes no sense to set `gnus-registry-enabled' to t when we haven't
fully loaded the registry. How about we move
`gnus-registry-install-hooks' and `gnus-registry-install-shortcuts' into
`gnus-registry-load', after the actual loading, a la the attached patch?
Does this solve the problems you're seeing?

Eric

diff --git a/lisp/gnus/gnus-registry.el b/lisp/gnus/gnus-registry.el
index 163d543afd..feb39df925 100644
--- a/lisp/gnus/gnus-registry.el
+++ b/lisp/gnus/gnus-registry.el
@@ -356,7 +356,10 @@ gnus-registry-load
   (interactive)
   (let ((file gnus-registry-cache-file))
     (condition-case nil
-        (gnus-registry-read file)
+        (progn
+          (gnus-registry-read file)
+          (gnus-registry-install-hooks)
+          (gnus-registry-install-shortcuts))
       (file-error
        ;; Fix previous mis-naming of the registry file.
        (let ((old-file-name
@@ -1184,8 +1187,6 @@ gnus-registry-initialize
   "Initialize the Gnus registry."
   (interactive)
   (gnus-message 5 "Initializing the registry")
-  (gnus-registry-install-hooks)
-  (gnus-registry-install-shortcuts)
   (if (gnus-alive-p)
       (gnus-registry-load)
     (add-hook 'gnus-read-newsrc-el-hook #'gnus-registry-load)))