Remove duplicate entries when setting Gnus' select methods

This commit is contained in:
Daniel - 2020-08-01 10:11:47 +02:00
parent 5707c9233e
commit bc3e2e875f
No known key found for this signature in database
GPG Key ID: 1C7071A75BB72D64
1 changed files with 23 additions and 19 deletions

View File

@ -91,10 +91,10 @@ ACCOUNT must be a valid element of `db/mail-accounts."
(defun db/-set-gnus-secondary-select-methods (other-gnus-accounts remote-mail-accounts)
"Set `gnus-secondary-select-methods from OTHER-GNUS-ACCOUNTS and REMOTE-MAIL-ACCOUNTS.
The values of the latter two variables are usually those of
`db/other-gnus-accounts and `db/mail-accounts."
;; XXX: this does not check whether accounts are added multiple times
(setq gnus-secondary-select-methods
(append other-gnus-accounts
`db/other-gnus-accounts and `db/mail-accounts. If multiple
accounts exist with the same (equalp) account name, only the
first will be added to `gnus-secondary-select-methods'."
(let ((select-methods (append other-gnus-accounts
;; Only add those remote accounts whose IMAP address is neither
;; `nil nor the empty string
(cl-remove-if #'null
@ -110,6 +110,10 @@ The values of the latter two variables are usually those of
(nnimap-inbox "INBOX")
(nnimap-fetch-partial-articles "text/")))))
remote-mail-accounts)))))
(setq gnus-secondary-select-methods
(cl-remove-duplicates select-methods
:key #'cl-second ; account name is second element
:test #'equalp))))
;; Let's make the byte-compiler happy
(defvar gnus-posting-styles)