Only use Gnus registry for formatting when registry is loaded

See bug 

* lisp/gnus/gnus-registry.el (gnus-registry-article-marks-to-chars):
  (gnus-registry-article-marks-to-names): In some circumstances it's
  possible for the user's summary line format spec to include
  registry-specific code, while the registry itself isn't actually
  loaded. Make sure the database is actually a hashtable before
  accessing it.
This commit is contained in:
Eric Abrahamsen 2019-09-19 10:36:42 -07:00
parent 2b80340bf3
commit a81223aeaa

View file

@ -1007,23 +1007,27 @@ Uses `gnus-registry-marks' to find what shortcuts to install."
;; (defalias 'gnus-user-format-function-M 'gnus-registry-article-marks-to-chars) ;; (defalias 'gnus-user-format-function-M 'gnus-registry-article-marks-to-chars)
(defun gnus-registry-article-marks-to-chars (headers) (defun gnus-registry-article-marks-to-chars (headers)
"Show the marks for an article by the :char property." "Show the marks for an article by the :char property."
(let* ((id (mail-header-message-id headers)) (if (hash-table-p gnus-registry-db)
(marks (when id (gnus-registry-get-id-key id 'mark)))) (let* ((id (mail-header-message-id headers))
(concat (delq nil (marks (when id (gnus-registry-get-id-key id 'mark))))
(mapcar (concat (delq nil
(lambda (m) (mapcar
(plist-get (lambda (m)
(cdr-safe (assoc m gnus-registry-marks)) (plist-get
:char)) (cdr-safe (assoc m gnus-registry-marks))
marks))))) :char))
marks))))
""))
;; use like this: ;; use like this:
;; (defalias 'gnus-user-format-function-M 'gnus-registry-article-marks-to-names) ;; (defalias 'gnus-user-format-function-M 'gnus-registry-article-marks-to-names)
(defun gnus-registry-article-marks-to-names (headers) (defun gnus-registry-article-marks-to-names (headers)
"Show the marks for an article by name." "Show the marks for an article by name."
(let* ((id (mail-header-message-id headers)) (if (hash-table-p gnus-registry-db)
(marks (when id (gnus-registry-get-id-key id 'mark)))) (let* ((id (mail-header-message-id headers))
(mapconcat (lambda (mark) (symbol-name mark)) marks ","))) (marks (when id (gnus-registry-get-id-key id 'mark))))
(mapconcat (lambda (mark) (symbol-name mark)) marks ","))
""))
(defun gnus-registry-read-mark () (defun gnus-registry-read-mark ()
"Read a mark name from the user with completion." "Read a mark name from the user with completion."