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')
This commit is contained in:
parent
917a623a9d
commit
097e0ee4a2
1 changed files with 13 additions and 12 deletions
|
@ -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).
|
||||
|
|
Loading…
Add table
Reference in a new issue