                  value))))
 
 (defcustom db/mail-accounts nil
-  "Configuration for email accounts.
+  "Configuration for remote email accounts.
 This is a list of lists, where each such list specifies necessary
-parameters for one particular email address."
+parameters for one particular email address.  These addresses
+will also be recognized when sending mail."
   :group 'personal-settings
   :type '(repeat
           (list

  (set-default symbol value)

  ;; Set `gnus-secondary-select-methods’
  (setq gnus-secondary-select-methods
        (append
         ;; immutable account definitions; TODO: move into customizable variable
         `((nntp "etsep"
                 (nntp-open-connection-function nntp-open-tls-stream)
                 (nntp-port-number 563)
                 (nntp-address "news.eternal-september.org"))
           (nntp "gmane"
                 (nntp-open-connection-function nntp-open-network-stream)
                 (nntp-address "news.gmane.org"))
           (nnimap "algebra20"
                   (nnimap-stream shell)
                   (nnimap-shell-program "/usr/lib/dovecot/imap -o mail_location=maildir:$HOME/Mail/algebra20")
                   (nnimap-split-methods nnimap-split-fancy)
                   (nnimap-inbox "INBOX")
                   (nnimap-split-fancy ,db/personal-gnus-filter-rules))
           (nnml "local"
                 (nnmail-split-methods nnmail-split-fancy)
                 (nnmail-split-fancy
                  (| ("subject" ".*Tiger Auditing Report for.*" "mail.tiger")
                     "mail.misc")))
           (nnmaildir "archive"
                      (directory "~/Mail/archive/")
                      (directory-files nnheader-directory-files-safe)
                      (nnir-search-engine notmuch)
                      (nnir-notmuch-remove-prefix ,(expand-file-name "~/Mail/archive/"))))

         ;; automatically add accounts when address is not nil and not the empty
         ;; string
         (remove-if #'null
                    (mapcar (lambda (account)
                              (let ((account-name (nth 1 account))
                                    (account-address (nth 2 account)))
                                (when (and account-address
                                           (stringp account-address)
                                           (< 0 (length account-address)))
                                  `(nnimap ,account-name
                                           (nnimap-address ,account-address)
                                           (nnimap-inbox "INBOX")))))
                            value))))

  ;; Set posting styles based on existing mail addresses
  (setq gnus-posting-styles

           (integer :tag "SMTP Service Port")
           (string :tag "SMTP Login Name")))
  :set #'db/mail-accounts--set-value)

(defun db/other-gnus-accounts--set-value (symbol value)
  "Set SYMBOL to VALUE as needed by `db/other-gnus-accounts’"
  (cl-assert (eq symbol 'db/other-gnus-accounts)
             "Only use `db/other-gnus-accounts--set-value’ only for setting `db/other-gnus-accounts’.")

  (set-default symbol value)
  (db/-set-gnus-secondary-select-methods
   value
   ;; Don’t complain if `db/mail-accounts’ is not defined yet.
   (and (boundp 'db/mail-accounts) db/mail-accounts)))

(defcustom db/other-gnus-accounts nil
  "Configuration for gnus accounts that are not IMAP/SMTP related.
The value of this variable should be a valid value for `gnus-secondary-select-methods’."
  :group 'personal-settings
  ;; type definition for `gnus-select-method’ widget from from gnus.el
  :type '(repeat gnus-select-method)
  :set #'db/other-gnus-accounts--set-value)


