             (advice-add 'mml-attach-file
                         :around #'db/mml-attach-file--go-to-eob)))
 
-(setq notmuch-fcc-dirs nil
-      message-send-mail-function #'db/smtpmail-send-it
+(use-package mm-encode
+  :init (setq mm-encrypt-option nil
+              mm-sign-option nil))
+
+(setq mml-smime-use 'epg
+      ;;mml2015-encrypt-to-self t
+      mml2015-display-key-image nil
+      gnus-message-replysign t
+      gnus-message-replyencrypt t
+      gnus-message-replysignencrypted t
+      mml-secure-cache-passphrase nil
+      mml-secure-openpgp-sign-with-sender t
+      mml-secure-smime-sign-with-sender t)
+
+;; Archiving
+
+;; We store messages in the current group, so there is
+;; no need to use Gnus’ archiving method
+
+(setq gnus-message-archive-method nil
+      gnus-update-message-archive-method t
+      gnus-message-archive-group nil
+      gnus-gcc-mark-as-read t)
+
+;; Searching
+
+(setq nnir-method-default-engines '((nnimap . imap)
+                                    (nnmaildir . notmuch)
+                                    (nntp . gmane)))
+
+;; Agents
+
+(setq gnus-agent-mark-unread-after-downloaded nil
+      gnus-agent-synchronize-flags t
+      gnus-agent-go-online t)
+
+;; Package configuration
+
+(use-package gnus
+  :commands (gnus)
+  :config (progn
+            (require 'db-mail)
+
+            (with-demoted-errors "Setting up BBDB failed: %s"
+              (bbdb-initialize 'gnus 'message)
+              (bbdb-mua-auto-update-init 'message))
+
+            ;; Ensure that whenever we compose new mail, it will use the correct
+            ;; posting style.  This is ensured by setting ARG of
+            ;; `gnus-group-mail’ to 1 to let it query the user for a group.
+            (defadvice gnus-group-mail (before inhibit-no-argument activate)
+              (unless (ad-get-arg 0)
+                (ad-set-arg 0 1)))
+
+            (remove-hook 'gnus-mark-article-hook
+                         'gnus-summary-mark-read-and-unread-as-read)
+            (add-hook 'gnus-mark-article-hook 'gnus-summary-mark-unread-as-read)
+
+            ;; Quit Gnus gracefully when exiting Emacs
+            (add-hook 'kill-emacs-hook #'(lambda ()
+                                           (interactive)
+                                           (when (get-buffer "*Group*")
+                                             (gnus-group-exit))))
+
+            ;; Don’t quit summary buffer when pressing `q’
+            (bind-key "q" #'gnus-summary-expand-window gnus-article-mode-map)
+
+            ;; Show topics in group buffer
+            (add-hook 'gnus-group-mode-hook 'gnus-topic-mode)
+
+            ;; We need to do some magic as otherwise the agent does not delete
+            ;; articles from its .overview when we move them around.  Thus we
+            ;; mark articles as expireable when they have been moved to another
+            ;; group.
+            (defadvice gnus-summary-move-article (around
+                                                  no-cancel-mark
+                                                  (&optional n to-newsgroup
+                                                             select-method action)
+                                                  activate)
+              (let ((articles (gnus-summary-work-articles n))
+                    (return   ad-do-it))
+                (when (or (null action)
+                          (eq action 'move))
+                  (dolist (article articles)
+                    (gnus-summary-mark-article article gnus-expirable-mark)))
+                return))
+
+            ;; Increase score of group after reading it
+            (add-hook 'gnus-summary-exit-hook
+                      'gnus-summary-bubble-group)
+
+            ;; Use Gnus’ registry; doing this too early conflicts with `gnus'
+            ;; calling `gnus-shutdown', which in turn calls
+            ;; `gnus-registry-clear', leaving us with an empty registry upon
+            ;; startup.  So let's call this initialization right after startup,
+            ;; that should be fine.
+            (add-hook 'gnus-started-hook
+                      #'gnus-registry-initialize)
+
+            ;; Automatic encryption if all necessary keys are present
+            (add-hook 'gnus-message-setup-hook
+                      #'db/signencrypt-message-when-possible)
+
+            ;; Do some pretty printing before saving the newsrc file
+            (add-hook 'gnus-save-quick-newsrc-hook
+                      #'db/gnus-save-newsrc-with-whitespace-1)
+
+            ;; Automatically scan for new news
+            (gnus-demon-add-handler 'db/gnus-demon-scan-news-on-level-2 5 5)
+
+            (add-hook 'gnus-started-hook #'gnus-demon-init)
+
+            ;; Visit group under point and immediately close it; this updates
+            ;; gnus’ registry as a side-effect
+            (bind-key "v u"
+                      '(lambda ()
+                         (interactive)
+                         (save-mark-and-excursion
+                           (when (gnus-topic-select-group)
+                             (gnus-summary-exit))))
+                      gnus-group-mode-map)
+
+            ;; Toggle visibility of News group
+            (bind-key "v c"
+                      (lambda ()
+                        (interactive)
+                        (save-mark-and-excursion
+                          (gnus-topic-jump-to-topic "News")
+                          (gnus-topic-read-group)))
+                      gnus-group-mode-map)
+
+            (bind-key "C-<return>" #'db/gnus-summary-open-Link gnus-summary-mode-map)
+            (bind-key "C-<return>" #'db/gnus-summary-open-Link gnus-article-mode-map)))
+
+
+;; Sending mail
+
+(setq message-send-mail-function #'db/smtpmail-send-it
       send-mail-function #'db/smtpmail-send-it
       mail-user-agent 'gnus-user-agent)
 

      gnus-treat-emphasize 'head
      gnus-treat-unsplit-urls t)

;; Adaptive Scoring

(setq gnus-use-scoring t

                (replace-match "\n"))
              t)))

(setq message-forward-as-mime t)

;; MIME creation; signing, and encryption

(use-package mml
  :config (progn
            ;; Move to end of message buffer before attaching a file
