emacs: update packages, disable web-mode's auto indentation
[~bandali/configs] / .emacs.d / init.el
index b8d4ccb..f2d78f8 100644 (file)
   (previous-line)
   (insert "\n\f\n;;; "))
 
+(defvar b/fill-column 47
+  "My custom `fill-column'.")
+
+(defconst b/asterism "* * *")
+
 (defun b/insert-asterism ()
+  "Insert a centred asterism."
   (interactive)
-  (insert "\n\n                                 * * *\n\n"))
+  (insert
+   (concat
+    "\n\n"
+    (make-string (floor (/ (- b/fill-column (length b/asterism)) 2))
+                 ?\s)
+    b/asterism
+    "\n\n")))
 
 (defun b/no-mouse-autoselect-window ()
   "Conveniently disable `focus-follows-mouse'.
@@ -543,12 +555,13 @@ For disabling the behaviour for certain buffers and/or modes."
  ;; for back and forward mouse keys
  ("<XF86Back>"     . previous-buffer)
  ("<mouse-8>"      . previous-buffer)
- ("<drag-mouse-8>" . previous-buffer)
;; ("<drag-mouse-8>" . previous-buffer)
  ("<XF86Forward>"  . next-buffer)
  ("<mouse-9>"      . next-buffer)
- ("<drag-mouse-9>" . next-buffer)
- ("<drag-mouse-2>" . kill-this-buffer)
- ("<drag-mouse-3>" . switch-to-buffer))
+ ;; ("<drag-mouse-9>" . next-buffer)
+ ;; ("<drag-mouse-2>" . kill-this-buffer)
+ ;; ("<drag-mouse-3>" . switch-to-buffer)
+ )
 
 (bind-keys
  :prefix-map b/straight-prefix-map
@@ -914,7 +927,7 @@ around if needed."
   :custom
   (magit-diff-refine-hunk t)
   (magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1)
-  (magit-completing-read-function 'magit-ido-completing-read)
+  ;; (magit-completing-read-function 'magit-ido-completing-read)
   :custom-face (magit-diff-file-heading ((t (:weight normal)))))
 
 ;; recently opened files
@@ -936,59 +949,61 @@ around if needed."
  ("C-c f r" . recentf-open-files)
  ("C-c x"   . execute-extended-command))
 
-(use-feature ido
-  :demand
-  :bind
-  (:map ido-common-completion-map
-        ([escape] . minibuffer-keyboard-quit)
-        ("DEL"    . b/ido-backspace))
-  :config
-  (require 'delsel)
-  (defun b/ido-backspace ()
-    "Forward to `backward-delete-char'.  On error (read-only), quit."
-    (interactive)
-    (condition-case nil
-        (backward-delete-char 1)
-      (error
-       (minibuffer-keyboard-quit))))
-  (ido-mode 1)
-  (ido-everywhere 1)
-  :custom
-  (ido-enable-flex-matching t)
-  (ido-max-window-height 10)
-  (ido-use-virtual-buffers t))
+(comment
+  (use-feature ido
+    :demand
+    :bind
+    (:map ido-common-completion-map
+          ([escape] . minibuffer-keyboard-quit)
+          ("DEL"    . b/ido-backspace))
+    :config
+    (require 'delsel)
+    (defun b/ido-backspace ()
+      "Forward to `backward-delete-char'.  On error (read-only), quit."
+      (interactive)
+      (condition-case nil
+          (backward-delete-char 1)
+        (error
+         (minibuffer-keyboard-quit))))
+    (ido-mode 1)
+    (ido-everywhere 1)
+    :custom
+    (ido-enable-flex-matching t)
+    ;; (ido-enable-regexp t)
+    ;; (ido-enable-prefix t)
+    (ido-max-window-height 10)
+    (ido-use-virtual-buffers t))
+
+  (use-package ido-vertical-mode
+    :defer 0.3
+    :config
+    (ido-vertical-mode 1)
+    :custom
+    (ido-vertical-define-keys 'C-n-C-p-up-and-down)
+    (ido-vertical-show-count t))
 
-(use-package ido-vertical-mode
-  :defer 0.3
-  :config
-  (ido-vertical-mode 1)
-  :custom
-  (ido-vertical-define-keys 'C-n-C-p-up-and-down)
-  (ido-vertical-show-count t))
+  (use-package ido-completing-read+
+    :defer 0.3
+    :after ido
+    :config
+    (ido-ubiquitous-mode 1))
 
-(use-package ido-completing-read+
-  :defer 0.3
-  :after ido
-  :config
-  (ido-ubiquitous-mode 1))
+  (use-package crm-custom
+    :defer 0.3
+    :config
+    (crm-custom-mode 1))
+
+  (use-feature icomplete
+    :defer 0.3
+    :config
+    (icomplete-mode 1)))
 
 (use-package amx
   :defer 0.3
   :config
   (amx-mode))
 
-(use-package crm-custom
-  :defer 0.3
-  :config
-  (crm-custom-mode 1))
-
-(use-feature icomplete
-  :defer 0.3
-  :config
-  (icomplete-mode 1))
-
 (use-package ivy
-  :disabled
   :defer 0.3
   :bind
   (:map ivy-minibuffer-map
@@ -998,7 +1013,7 @@ around if needed."
    ("DEL"    . ivy-backward-delete-char))
   :config
   (setq ivy-wrap t
-        ivy-height 14
+        ;; ivy-height 14
         ivy-use-virtual-buffers t
         ivy-virtual-abbreviate 'abbreviate
         ivy-count-format "%d/%d ")
@@ -1016,32 +1031,30 @@ This function is intended for use with `ivy-ignore-buffers'."
   (add-to-list 'ivy-ignore-buffers 'b/ivy-ignore-buffer-p)
 
   (ivy-mode 1)
-  ;; :custom-face
-  ;; (ivy-minibuffer-match-face-2 ((t (:background "#e99ce8" :weight semi-bold))))
-  ;; (ivy-minibuffer-match-face-3 ((t (:background "#bbbbff" :weight semi-bold))))
-  ;; (ivy-minibuffer-match-face-4 ((t (:background "#ffbbff" :weight semi-bold))))
-)
+  :custom-face
+  (ivy-minibuffer-match-face-1 ((t (:background "#eeeeee"))))
+  (ivy-minibuffer-match-face-2 ((t (:background "#e7e7e7" :weight bold))))
+  (ivy-minibuffer-match-face-3 ((t (:background "light goldenrod" :weight semi-bold))))
+  (ivy-minibuffer-match-face-4 ((t (:background "misty rose" :weight semi-bold))))
+  (ivy-current-match ((((class color) (background light))
+                       :background "#d7d7d7" :foreground "black")
+                      (((class color) (background dark))
+                       :background "#65a7e2" :foreground "black"))))
 
 (use-package swiper
-  :commands (swiper swiper-isearch)
-  :bind (;; ("C-s"   . swiper-isearch)
-         ;; ("C-r"   . swiper)
-         ("C-S-s" . swiper-isearch)))
+  :demand
+  :after ivy
+  :bind (("C-S-s" . swiper-isearch)))
 
 (use-package counsel
-  :commands (counsel-linux-app))
-  ;; :bind (([remap execute-extended-command] . counsel-M-x)
-  ;;        ([remap find-file]                . counsel-find-file)
-  ;;        ("C-c f ."                        . counsel-find-file)
-  ;;        ("C-c f l"                        . counsel-find-library)
-  ;;        ("C-c f r"                        . counsel-recentf)
-  ;;        ("C-c x"                          . counsel-M-x)
-  ;;        :map minibuffer-local-map
-  ;;        ("C-r" . counsel-minibuffer-history))
-  ;; :config
-  ;; (counsel-mode 1)
-  ;; (defalias 'locate #'counsel-locate)
-  ;; )
+  :demand
+  :after ivy
+  :bind (("C-c f r" . counsel-recentf)
+         :map minibuffer-local-map
+         ("C-r" . counsel-minibuffer-history))
+  :config
+  (counsel-mode 1)
+  (defalias 'locate #'counsel-locate))
 
 (comment
   (use-package helm
@@ -1086,7 +1099,8 @@ This function is intended for use with `ivy-ignore-buffers'."
                ("C-S-l" . b/eshell-clear)
                ("M-r"   . counsel-esh-history)
                ;; ([tab]   . company-complete)
-               ))
+               :map eshell-hist-mode-map
+               ("M-r" . counsel-esh-history)))
 
   :hook (eshell-mode . b/eshell-setup)
   :custom
@@ -1312,7 +1326,8 @@ This function is intended for use with `ivy-ignore-buffers'."
 
 (use-feature text-mode
   :bind (:map text-mode-map ("C-*" . b/insert-asterism))
-  :hook (text-mode . indicate-buffer-boundaries-left))
+  :hook ((text-mode . indicate-buffer-boundaries-left)
+         (text-mode . flyspell-mode)))
 
 (use-feature conf-mode
   :mode "\\.*rc$")
@@ -1324,7 +1339,9 @@ This function is intended for use with `ivy-ignore-buffers'."
   :bind
   (:map company-active-map
         ([tab]    . company-complete-common-or-cycle)
-        ([escape] . company-abort))
+        ([escape] . company-abort)
+        ("C-p"    . company-select-previous-or-abort)
+        ("C-n"    . company-select-next-or-abort))
   :custom
   (company-minimum-prefix-length 1)
   (company-selection-wrap-around t)
@@ -1458,7 +1475,9 @@ This function is intended for use with `ivy-ignore-buffers'."
   (b/setq-every 2
     web-mode-code-indent-offset
     web-mode-css-indent-offset
-    web-mode-markup-indent-offset))
+    web-mode-markup-indent-offset)
+  :custom
+  (web-mode-enable-auto-indentation nil))
 
 (use-package emmet-mode
   :after (:any web-mode css-mode sgml-mode)
@@ -1672,10 +1691,10 @@ This function is intended for use with `ivy-ignore-buffers'."
     ;; prefixes for global prefixes and minor modes
     "C-c @"   "outline"
     "C-c !"   "flycheck"
-    "C-c 8"   "typo"
-    "C-c 8 -" "typo/dashes"
-    "C-c 8 <" "typo/left-brackets"
-    "C-c 8 >" "typo/right-brackets"
+    ;; "C-c 8"   "typo"
+    ;; "C-c 8 -" "typo/dashes"
+    ;; "C-c 8 <" "typo/left-brackets"
+    ;; "C-c 8 >" "typo/right-brackets"
     "C-x RET" "coding system"
     "C-x 8"   "unicode"
     "C-x @"   "event modifiers"
@@ -1733,7 +1752,7 @@ This function is intended for use with `ivy-ignore-buffers'."
 (use-package crux            ; results in Waiting for git... [2 times]
   :defer 0.4
   :bind (("C-c d"   . crux-duplicate-current-line-or-region)
-         ("C-c D"   . crux-duplicate-and-comment-current-line-or-region)
+         ("C-c M-d" . crux-duplicate-and-comment-current-line-or-region)
          ("C-c f C" . crux-copy-file-preserve-attributes)
          ("C-c f D" . crux-delete-file-and-buffer)
          ("C-c f R" . crux-rename-file-and-buffer)
@@ -1774,7 +1793,7 @@ This function is intended for use with `ivy-ignore-buffers'."
        (advice-add 'magit-branch-and-checkout
                    :after #'my-projectile-invalidate-cache)))
   :custom
-  ;; (projectile-completion-system 'ivy)
+  (projectile-completion-system 'ivy)
   (projectile-mode-line-prefix " proj"))
 
 (use-package helpful
@@ -1830,12 +1849,19 @@ This function is intended for use with `ivy-ignore-buffers'."
 
 ;; easily type pretty quotes & other typography, like ‘’“”-–—«»‹›
 (use-package typo
+  :disabled
   :defer 0.5
   :config
   (typo-global-mode 1)
   :hook (((text-mode erc-mode web-mode) . typo-mode)
          (tex-mode                      . (lambda ()(typo-mode -1)))))
 
+(use-feature electric
+  :disabled
+  :demand
+  :config
+  (electric-quote-mode))
+
 ;; highlight TODOs in buffers
 (use-package hl-todo
   :defer 0.5
@@ -1964,7 +1990,24 @@ This function is intended for use with `ivy-ignore-buffers'."
   :straight (debbugs
              :host github
              :repo "emacs-straight/debbugs"
-             :files (:defaults "Debbugs.wsdl")))
+             :files (:defaults "Debbugs.wsdl"))
+  :bind
+  (("C-c D d" . debbugs-gnu)
+   ("C-c D e" .
+    (lambda ()
+      (interactive)
+      (setq debbugs-gnu-current-suppress t)
+      (debbugs-gnu debbugs-gnu-default-severities '("emacs"))))
+   ("C-c D g" .
+    (lambda ()
+      (interactive)
+      (setq debbugs-gnu-current-suppress t)
+      (debbugs-gnu debbugs-gnu-default-severities '("gnuzilla"))))
+   ("C-c D G" .
+    (lambda ()
+      (interactive)
+      (setq debbugs-gnu-current-suppress t)
+      (debbugs-gnu debbugs-gnu-default-severities '("guix"))))))
 
 (use-package org-ref
   :init
@@ -2112,6 +2155,12 @@ This function is intended for use with `ivy-ignore-buffers'."
   :custom
   (debpaste-paste-is-hidden t))
 
+(use-package scpaste
+  :disabled
+  :config
+  (setq scpaste-http-destination "https://p.bndl.org"
+        scpaste-scp-destination "nix:/var/www/p.bndl.org"))
+
 \f
 ;;; Email (with Gnus)
 
@@ -2152,6 +2201,8 @@ This function is intended for use with `ivy-ignore-buffers'."
                                   ;; (: gnus-group-split-fancy "INBOX" t "INBOX")
                                   ;; gnu
                                   (list ".*<\\(.*\\)\\.\\(non\\)?gnu\\.org>.*" "l.\\1")
+                                  ;; gnus
+                                  (list ".*<\\(.*\\)\\.gnus\\.org>.*" "l.\\1")
                                   ;; *.lists.sr.ht, omitting one dot if present
                                   ;;    add more \\.?\\([^.]*\\) if needed
                                   (list ".*<~\\(.*\\)/\\([^.]*\\)\\.?\\([^.]*\\)\\.lists.sr.ht>.*" "l.~\\1.\\2\\3")
@@ -2324,7 +2375,7 @@ This function is intended for use with `ivy-ignore-buffers'."
       (to-list    . "webmasters@gnu.org"))
      ("gnu.*"
       (gcc-self . t))
-     ("gnu\\."
+     ("l\\."
       (subscribed . t))
      ("nnimap\\+uw:.*"
       (gcc-self . t)))
@@ -2458,8 +2509,9 @@ https://csclub.uwaterloo.ca/~abandali")
            (address "bandali@csclub.uwaterloo.ca")
            (signature b/csc-signature)
            (gcc "nnimap+csc:Sent"))))
-  ;; :hook (gnus-message-setup . mml-secure-message-sign)
-  )
+  :hook (gnus-message-setup . (lambda ()
+                                (unless (mml-secure-is-encrypted-p)
+                                  (mml-secure-message-sign)))))
 
 (use-feature gnus-topic
   :hook (gnus-group-mode . gnus-topic-mode)
@@ -2485,9 +2537,10 @@ https://csclub.uwaterloo.ca/~abandali")
   :init
   (add-hook 'dired-mode-hook 'gnus-dired-mode))
 
-(use-feature gnus-utils
-  :custom
-  (gnus-completing-read-function 'gnus-ido-completing-read))
+(comment
+  (use-feature gnus-utils
+    :custom
+    (gnus-completing-read-function 'gnus-ido-completing-read)))
 
 (use-feature mm-decode
   :config
@@ -2545,8 +2598,8 @@ https://csclub.uwaterloo.ca/~abandali")
   :hook (;; (message-setup . mml-secure-message-sign-pgpmime)
          (message-mode . flyspell-mode)
          (message-mode . (lambda ()
-                           ;; (setq fill-column 65
-                           ;;       message-fill-column 65)
+                           (setq-local fill-column b/fill-column
+                                       message-fill-column b/fill-column)
                            (make-local-variable 'company-idle-delay)
                            (setq company-idle-delay 0.2))))
   ;; :custom-face
@@ -2581,6 +2634,17 @@ https://csclub.uwaterloo.ca/~abandali")
         ("r" . footnote-renumber-footnotes)
         ("s" . footnote-set-style)))
 
+(use-package bbdb
+  :disabled
+  :demand
+  :after gnus
+  :bind (:map gnus-group-mode-map ("e" . bbdb))
+  :config
+  (bbdb-initialize 'gnus 'message)
+  :custom
+  (bbdb-complete-mail-allow-cycling t)
+  (bbdb-user-mail-address-re message-dont-reply-to-names))
+
 (use-package ebdb
   :demand
   :after gnus
@@ -2697,7 +2761,7 @@ https://csclub.uwaterloo.ca/~abandali")
 (use-feature erc-pcomplete
   :after erc
   :custom
-  (erc-pcomplete-nick-postfix ","))
+  (erc-pcomplete-nick-postfix ", "))
 
 (use-feature erc-track
   :after erc