summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Abrahamsen <eric@ericabrahamsen.net>2022-01-12 14:58:46 -0800
committerEric Abrahamsen <eric@ericabrahamsen.net>2022-01-12 14:58:46 -0800
commit097e0ee4a20f09d7d1262ddb56ca1a0e5ed1e156 (patch)
tree47da784df7b06d55c82b214f207ba90eeef72705
parent917a623a9dd21bc1d73fd13d91de57d924ce2692 (diff)
downloademacs-097e0ee4a20f09d7d1262ddb56ca1a0e5ed1e156.tar.gz
Rework setting/unsetting of gnus-registry-enabled
The basic idea is, we're moving the setting/unsetting of `gnus-registry-enabled' so that it is a more reliable indicator of whether the registry is actually available or not. * lisp/gnus/gnus-registry.el (gnus-registry-load): Move the setting of `gnus-registry-enabled' here, after we're sure the registry actually has been loaded. (gnus-registry-initialize): Move it out of here. All this function does is conditionally call `gnus-registry-load'. (gnus-registry-register-message-ids): Only check `gnus-registry-enabled', since we'd more confident about this now. Sort checks in order of increasing complexity. (gnus-registry-clear): Unset `gnus-registry-enabled'. (gnus-registry-install-hooks): This function should only install hooks, not set variables. (gnus-registry-unload-hook): Change the unload hook to call `gnus-registry-clear', as that will do all the necessary work (including calling `gnus-registry-unload-hook')
-rw-r--r--lisp/gnus/gnus-registry.el25
1 files changed, 13 insertions, 12 deletions
diff --git a/lisp/gnus/gnus-registry.el b/lisp/gnus/gnus-registry.el
index 0c281a997f8..edeacbc919e 100644
--- a/lisp/gnus/gnus-registry.el
+++ b/lisp/gnus/gnus-registry.el
@@ -355,8 +355,13 @@ This is not required after changing `gnus-registry-cache-file'."
"Load the registry from the cache file."
(interactive)
(let ((file gnus-registry-cache-file))
+ (gnus-message 5 "Initializing the registry")
(condition-case nil
- (gnus-registry-read file)
+ (progn
+ (gnus-registry-read file)
+ (gnus-registry-install-hooks)
+ (gnus-registry-install-shortcuts)
+ (setq gnus-registry-enabled t))
(file-error
;; Fix previous mis-naming of the registry file.
(let ((old-file-name
@@ -846,9 +851,9 @@ Overrides existing keywords with FORCE set non-nil."
(defun gnus-registry-register-message-ids ()
"Register the Message-ID of every article in the group."
- (unless (or (gnus-parameter-registry-ignore gnus-newsgroup-name)
- (null gnus-registry-register-all)
- (null (eieio-object-p gnus-registry-db)))
+ (unless (or (null gnus-registry-enabled)
+ (null gnus-registry-register-all)
+ (gnus-parameter-registry-ignore gnus-newsgroup-name))
(dolist (article gnus-newsgroup-articles)
(let* ((id (gnus-registry-fetch-message-id-fast article))
(groups (gnus-registry-get-id-key id 'group)))
@@ -1175,7 +1180,8 @@ non-nil."
(defun gnus-registry-clear ()
"Clear the registry."
(gnus-registry-unload-hook)
- (setq gnus-registry-db nil))
+ (setq gnus-registry-db nil
+ gnus-registry-enabled nil))
(gnus-add-shutdown 'gnus-registry-clear 'gnus)
@@ -1183,16 +1189,12 @@ non-nil."
(defun 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)))
(defun gnus-registry-install-hooks ()
"Install the registry hooks."
- (setq gnus-registry-enabled t)
(add-hook 'gnus-summary-article-move-hook #'gnus-registry-action)
(add-hook 'gnus-summary-article-delete-hook #'gnus-registry-action)
(add-hook 'gnus-summary-article-expire-hook #'gnus-registry-action)
@@ -1212,10 +1214,9 @@ non-nil."
(remove-hook 'gnus-save-newsrc-hook #'gnus-registry-save)
(remove-hook 'gnus-read-newsrc-el-hook #'gnus-registry-load)
- (remove-hook 'gnus-summary-prepare-hook #'gnus-registry-register-message-ids)
- (setq gnus-registry-enabled nil))
+ (remove-hook 'gnus-summary-prepare-hook #'gnus-registry-register-message-ids))
-(add-hook 'gnus-registry-unload-hook #'gnus-registry-unload-hook)
+(add-hook 'gnus-registry-unload-hook #'gnus-registry-clear)
(defun gnus-registry-install-p ()
"Return non-nil if the registry is enabled (and maybe enable it first).