Remove duplicate entries when setting Gnus' select methods
This commit is contained in:
parent
5707c9233e
commit
bc3e2e875f
|
@ -91,25 +91,29 @@ ACCOUNT must be a valid element of `db/mail-accounts’."
|
||||||
(defun db/-set-gnus-secondary-select-methods (other-gnus-accounts remote-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.
|
"Set `gnus-secondary-select-methods’ from OTHER-GNUS-ACCOUNTS and REMOTE-MAIL-ACCOUNTS.
|
||||||
The values of the latter two variables are usually those of
|
The values of the latter two variables are usually those of
|
||||||
`db/other-gnus-accounts’ and `db/mail-accounts’."
|
`db/other-gnus-accounts’ and `db/mail-accounts’. If multiple
|
||||||
;; XXX: this does not check whether accounts are added multiple times
|
accounts exist with the same (equalp) account name, only the
|
||||||
(setq gnus-secondary-select-methods
|
first will be added to `gnus-secondary-select-methods'."
|
||||||
(append other-gnus-accounts
|
(let ((select-methods (append other-gnus-accounts
|
||||||
;; Only add those remote accounts whose IMAP address is neither
|
;; Only add those remote accounts whose IMAP address is neither
|
||||||
;; `nil’ nor the empty string
|
;; `nil’ nor the empty string
|
||||||
(cl-remove-if #'null
|
(cl-remove-if #'null
|
||||||
(mapcar (lambda (account)
|
(mapcar (lambda (account)
|
||||||
(let ((account-name (db/mail-accounts--name account))
|
(let ((account-name (db/mail-accounts--name account))
|
||||||
(account-address (db/mail-accounts--imap-address account)))
|
(account-address (db/mail-accounts--imap-address account)))
|
||||||
(when (and account-address
|
(when (and account-address
|
||||||
(stringp account-address)
|
(stringp account-address)
|
||||||
(< 0 (length account-address)))
|
(< 0 (length account-address)))
|
||||||
`(nnimap ,account-name
|
`(nnimap ,account-name
|
||||||
(nnimap-address ,account-address)
|
(nnimap-address ,account-address)
|
||||||
(nnimap-stream starttls)
|
(nnimap-stream starttls)
|
||||||
(nnimap-inbox "INBOX")
|
(nnimap-inbox "INBOX")
|
||||||
(nnimap-fetch-partial-articles "text/")))))
|
(nnimap-fetch-partial-articles "text/")))))
|
||||||
remote-mail-accounts)))))
|
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
|
;; Let's make the byte-compiler happy
|
||||||
(defvar gnus-posting-styles)
|
(defvar gnus-posting-styles)
|
||||||
|
|
Loading…
Reference in New Issue