diff options
| author | Eric Abrahamsen | 2019-12-03 09:12:44 +0000 |
|---|---|---|
| committer | Eric Abrahamsen | 2019-12-08 12:25:33 -0800 |
| commit | 37d801a19aa0d49312445ec0f2b21f8f44a37bb7 (patch) | |
| tree | bc3907bfdfefa7ffaa8bf863c85b0486366dd418 | |
| parent | f93a604ff15c18c75563622a300cfa82647a86bf (diff) | |
| download | emacs-37d801a19aa0d49312445ec0f2b21f8f44a37bb7.tar.gz emacs-37d801a19aa0d49312445ec0f2b21f8f44a37bb7.zip | |
Continued fixes to gnus registry loading
* lisp/gnus/gnus-registry.el (gnus-registry-db): Do not initialize
this variable to an empty database, that should only be done for new
databases.
(gnus-registry-load): Remove "force" argument, don't check if the
database is already loaded, as we're only going to load it once.
(gnus-registry-initialize): Either load the db directly, or set up a
hook to do it later.
(gnus-registry-install-hooks): Don't load on
gnus-read-newsrc-el-hook.
| -rw-r--r-- | lisp/gnus/gnus-registry.el | 70 |
1 files changed, 30 insertions, 40 deletions
diff --git a/lisp/gnus/gnus-registry.el b/lisp/gnus/gnus-registry.el index e6fb382c2f9..ff4c640c82f 100644 --- a/lisp/gnus/gnus-registry.el +++ b/lisp/gnus/gnus-registry.el | |||
| @@ -340,7 +340,7 @@ Encode names if ENCODE is non-nil, otherwise decode." | |||
| 340 | :precious nil | 340 | :precious nil |
| 341 | :tracked nil))) | 341 | :tracked nil))) |
| 342 | 342 | ||
| 343 | (defvar gnus-registry-db (gnus-registry-make-db) | 343 | (defvar gnus-registry-db nil |
| 344 | "The article registry by Message ID. See `registry-db'.") | 344 | "The article registry by Message ID. See `registry-db'.") |
| 345 | 345 | ||
| 346 | ;; top-level registry data management | 346 | ;; top-level registry data management |
| @@ -352,40 +352,33 @@ This is not required after changing `gnus-registry-cache-file'." | |||
| 352 | (gnus-message 4 "Remaking the Gnus registry") | 352 | (gnus-message 4 "Remaking the Gnus registry") |
| 353 | (setq gnus-registry-db (gnus-registry-make-db)))) | 353 | (setq gnus-registry-db (gnus-registry-make-db)))) |
| 354 | 354 | ||
| 355 | (defun gnus-registry-load (&optional force) | 355 | (defun gnus-registry-load () |
| 356 | "Load the registry from the cache file. | 356 | "Load the registry from the cache file." |
| 357 | If the registry is already loaded, don't reload unless FORCE is | ||
| 358 | non-nil." | ||
| 359 | (interactive) | 357 | (interactive) |
| 360 | (when (or force | 358 | (let ((file gnus-registry-cache-file)) |
| 361 | ;; The registry is loaded by both | 359 | (condition-case nil |
| 362 | ;; `gnus-registry-initialize' and the read-newsrc hook. | 360 | (gnus-registry-read file) |
| 363 | ;; Don't load twice. | 361 | (file-error |
| 364 | (null (eieio-object-p gnus-registry-db))) | 362 | ;; Fix previous mis-naming of the registry file. |
| 365 | (let ((file gnus-registry-cache-file)) | 363 | (let ((old-file-name |
| 366 | (condition-case nil | 364 | (concat (file-name-sans-extension |
| 367 | (gnus-registry-read file) | 365 | gnus-registry-cache-file) |
| 368 | (file-error | 366 | ".eioio"))) |
| 369 | ;; Fix previous mis-naming of the registry file. | 367 | (if (and (file-exists-p old-file-name) |
| 370 | (let ((old-file-name | 368 | (yes-or-no-p |
| 371 | (concat (file-name-sans-extension | 369 | (format "Rename registry file from %s to %s? " |
| 372 | gnus-registry-cache-file) | 370 | old-file-name file))) |
| 373 | ".eioio"))) | 371 | (progn |
| 374 | (if (and (file-exists-p old-file-name) | 372 | (gnus-registry-read old-file-name) |
| 375 | (yes-or-no-p | 373 | (setf (oref gnus-registry-db file) file) |
| 376 | (format "Rename registry file from %s to %s? " | 374 | (gnus-message 1 "Registry filename changed to %s" file)) |
| 377 | old-file-name file))) | 375 | (gnus-registry-remake-db t)))) |
| 378 | (progn | 376 | (error |
| 379 | (gnus-registry-read old-file-name) | 377 | (gnus-message |
| 380 | (setf (oref gnus-registry-db file) file) | 378 | 1 |
| 381 | (gnus-message 1 "Registry filename changed to %s" file)) | 379 | "The Gnus registry could not be loaded from %s, creating a new one" |
| 382 | (gnus-registry-remake-db t)))) | 380 | file) |
| 383 | (error | 381 | (gnus-registry-remake-db t))))) |
| 384 | (gnus-message | ||
| 385 | 1 | ||
| 386 | "The Gnus registry could not be loaded from %s, creating a new one" | ||
| 387 | file) | ||
| 388 | (gnus-registry-remake-db t)))))) | ||
| 389 | 382 | ||
| 390 | (defun gnus-registry-read (file) | 383 | (defun gnus-registry-read (file) |
| 391 | "Do the actual reading of the registry persistence file." | 384 | "Do the actual reading of the registry persistence file." |
| @@ -1178,13 +1171,12 @@ only the last one's marks are returned." | |||
| 1178 | (gnus-message 5 "Initializing the registry") | 1171 | (gnus-message 5 "Initializing the registry") |
| 1179 | (gnus-registry-install-hooks) | 1172 | (gnus-registry-install-hooks) |
| 1180 | (gnus-registry-install-shortcuts) | 1173 | (gnus-registry-install-shortcuts) |
| 1181 | (gnus-registry-load)) | 1174 | (if (gnus-alive-p) |
| 1175 | (gnus-registry-load) | ||
| 1176 | (add-hook 'gnus-read-newsrc-el-hook 'gnus-registry-load))) | ||
| 1182 | 1177 | ||
| 1183 | ;; FIXME: Why autoload this function? | ||
| 1184 | ;;;###autoload | ||
| 1185 | (defun gnus-registry-install-hooks () | 1178 | (defun gnus-registry-install-hooks () |
| 1186 | "Install the registry hooks." | 1179 | "Install the registry hooks." |
| 1187 | (interactive) | ||
| 1188 | (setq gnus-registry-enabled t) | 1180 | (setq gnus-registry-enabled t) |
| 1189 | (add-hook 'gnus-summary-article-move-hook 'gnus-registry-action) | 1181 | (add-hook 'gnus-summary-article-move-hook 'gnus-registry-action) |
| 1190 | (add-hook 'gnus-summary-article-delete-hook 'gnus-registry-action) | 1182 | (add-hook 'gnus-summary-article-delete-hook 'gnus-registry-action) |
| @@ -1192,13 +1184,11 @@ only the last one's marks are returned." | |||
| 1192 | (add-hook 'nnmail-spool-hook 'gnus-registry-spool-action) | 1184 | (add-hook 'nnmail-spool-hook 'gnus-registry-spool-action) |
| 1193 | 1185 | ||
| 1194 | (add-hook 'gnus-save-newsrc-hook 'gnus-registry-save) | 1186 | (add-hook 'gnus-save-newsrc-hook 'gnus-registry-save) |
| 1195 | (add-hook 'gnus-read-newsrc-el-hook 'gnus-registry-load) | ||
| 1196 | 1187 | ||
| 1197 | (add-hook 'gnus-summary-prepare-hook 'gnus-registry-register-message-ids)) | 1188 | (add-hook 'gnus-summary-prepare-hook 'gnus-registry-register-message-ids)) |
| 1198 | 1189 | ||
| 1199 | (defun gnus-registry-unload-hook () | 1190 | (defun gnus-registry-unload-hook () |
| 1200 | "Uninstall the registry hooks." | 1191 | "Uninstall the registry hooks." |
| 1201 | (interactive) | ||
| 1202 | (remove-hook 'gnus-summary-article-move-hook 'gnus-registry-action) | 1192 | (remove-hook 'gnus-summary-article-move-hook 'gnus-registry-action) |
| 1203 | (remove-hook 'gnus-summary-article-delete-hook 'gnus-registry-action) | 1193 | (remove-hook 'gnus-summary-article-delete-hook 'gnus-registry-action) |
| 1204 | (remove-hook 'gnus-summary-article-expire-hook 'gnus-registry-action) | 1194 | (remove-hook 'gnus-summary-article-expire-hook 'gnus-registry-action) |