 
 (use-package elisp-mode
   :defer t
-  :config (progn (add-hook 'emacs-lisp-mode-hook #'lispy-mode)
-
-                 (defun db/add-use-package-to-imenu ()
-                   (add-to-list 'imenu-generic-expression
-                                '("Used Packages"
-                                  "\\(^\\s-*(use-package +\\)\\(\\_<.+\\_>\\)"
-                                  2)))
-                 (add-hook 'emacs-lisp-mode-hook #'db/add-use-package-to-imenu)
-
-                 (add-hook 'ielm-mode-hook #'eldoc-mode)
-                 (add-hook 'emacs-lisp-mode-hook #'eldoc-mode)))
+  :config (progn
+            (add-hook 'emacs-lisp-mode-hook #'lispy-mode)
+            (add-hook 'emacs-lisp-mode-hook #'db/add-use-package-to-imenu)
+            (add-hook 'ielm-mode-hook #'eldoc-mode)
+            (add-hook 'emacs-lisp-mode-hook #'eldoc-mode)))
+
+(defun db/add-use-package-to-imenu ()
+  "Add `use-package’ statements to `imenu-generic-expression."
+  (add-to-list 'imenu-generic-expression
+               '("Used Packages"
+                 "\\(^\\s-*(use-package +\\)\\(\\_<.+\\_>\\)"
+                 2)))
 
 (use-package geiser
   :commands (geiser-mode))

            (when on-windows
              (setq ls-lisp-use-insert-directory-program t))
            (dired-quick-sort-setup)

            (defun dired-back-to-top ()
              "Jump to first non-trivial line in dired."
              (interactive)
              (goto-char (point-min))
              (dired-next-line 2))

            (defun dired-jump-to-bottom ()
              "Jump to last non-trivial line in dired."
              (interactive)
              (goto-char (point-max))
              (dired-next-line -1))

            (defun dired-get-size ()    ; from emacswiki, via oremacs
              "print size of all files marked in the current dired buffer."
              (interactive)
              (let ((files (dired-get-marked-files)))
                (with-temp-buffer
                  (apply 'call-process "/usr/bin/du" nil t nil "-sch" files)
                  (message
                   "size of all marked files: %s"
                   (progn
                     (re-search-backward "\\(^[0-9.,]+[a-za-z]+\\).*total$")
                     (match-string 1))))))

            (bind-key [remap beginning-of-buffer]
                      #'dired-back-to-top dired-mode-map)

            (setq network-security-level 'high
                  nsm-save-host-names t)

            (advice-add 'nsm-write-settings
                        :before #'db/sort-nsm-permanent-settings)))

(defun db/sort-nsm-permanent-settings ()
  "Sort values in `nsm-permanent-host-settings’."
  (setq nsm-permanent-host-settings
        (cl-sort nsm-permanent-host-settings
                 #'string<
                 :key #'second)))

(use-package gnutls
  :defer t
  :config (progn
            (setq gnutls-log-level 0    ; too noisy otherwise
                  gnutls-min-prime-bits 1024
                  gnutls-verify-error t)))

(defun db/update-cert-file-directory (symbol new-value)
  "Set SYMBOL to NEW-VALUE and add all certificate in it to `gnutls-trustfiles’.

Assumes that NEW-VALUE points to a directory, and certificates
are assumed to be of the form *.crt."
  (set symbol new-value)
  (when (file-directory-p new-value)
    (dolist (cert-file (directory-files new-value t ".crt$"))
      (add-to-list 'gnutls-trustfiles cert-file))))

(defcustom db/cert-file-directory "~/.local/etc/certs/"
  "Local directory with additional certificates."
  :group 'personal-settings
  :type 'string
  :set #'db/update-cert-file-directory)

(use-package epg
  :defer t
