about summary refs log tree commit diff stats
path: root/.emacs.d/lisp
diff options
context:
space:
mode:
Diffstat (limited to '.emacs.d/lisp')
-rw-r--r--.emacs.d/lisp/init-clojure.el44
-rw-r--r--.emacs.d/lisp/init-completion.el182
-rw-r--r--.emacs.d/lisp/init-crux.el11
-rw-r--r--.emacs.d/lisp/init-dired.el5
-rw-r--r--.emacs.d/lisp/init-editor.el98
-rw-r--r--.emacs.d/lisp/init-emacs-lisp.el14
-rw-r--r--.emacs.d/lisp/init-git.el9
-rw-r--r--.emacs.d/lisp/init-kill.el1
-rw-r--r--.emacs.d/lisp/init-lsp.el34
-rw-r--r--.emacs.d/lisp/init-minibuffer.el257
-rw-r--r--.emacs.d/lisp/init-misc.el7
-rw-r--r--.emacs.d/lisp/init-navigation.el16
-rw-r--r--.emacs.d/lisp/init-packages.el78
-rw-r--r--.emacs.d/lisp/init-project.el9
-rw-r--r--.emacs.d/lisp/init-search.el156
-rw-r--r--.emacs.d/lisp/init-shell.el36
-rw-r--r--.emacs.d/lisp/init-sql.el5
-rw-r--r--.emacs.d/lisp/init-ui.el96
-rw-r--r--.emacs.d/lisp/init-windows.el24
19 files changed, 671 insertions, 411 deletions
diff --git a/.emacs.d/lisp/init-clojure.el b/.emacs.d/lisp/init-clojure.el
index 20394e3..7673565 100644
--- a/.emacs.d/lisp/init-clojure.el
+++ b/.emacs.d/lisp/init-clojure.el
@@ -28,7 +28,8 @@
       ("st" "#spy/t")))
 
   (defalias 'cape-clojure (cape-capf-super #'cider-complete-at-point
-                                           #'lsp-completion-at-point))
+                                           #'lsp-completion-at-point
+                                           #'cape-dabbrev))
   (defun set-clojure-capf ()
     (add-hook 'completion-at-point-functions #'cape-clojure -99 t))
 
@@ -101,14 +102,13 @@
   :init
   ;; Always show more of the path in clj buffer names.
   ;; Using setq-local in clojure-mode-hook is not enough, as it runs too late
-  (defun clj-uniquify-get-proposed-name (orig base dirname &optional depth original-dirname)
+  (defun clj-uniquify-get-proposed-name (orig base dirname &optional depth)
     (when (and (> (length base) 4)
                (string= ".clj" (substring base -4))
                (not (string= "project.clj" base)))
       (setq-local uniquify-min-dir-content 3))
-    (funcall orig base dirname depth original-dirname))
+    (funcall orig base dirname depth))
   (advice-add 'uniquify-get-proposed-name :around 'clj-uniquify-get-proposed-name)
-  :bind
   :hook
   (clojure-mode . clojure-mode-hook-fn))
 
@@ -152,10 +152,10 @@
     (cider-jack-in params))
   (defun load-debug-namespaces ()
     (interactive)
-    (cider-interactive-eval "(require 'snitch.core)" nil nil (cider--nrepl-pr-request-map))
-    (cider-interactive-eval "(require 'miracle.save)" nil nil (cider--nrepl-pr-request-map))
-    (cider-interactive-eval "(require 'sc.api)" nil nil (cider--nrepl-pr-request-map))
-    (cider-interactive-eval "(require '[debux.cs.core :refer [dbg dbgn dbgt]])" nil nil (cider--nrepl-pr-request-map)))
+    (cider-interactive-eval "(require 'snitch.core)" nil nil (cider--nrepl-pr-request-plist))
+    (cider-interactive-eval "(require 'miracle.save)" nil nil (cider--nrepl-pr-request-plist))
+    (cider-interactive-eval "(require 'sc.api)" nil nil (cider--nrepl-pr-request-plist))
+    (cider-interactive-eval "(require '[debux.cs.core :refer [dbg dbgn dbgt]])" nil nil (cider--nrepl-pr-request-plist)))
   (defun cider-toggle-boolean ()
     (interactive)
     (let ((opposite (pcase (cider-symbol-at-point)
@@ -196,12 +196,14 @@
         cider-connection-message-fn nil
         cider-show-error-buffer 'except-in-repl
         cider-test-fail-fast nil
+        cider-download-java-sources t
         clojure-toplevel-inside-comment-form t)
   (setq cider-clojure-compilation-error-phases nil)
   (setq-default cider-use-overlays t)
   (unbind-key "C-c C-l" cider-mode-map)
   (unbind-key "C-c C-b" cider-mode-map)
   (unbind-key "C-c C-b" cider-repl-mode-map)
+  (unbind-key "M-." cider-repl-mode-map)
 
   (defun fix-duplicate-windows ()
     "When all windows are the same, delete all of them except the current one."
@@ -209,20 +211,26 @@
       (delete-other-windows)))
   (advice-add #'cider-close-ancillary-buffers :after #'fix-duplicate-windows)
 
-  (defun switch-to-cider-repl ()
-    "Wrapper around `cider-switch-to-repl-buffer' with custom functionality."
-    (interactive)
-    (if (get-buffer-window (cider-current-repl))
-        (cider-switch-to-repl-buffer)
-      (cider-switch-to-repl-buffer)
-      (transpose-large-frame)))
   :bind
   (:map cider-mode-map
-        ("C-c C-z" . switch-to-cider-repl)
         ("C-c M-l" . cider-load-file)
-        ("C-c M-b" . cider-interrupt))
+        ("C-c M-b" . cider-interrupt)
+        ("C-c C-j C-;" . cider-pprint-eval-last-sexp-to-comment)
+        ("C-c C-M-p" . cider-pprint-eval-last-sexp-to-repl)
+        ("C-x M-i e" . cider-inspect-last-sexp)
+        ("C-x M-i f" . cider-inspect-defun-at-point)
+        ("C-x M-i l" . cider-inspect-last-result)
+        ("C-x M-i v" . cider-inspect-expr))
   (:map cider-repl-mode-map
-        ("C-c M-b" . cider-interrupt))
+        ("C-c M-b" . cider-interrupt)
+        ;; sp commands sometimes behave strangely in the cider repl buffer
+        ("M-d" . paredit-forward-kill-word)
+        ("M-DEL" . paredit-backward-kill-word)
+        ("C-k" . paredit-kill)
+        ("C-x M-i e" . cider-inspect-last-sexp)
+        ("C-x M-i f" . cider-inspect-defun-at-point)
+        ("C-x M-i l" . cider-inspect-last-result)
+        ("C-x M-i v" . cider-inspect-expr))
   (:map cider-start-map
         ("C-c C-M-j" . cider-jack-in-and-run-main))
   (:map clojure-mode-map
diff --git a/.emacs.d/lisp/init-completion.el b/.emacs.d/lisp/init-completion.el
index 27d4d19..16eca6b 100644
--- a/.emacs.d/lisp/init-completion.el
+++ b/.emacs.d/lisp/init-completion.el
@@ -4,72 +4,100 @@
 ;; Most of it is taken from the READMEs and wikis of those packages
 ;;; Code:
 
+(defun +elpaca-unload-dabbrev (e)
+  (and (featurep 'dabbrev) (unload-feature 'dabbrev t))
+  (elpaca--continue-build e))
+
+(defun +elpaca-dabbrev-build-steps ()
+  (append (butlast (if (file-exists-p (expand-file-name "dabbrev" elpaca-builds-directory))
+                       elpaca--pre-built-steps elpaca-build-steps))
+          (list '+elpaca-unload-dabbrev 'elpaca--activate-package)))
+
 (use-feature dabbrev
-  :diminish
   :custom
   (dabbrev-case-distinction nil)
   (dabbrev-case-fold-search t)
   (dabbrev-case-replace nil))
 
-(use-feature hippie-expand
+(use-package mono-complete
   :config
-  (setq hippie-expand-try-functions-list
-        '(;yas-hippie-try-expand
-          try-expand-dabbrev
-          try-expand-all-abbrevs
-          try-expand-dabbrev-all-buffers
-          try-expand-dabbrev-from-kill
-          try-complete-file-name-partially
-          try-complete-file-name
-          try-expand-list
-          try-expand-line
-          try-complete-lisp-symbol-partially
-          try-complete-lisp-symbol))
-  ;; https://www.emacswiki.org/emacs/HippieExpand#h5o-9
-  (defadvice he-substitute-string (after he-paredit-fix)
-    "Remove extra paren when expanding line in paredit."
-    (if (and (or smartparens-mode paredit-mode) (equal (substring str -1) ")"))
-        (progn (backward-delete-char 1) (forward-char))))
+  (setq mono-complete-preview-delay 0.15
+        mono-complete-backends '(dabbrev filesystem whole-line)
+        mono-complete-project-root 'persp-current-project-root)
+  (append-to-list* 'mono-complete-self-insert-commands 'sp-backward-delete-char 'sp-delete-char 'delete-indentation 'backward-delete-char 'delete-char)
+  (defun mono-complete-expand-or-complete ()
+    (interactive)
+    (if (eq 'mono-complete-expand-or-complete real-last-command)
+        (let ((corfu-preselect 'prompt))
+          (progn
+            (primitive-undo 2 buffer-undo-list)
+            (completion-at-point)))
+      (mono-complete-expand-or-fallback)))
+  :hook ((text-mode prog-mode) . mono-complete-mode)
   :bind
-  ("C-M-/" . hippie-expand))
+  (:map mono-complete-mode-map ("M-/" . mono-complete-expand-or-complete)))
 
-(use-package fancy-dabbrev
-  :diminish
-  :config
-  (global-fancy-dabbrev-mode)
-  (defun fancy-dabbrev-popup-advice (_next)
-    (local-set-key (kbd "C-M-/") #'fancy-dabbrev-backward))
-  (defun fancy-dabbrev-popup-exit-advice ()
-    (local-unset-key (kbd "C-M-/")))
-  (advice-add #'fancy-dabbrev--expand-again :before #'fancy-dabbrev-popup-advice)
-  (advice-add #'fancy-dabbrev--on-exit :after #'fancy-dabbrev-popup-exit-advice)
-  :bind ("M-/" . fancy-dabbrev-expand))
+(use-feature hippie-expand
+  :custom
+  (hippie-expand-try-functions-list '(try-expand-dabbrev
+                                      try-expand-all-abbrevs
+                                      try-expand-dabbrev-all-buffers
+                                      try-expand-dabbrev-from-kill
+                                      try-complete-file-name-partially
+                                      try-complete-file-name
+                                      try-expand-list
+                                      try-expand-line
+                                      try-complete-lisp-symbol-partially
+                                      try-complete-lisp-symbol))
+  :hook (elpaca-after-init . (lambda ()
+                               ;; Modified from https://www.emacswiki.org/emacs/HippieExpand#h5o-9
+                               (define-advice he-substitute-string (:after (str &optional trans-case) he-paredit-fix)
+                                 "Remove extra bracket when expanding line in paredit/smartparents mode."
+                                 (if (and (or smartparens-mode paredit-mode) (string-match "[]})]$" str))
+                                     (progn (backward-delete-char 1) (forward-char))))))
+  :bind
+  ("C-M-/" . hippie-expand))
 
 (use-feature emacs
   :config
-  (setq completion-cycle-threshold 3)
+  (setq completion-cycle-threshold 2)
   (setq tab-always-indent 'complete)
   (setq read-buffer-completion-ignore-case t
         read-file-name-completion-ignore-case t
         completion-ignore-case t))
 
 (use-package orderless
-  :defer 2
-  :bind (:map minibuffer-local-map
-              ("C-l" . my/orderless-match-components-literally))
+  :bind
+  (:map minibuffer-local-map
+        ("C-l" . orderless-toggle-literal-matching))
+  (:map corfu-map
+        ("C-l" . orderless-toggle-literal-matching))
   :custom
   (orderless-component-separator 'orderless-escapable-split-on-space)
   (completion-styles '(orderless partial-completion basic))
   (completion-category-defaults nil)
-  (completion-category-overrides '((file (styles . (partial-completion orderless)))))
   (orderless-matching-styles '(orderless-literal orderless-regexp orderless-strict-initialism))
-  (orderless-style-dispatchers '(+orderless-dispatch))
+  (orderless-style-dispatchers (list #'+orderless-consult-dispatch
+                                     #'orderless-affix-dispatch))
   :config
-  (defun my/orderless-match-components-literally ()
-    "Components match literally for the rest of the session."
+  ;; Inspired by https://github.com/oantolin/orderless/blob/ac4aeb66f331f4c4a430d5556071e33177304c37/README.org#interactively-changing-the-configuration
+  (defun orderless-toggle-literal-matching ()
+    "Toggle matching components literally for the rest of the session."
     (interactive)
-    (setq-local orderless-matching-styles '(orderless-literal)
-                orderless-style-dispatchers nil))
+    (if orderless-style-dispatchers
+        (progn
+          (setq-local +saved-orderless-matching-styles orderless-matching-styles
+                      +saved-orderless-style-dispatchers orderless-style-dispatchers)
+          (setq-local orderless-matching-styles '(orderless-literal)
+                      orderless-style-dispatchers nil))
+      (setq-local orderless-matching-styles +saved-orderless-matching-styles
+                  orderless-style-dispatchers +saved-orderless-style-dispatchers))
+    (when vertico--input
+      (setq vertico--input t)
+      (vertico--update))
+    (when corfu--input
+      (setq corfu--input t)
+      (corfu--update)))
 
   (defun orderless-strict-initialism (component &optional leading)
     "Match a component as a strict initialism.
@@ -88,68 +116,84 @@ candidate, in that order, at the beginning of words, with
 no words in between, beginning with the first word."
     (orderless-strict-initialism component t))
 
-  ;; based on https://github.com/minad/consult/wiki#minads-orderless-configuration
-  (defvar +orderless-dispatch-alist
-    '((?% . char-fold-to-regexp)
-      (?! . orderless-without-literal)
-      (?` . orderless-strict-leading-initialism)
-      (?= . orderless-literal)
-      (?_ . orderless-prefix)
-      (?~ . orderless-flex)))
+  ;; Replace initialism (,) with strict-leading-initialism, and also add strict initialism
+  (setf (alist-get ?, orderless-affix-dispatch-alist) #'orderless-strict-leading-initialism)
+  (add-to-list 'orderless-affix-dispatch-alist '(?` . orderless-strict-initialism) t)
 
-  (defun +orderless--suffix-regexp ()
+  ;; Copied from https://github.com/minad/consult/wiki#minads-orderless-configuration
+  (defun +orderless--consult-suffix ()
+    "Regexp which matches the end of string with Consult tofu support."
     (if (and (boundp 'consult--tofu-char) (boundp 'consult--tofu-range))
         (format "[%c-%c]*$"
                 consult--tofu-char
                 (+ consult--tofu-char consult--tofu-range -1))
       "$"))
 
+  ;; Copied from https://github.com/minad/consult/wiki#minads-orderless-configuration
   ;; Recognizes the following patterns:
-  ;; * ~flex flex~
-  ;; * =literal literal=
-  ;; * _prefix prefix_
-  ;; * %char-fold char-fold%
-  ;; * `strict-leading-initialism strict-leading-initialism`
-  ;; * !without-literal without-literal!
   ;; * .ext (file extension)
   ;; * regexp$ (regexp matching at end)
-  (defun +orderless-dispatch (word _index _total)
+  (defun +orderless-consult-dispatch (word _index _total)
     (cond
      ;; Ensure that $ works with Consult commands, which add disambiguation suffixes
      ((string-suffix-p "$" word)
-      `(orderless-regexp . ,(concat (substring word 0 -1) (+orderless--suffix-regexp))))
+      `(orderless-regexp . ,(concat (substring word 0 -1) (+orderless--consult-suffix))))
      ;; File extensions
      ((and (or minibuffer-completing-file-name
                (derived-mode-p 'eshell-mode))
            (string-match-p "\\`\\.." word))
-      `(orderless-regexp . ,(concat "\\." (substring word 1) (+orderless--suffix-regexp))))
-     ;; Ignore single !
-     ((equal "!" word) `(orderless-literal . ""))
-     ;; Prefix and suffix
-     ((if-let (x (assq (aref word 0) +orderless-dispatch-alist))
-          (cons (cdr x) (substring word 1))
-        (when-let (x (assq (aref word (1- (length word))) +orderless-dispatch-alist))
-          (cons (cdr x) (substring word 0 -1))))))))
+      `(orderless-regexp . ,(concat "\\." (substring word 1) (+orderless--consult-suffix))))))
+
+  ;; Based on https://github.com/minad/consult/wiki#minads-orderless-configuration
+  (orderless-define-completion-style +orderless-with-strict-leading-initialism
+    (orderless-matching-styles '(orderless-literal orderless-regexp orderless-strict-leading-initialism)))
+
+  (setopt completion-category-overrides '((file (styles partial-completion orderless))
+                                          (command (styles +orderless-with-strict-leading-initialism))
+                                          (variable (styles +orderless-with-strict-leading-initialism))
+                                          (symbol (styles +orderless-with-strict-leading-initialism)))))
 
 ;; code completion - corfu
 (use-package corfu
   :ensure (corfu :files (:defaults "extensions/*"))
   :custom
   (corfu-cycle t)
+  (corfu-preselect 'first)
   :bind (:map corfu-map
+              ("SPC" . corfu-insert)
               ("TAB" . corfu-next)
               ([tab] . corfu-next)
+              ("M-/" . corfu-next)
               ("S-TAB" . corfu-previous)
-              ([backtab] . corfu-previous))
+              ([backtab] . corfu-previous)
+              ("C-M-/" . corfu-previous))
   :hook (elpaca-after-init . global-corfu-mode))
 
 (use-extension corfu corfu-indexed
-  :config (corfu-indexed-mode 1))
+  :config
+  (defmacro define-corfu-complete (n)
+    `(defun ,(intern (format "corfu-indexed-complete-%s" n)) ()
+       ,(format "Complete with candidate %s." n)
+       (interactive)
+       (let ((corfu--index ,n))
+         (funcall-interactively 'corfu-complete))))
+  (defmacro define-corfu-insert (n)
+    `(defun ,(intern (format "corfu-indexed-insert-%s" n)) ()
+       ,(format "Insert candidate %s." n)
+       (interactive)
+       (let ((corfu--index ,n))
+         (funcall-interactively 'corfu-insert))))
+  (dotimes (n 10)
+    (eval `(define-corfu-complete ,n))
+    (eval `(define-corfu-insert ,n))
+    (define-key corfu-map (kbd (format "C-%s" n)) (intern (format "corfu-indexed-complete-%s" n)))
+    (define-key corfu-map (kbd (format "M-%s" n)) (intern (format "corfu-indexed-insert-%s" n))))
+  (corfu-indexed-mode 1))
 
 (use-extension corfu corfu-quick
   :bind (:map corfu-map
               ("M-;" . corfu-quick-insert)
-              ("M-'" . corfu-quick-exit)))
+              ("M-'" . corfu-quick-complete)))
 
 (use-extension corfu corfu-history
   :after savehist
diff --git a/.emacs.d/lisp/init-crux.el b/.emacs.d/lisp/init-crux.el
index 0739bd3..5f7b836 100644
--- a/.emacs.d/lisp/init-crux.el
+++ b/.emacs.d/lisp/init-crux.el
@@ -6,16 +6,6 @@
   :defer 5
   :commands crux-start-or-switch-to
   :config
-  (defmacro crux-with-region-or-sexp-or-line (func)
-    "When called with no active region, call FUNC on current sexp."
-    `(defadvice ,func (before with-region-or-sexp-or-line activate compile)
-       (interactive
-        (cond
-         (mark-active (list (region-beginning) (region-end)))
-         ((in-string-p) (flatten-list (bounds-of-thing-at-point 'string)))
-         ((thing-at-point 'list) (flatten-list (bounds-of-thing-at-point 'list)))
-         (t (list (line-beginning-position) (line-beginning-position 2)))))))
-
   (crux-with-region-or-sexp-or-line sp-kill-region)
   (crux-with-region-or-buffer shell-command-on-region)
   (crux-with-region-or-buffer indent-region)
@@ -25,6 +15,7 @@
   ("C-^" . crux-top-join-line)
   ("C-<backspace>" . crux-kill-line-backwards)
   ([remap kill-whole-line] . crux-kill-whole-line)
+  ([remap keyboard-quit] . crux-keyboard-quit-dwim)
   ;; TODO don't need all of these
   ("C-<return>" . crux-smart-open-line)
   ("S-<return>" . crux-smart-open-line)
diff --git a/.emacs.d/lisp/init-dired.el b/.emacs.d/lisp/init-dired.el
index 5ec6531..bd01329 100644
--- a/.emacs.d/lisp/init-dired.el
+++ b/.emacs.d/lisp/init-dired.el
@@ -13,6 +13,8 @@
   (dired-kill-when-opening-new-dired-buffer t)
   (wdired-use-dired-vertical-movement 'sometimes)
   (dired-vc-rename-file t)
+  (dired-clean-confirm-killing-deleted-buffers nil)
+  (dired-create-destination-dirs 'ask)
   :bind (:map dired-mode-map
               ("M-o" . dired-omit-mode)
               ("E" . wdired-change-to-wdired-mode)))
@@ -25,7 +27,8 @@
              ("i" . dired-subtree-insert)
              (";" . dired-subtree-remove)))
 
-(use-package casual-dired
+(use-feature casual-dired
+  :after dired
   :bind (:map dired-mode-map
               ("C-o" . casual-dired-tmenu)
               ("s" . casual-dired-sort-by-tmenu)))
diff --git a/.emacs.d/lisp/init-editor.el b/.emacs.d/lisp/init-editor.el
index 45a4b8e..fc575c4 100644
--- a/.emacs.d/lisp/init-editor.el
+++ b/.emacs.d/lisp/init-editor.el
@@ -33,14 +33,24 @@
   (setq comment-auto-fill-only-comments t)
   (setq large-file-warning-threshold 100000000)
   (setq create-lockfiles nil)
-  (setq global-auto-revert-non-file-buffers t)
-  (setq backup-by-copying t)
+  (setq global-auto-revert-non-file-buffers t
+        revert-without-query (list ".")
+        auto-revert-stop-on-user-input nil)
+  (setq backup-by-copying t
+        delete-old-versions t
+        version-control t
+        kept-new-versions 5
+        kept-old-versions 5)
   (setq backup-directory-alist
         `((".*" . ,temporary-file-directory))
         auto-save-file-name-transforms
-        `((".*" ,temporary-file-directory t)))
+        `((".*" ,temporary-file-directory t))
+        auto-save-include-big-deletions t)
+  (setq comment-multi-line t
+        comment-empty-lines t)
 
-  (setq save-place-file (expand-file-name "saveplace" save-dir))
+  (setq save-place-file (expand-file-name "saveplace" save-dir)
+        save-place-limit 800)
   ;; https://git.sr.ht/~technomancy/better-defaults/tree/master/item/better-defaults.el
   (setq save-interprogram-paste-before-kill t
         apropos-do-all t
@@ -50,11 +60,12 @@
   (setq ffap-machine-p-local 'accept
         ffap-machine-p-known 'reject
         ffap-machine-p-unkown 'reject)
-  ;; https://github.com/natecox/dotfiles/blob/master/workspaces/shared/symlinks/emacs/.emacs.d/nathancox.org
+
   (setq sentence-end-double-space nil)
-  (set-charset-priority 'unicode)
-  (setq locale-coding-system 'utf-8)
-  (setq default-process-coding-system '(utf-8-unix . utf-8-unix))
+  (set-language-environment "UTF-8")
+  ;; The previous line sets this to "rfc1345"
+  (setq default-input-method nil)
+
   (set-default 'imenu-auto-rescan t))
 
 (use-package move-text
@@ -72,6 +83,7 @@
   (savehist-additional-variables '(search-ring regexp-search-ring))
   (savehist-autosave-interval 60)
   (savehist-file (expand-file-name "savehist" save-dir))
+  (history-length 300)
   :hook (elpaca-after-init . savehist-mode))
 
 (use-package super-save
@@ -99,13 +111,21 @@
   :config
   (global-flycheck-mode))
 
-;(use-package flyspell
-;  :custom
-;  (ispell-program-name "aspell")
-;  (ispell-extra-args '("--sug-mode=ultra"))
-;  :hook
-;  (text-mode . (lambda () (flyspell-mode +1)))
-;  (prog-mode . (lambda () (flyspell-prog-mode))))
+(use-feature flyspell
+  :diminish
+  :config
+  (when (string-suffix-p "aspell" ispell-program-name)
+    (setq ispell-extra-args '("--sug-mode=ultra")))
+  (unbind-key "C-," flyspell-mode-map)
+  (unbind-key "C-." flyspell-mode-map)
+  ;;(unbind-key "C-;" flyspell-mode-map)
+  :custom (flyspell-auto-correct-binding (kbd "C-x C-M-;"))
+  :bind (:map flyspell-mode-map
+              ("C-x C-," . flyspell-goto-next-error)
+              ("C-x C-." . flyspell-correct-word))
+  :hook
+  (text-mode . flyspell-mode)
+  (prog-mode . flyspell-prog-mode))
 
 (use-feature bookmark
   :custom
@@ -125,7 +145,6 @@
   (undo-tree-auto-save-history t))
 
 (use-feature abbrev
-  :defer 5
   :diminish
   :hook
   (text-mode . abbrev-mode)
@@ -146,27 +165,48 @@
 
 (use-package operate-on-number
   :bind
-  ("C-c ." . operate-on-number-at-point))
+  ("C-c +" . operate-on-number-at-point))
 
 (defun +elpaca-unload-xref (e)
   (and (featurep 'xref) (unload-feature 'xref t))
+  ;; Make sure these aren't overwritten
+  (setq xref-search-program 'ripgrep
+        xref-show-xrefs-function #'consult-xref
+        xref-show-definitions-function #'consult-xref)
   (elpaca--continue-build e))
 
 (defun +elpaca-xref-build-steps ()
   (append (butlast (if (file-exists-p (expand-file-name "xref" elpaca-builds-directory))
                        elpaca--pre-built-steps elpaca-build-steps))
-          (list '+elpaca-unload-xref'elpaca--activate-package)))
+          (list '+elpaca-unload-xref 'elpaca--activate-package)))
 
 (use-package xref
-  :ensure `(xref :build ,(+elpaca-xref-build-steps))
-  :custom (xref-search-program 'ripgrep)
+  :ensure `(xref :build ,(+elpaca-xref-build-steps) :ref "87db670d045bea2d90139b1f741eea8db7c193ea" :pin t)
+  :custom
+  (xref-search-program 'ripgrep)
+  (xref-show-xrefs-function #'consult-xref)
+  (xref-show-definitions-function #'consult-xref)
   :config
+  (defun xref-find-references-current-defun ()
+    "`xref-find-references' for the enclosing defun."
+    (interactive)
+    (xref-backend-identifier-completion-table (xref-find-backend))
+    (xref-find-references (which-function)))
+  (defun xref-find-definitions-current-list-function ()
+    "`xref-find-definitions' for the function at the beginning of the current list.
+With a prefix argument, moves up `current-prefix-arg' sexps first."
+    (interactive)
+    (let ((fn-name (save-excursion
+                     (when current-prefix-arg
+                       (sp-backward-up-sexp current-prefix-arg))
+                     (sp-beginning-of-sexp) (thing-at-point 'symbol))))
+      (xref-find-definitions fn-name)))
   (defun xref-find-references-other-window (identifier)
-    "Like `xref-find-references' but switch to the other window"
+    "Like `xref-find-references' but switch to the other window."
     (interactive (list (xref--read-identifier "Find references of: ")))
     (xref--find-xrefs identifier 'references identifier 'window))
   (defun xref-find-references-other-frame (identifier)
-    "Like `xref-find-references' but switch to the other frame"
+    "Like `xref-find-references' but switch to the other frame."
     (interactive (list (xref--read-identifier "Find references of: ")))
     (xref--find-xrefs identifier 'references identifier 'frame))
   (define-key ctl-x-4-map (kbd "M-?") 'xref-find-references-other-window)
@@ -176,7 +216,10 @@
   ;; there is no value at point that can be used
   (add-to-list 'xref-prompt-for-identifier 'xref-find-references t)
   (add-to-list 'xref-prompt-for-identifier 'xref-find-references-other-window t)
-  (add-to-list 'xref-prompt-for-identifier 'xref-find-references-other-frame t))
+  (add-to-list 'xref-prompt-for-identifier 'xref-find-references-other-frame t)
+  :bind
+  ("C-c q" . xref-find-references-current-defun)
+  ("C-c C-M-." . xref-find-definitions-current-list-function))
 
 (use-package ws-butler
   :diminish
@@ -221,8 +264,9 @@
   :hook (elpaca-after-init . editorconfig-mode))
 
 (use-package titlecase
-  ;; TODO find a better binding
-  :bind ("C-c c t t" . titlecase-dwim))
+  :bind (("C-c c t t" . titlecase-dwim)
+         (:map embark-heading-map ("T" . titlecase-line))
+         (:map embark-region-map ("T" . titlecase-region))))
 
 (use-package caser
   :ensure (caser :host github :repo "emacsmirror/caser")
@@ -265,5 +309,9 @@
               ("x" . cider-eval-region)
               ("r" . cider-insert-region-in-repl)))
 
+(use-package repeat-fu
+  :bind ("M-+" . repeat-fu-execute)
+  :hook ((prog-mode text-mode) . repeat-fu-mode))
+
 (provide 'init-editor)
 ;;; init-editor.el ends here
diff --git a/.emacs.d/lisp/init-emacs-lisp.el b/.emacs.d/lisp/init-emacs-lisp.el
index 4ca010a..0cf1f44 100644
--- a/.emacs.d/lisp/init-emacs-lisp.el
+++ b/.emacs.d/lisp/init-emacs-lisp.el
@@ -10,6 +10,10 @@
   :diminish)
 
 (use-feature emacs
+  :custom
+  ;; These don't really belong here, but do affect ielm
+  (comint-prompt-read-only t)
+  (comint-buffer-maximum-size 2048)
   :config
   ;; Based on prelude-emacs-lisp.el
   (defun recompile-init-lisp ()
@@ -61,6 +65,16 @@ Start `ielm' if it's not already running."
 
 
 (use-package eros
+  :config
+  ;; https://xenodium.com/inline-previous-result-and-why-you-should-edebug/
+  (defun adviced:edebug-previous-result (_ &rest r)
+    "Adviced `edebug-previous-result'."
+    (eros--make-result-overlay edebug-previous-result
+      :where (point)
+      :duration eros-eval-result-duration))
+  (advice-add #'edebug-previous-result
+              :around
+              #'adviced:edebug-previous-result)
   :hook
   (emacs-lisp-mode . eros-mode))
 
diff --git a/.emacs.d/lisp/init-git.el b/.emacs.d/lisp/init-git.el
index 1d7183e..10c9c78 100644
--- a/.emacs.d/lisp/init-git.el
+++ b/.emacs.d/lisp/init-git.el
@@ -77,6 +77,8 @@
   ("C-c g r" . my/magit-refresh-state)
   ("C-c g m" . my/magit-update-master)
   ("C-c g C-c" . my/magit-stage-and-commit-file)
+  ;; Used by eshell-prompt-function (see init-shell.el)
+  :commands (magit-get-shortname magit-file-status)
   :config
   ;; Requires the following gitconfig:
   ;; [alias]
@@ -338,8 +340,13 @@ GitHub/Bitbucket/GitLab/... The URL will be added to the kill ring.  If
   ("C-c g c" . git-link-commit)
   ("C-c g b" . git-link-branch))
 
+(use-feature git-link-transient
+  :bind ("C-c g d" . git-link-dispatch))
+
 (use-feature git-related
-  :defer 10)
+  :bind
+  ("C-c g #" . git-related-find-file)
+  ("C-c g ~" . git-related-update))
 
 (provide 'init-git)
 ;;; init-git.el ends here
diff --git a/.emacs.d/lisp/init-kill.el b/.emacs.d/lisp/init-kill.el
index 37103e3..d72f776 100644
--- a/.emacs.d/lisp/init-kill.el
+++ b/.emacs.d/lisp/init-kill.el
@@ -16,6 +16,7 @@
   (:map easy-kill-base-map ("C-=" . easy-kill-expand)))
 
 (use-feature emacs
+  :custom (kill-do-not-save-duplicates t)
   :hook
   (elpaca-after-init . (lambda ()
                          ;; Based on code in prelude-editor.el
diff --git a/.emacs.d/lisp/init-lsp.el b/.emacs.d/lisp/init-lsp.el
index e496813..9a0b4d5 100644
--- a/.emacs.d/lisp/init-lsp.el
+++ b/.emacs.d/lisp/init-lsp.el
@@ -26,6 +26,7 @@
   (lsp-lens-mode . really-diminish-lsp-lens-mode)
   (lsp-completion-mode . my/lsp-mode-setup-completion)
   (sql-mode . lsp)
+  (lsp-after-apply-edits . save-buffer)
   :config
   (defun really-diminish-lsp-lens-mode ()
     (diminish 'lsp-lens-mode)
@@ -55,7 +56,38 @@
         lsp-references-exclude-definition t
         ;; user cider for indendation and eldoc
         lsp-enable-indentation nil
-        lsp-eldoc-enable-hover nil))
+        lsp-eldoc-enable-hover nil)
+
+  ;; Copied from https://github.com/blahgeek/emacs-lsp-booster/blob/4200ed6ae0cd83b8e3fd1dbefb09121480951a22/README.md#configure-lsp-mode
+  (defun lsp-booster--advice-json-parse (old-fn &rest args)
+    "Try to parse bytecode instead of json."
+    (or
+     (when (equal (following-char) ?#)
+       (let ((bytecode (read (current-buffer))))
+         (when (byte-code-function-p bytecode)
+           (funcall bytecode))))
+     (apply old-fn args)))
+  (advice-add (if (progn (require 'json)
+                         (fboundp 'json-parse-buffer))
+                  'json-parse-buffer
+                'json-read)
+              :around
+              #'lsp-booster--advice-json-parse)
+  (defun lsp-booster--advice-final-command (old-fn cmd &optional test?)
+    "Prepend emacs-lsp-booster command to lsp CMD."
+    (let ((orig-result (funcall old-fn cmd test?)))
+      (if (and (not test?)                             ;; for check lsp-server-present?
+               (not (file-remote-p default-directory)) ;; see lsp-resolve-final-command, it would add extra shell wrapper
+               lsp-use-plists
+               (not (functionp 'json-rpc-connection))  ;; native json-rpc
+               (executable-find "emacs-lsp-booster"))
+          (progn
+            (when-let ((command-from-exec-path (executable-find (car orig-result))))  ;; resolve command from exec-path (in case not found in $PATH)
+              (setcar orig-result command-from-exec-path))
+            (message "Using emacs-lsp-booster for %s!" orig-result)
+            (cons "emacs-lsp-booster" orig-result))
+        orig-result)))
+  (advice-add 'lsp-resolve-final-command :around #'lsp-booster--advice-final-command))
 
 (provide 'init-lsp)
 ;;; init-lsp.el ends here
diff --git a/.emacs.d/lisp/init-minibuffer.el b/.emacs.d/lisp/init-minibuffer.el
index 69fec18..118f730 100644
--- a/.emacs.d/lisp/init-minibuffer.el
+++ b/.emacs.d/lisp/init-minibuffer.el
@@ -12,7 +12,7 @@
   :config
   ;; Do not allow the cursor in the minibuffer prompt
   (setq minibuffer-prompt-properties
-        '(read-only t cursor-intangible t face minibuffer-prompt))
+        '(read-only t cursor-intangible t intangible t face minibuffer-prompt))
   (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)
   (setq enable-recursive-minibuffers t)
   (minibuffer-depth-indicate-mode t)
@@ -42,24 +42,31 @@
                    "  ")
                  cand)))
 
+  ;; https://github.com/minad/vertico/wiki#ding-when-wrapping-around
+  (advice-add #'vertico-next
+              :around
+              #'(lambda (origin &rest args)
+                  (let ((beg-index vertico--index))
+                    (apply origin args)
+                    (if (not (eq 1 (abs (- beg-index vertico--index))))
+                        (ding)))))
+
+  ;; https://github.com/minad/vertico/wiki#useful-commands-from-outside-minibuffer
   (defun down-from-outside ()
     "Move to next candidate in minibuffer, even when minibuffer isn't selected."
     (interactive)
     (with-selected-window (active-minibuffer-window)
       (execute-kbd-macro [down])))
-
   (defun up-from-outside ()
     "Move to previous candidate in minibuffer, even when minibuffer isn't selected."
     (interactive)
     (with-selected-window (active-minibuffer-window)
       (execute-kbd-macro [up])))
-
   (defun preview-from-outside ()
     "Preview the selected candidate, even when minibuffer isn't selected."
     (interactive)
     (with-selected-window (active-minibuffer-window)
       (execute-kbd-macro (kbd "M-."))))
-
   (defun to-and-fro-minibuffer ()
     "Go back and forth between minibuffer and other window."
     (interactive)
@@ -67,18 +74,73 @@
         (select-window (minibuffer-selected-window))
       (select-window (active-minibuffer-window))))
 
-  (defun minibuffer-really-quit ()
-    "Quit minibuffer session, even if it is not the selected window."
+  ;; Modified from https://github.com/minad/vertico/wiki#update-minibuffer-history-with-candidate-insertions
+  (defadvice vertico-insert
+      (after vertico-insert-add-history activate)
+    "Make vertico-insert add to the minibuffer history."
+    (if (and (not (eq minibuffer-history-variable t))
+             (eq 'file (vertico--metadata-get 'category)))
+        (add-to-history minibuffer-history-variable (minibuffer-contents))))
+
+  (defun toggle-sort-directories-first ()
     (interactive)
-    (with-selected-window (active-minibuffer-window)
-      (minibuffer-keyboard-quit)))
+    (if (eq vertico-sort-function 'vertico-sort-directories-first)
+        (set (make-local-variable 'vertico-sort-function) 'vertico-sort-history-length-alpha)
+      (set (make-local-variable 'vertico-sort-function) 'vertico-sort-directories-first))
+    (setq vertico--input t)
+    (vertico--update))
 
   :bind (("C-M-<" . up-from-outside)
          ("C-M->" . down-from-outside)
          ("C-M-+" . preview-from-outside)
          ("M-X" . to-and-fro-minibuffer)
-         ("C-M-S-g" . minibuffer-really-quit)
-         (:map vertico-map ("M-RET" . minibuffer-force-complete-and-exit))))
+         (:map vertico-map
+               ("M-RET" . minibuffer-force-complete-and-exit)
+               ("M-D" . toggle-sort-directories-first))))
+
+(use-extension vertico vertico-multiform
+  :config
+  (vertico-multiform-mode +1)
+
+  (defun vertico-multiform-buffer-grid ()
+    "Toggle displaying Vertico as a grid in a large window (like a regular buffer).)"
+    (interactive)
+    (if (equal '(vertico-buffer-mode vertico-grid-mode) (car vertico-multiform--stack))
+        (vertico-multiform-vertical)
+      (setcar vertico-multiform--stack '(vertico-buffer-mode vertico-grid-mode))
+      (vertico-multiform--toggle 1)))
+
+  ;; https://github.com/minad/vertico/wiki#candidate-display-transformations-custom-candidate-highlighting
+  (defvar +vertico-transform-functions nil)
+  (cl-defmethod vertico--format-candidate :around
+    (cand prefix suffix index start &context ((not +vertico-transform-functions) null))
+    (dolist (fun (ensure-list +vertico-transform-functions))
+      (setq cand (funcall fun cand)))
+    (cl-call-next-method cand prefix suffix index start))
+  (defun +vertico-highlight-directory (file)
+    "If FILE ends with a slash, highlight it as a directory."
+    (if (string-suffix-p "/" file)
+        (propertize file 'face 'marginalia-file-priv-dir)
+      file))
+  (defun +vertico-highlight-enabled-mode (cmd)
+    "If MODE is enabled, highlight it as font-lock-doc-face."
+    (let ((sym (intern cmd)))
+      (if (or (eq sym major-mode)
+              (and
+               (memq sym minor-mode-list)
+               (boundp sym)))
+          (propertize cmd 'face 'font-lock-doc-face)
+        cmd)))
+
+  (setq vertico-multiform-commands
+        '((execute-extended-command
+           (+vertico-transform-functions . +vertico-highlight-enabled-mode))))
+  (setq vertico-multiform-categories
+        '((file (+vertico-transform-functions . +vertico-highlight-directory)
+                (:keymap . vertico-directory-map))
+          (imenu grid)))
+  :bind (:map vertico-multiform-map
+              ("M-H" . vertico-multiform-buffer-grid)))
 
 (use-extension vertico vertico-directory
   :config
@@ -115,28 +177,28 @@
 DEFS is a plist associating completion categories to commands."
     (let ((default-command (lookup-key vertico-map (kbd key))))
       (define-key vertico-map (kbd key)
-        (list 'menu-item nil defs :filter
-              (lambda (d)
-                (or (plist-get d (completion-metadata-get
-                                  (completion-metadata (minibuffer-contents)
-                                                       minibuffer-completion-table
-                                                       minibuffer-completion-predicate)
-                                  'category))
-                    default-command))))))
+                  (list 'menu-item nil defs :filter
+                        (lambda (d)
+                          (or (plist-get d (completion-metadata-get
+                                            (completion-metadata (minibuffer-contents)
+                                                                 minibuffer-completion-table
+                                                                 minibuffer-completion-predicate)
+                                            'category))
+                              default-command))))))
   (define-vertico-key "/"
-    'file #'vertico-directory-slash
-    'project-file #'vertico-directory-slash)
+                      'file #'vertico-directory-slash
+                      'project-file #'vertico-directory-slash)
   (define-vertico-key "RET"
-    'file #'vertico-directory-enter-or-select-project
-    'project-file #'vertico-directory-enter)
+                      'file #'vertico-directory-enter-or-select-project
+                      'project-file #'vertico-directory-enter)
   (define-vertico-key "~"
-    'file #'vertico-directory-home)
+                      'file #'vertico-directory-home)
   (define-vertico-key "DEL"
-    'file #'vertico-directory-delete-char
-    'project-file #'vertico-directory-delete-char)
+                      'file #'vertico-directory-delete-char
+                      'project-file #'vertico-directory-delete-char)
   (define-vertico-key "M-DEL"
-    'file #'vertico-directory-delete-word
-    'project-file #'vertico-directory-delete-word)
+                      'file #'vertico-directory-delete-word
+                      'project-file #'vertico-directory-delete-word)
   :commands (vertico-directory-enter vertico-directory-delete-word vertico-directory-delete-char)
   ;; Tidy shadowed file names
   :hook (rfn-eshadow-update-overlay . vertico-directory-tidy))
@@ -152,21 +214,21 @@ DEFS is a plist associating completion categories to commands."
 
 (use-extension vertico vertico-indexed
   :config
-  (defmacro define-choose (n)
+  (defmacro define-vertico-choose (n)
     `(defun ,(intern (format "vertico-indexed-choose-%s" n)) ()
        ,(format "Exit minibuffer with candidate %s." n)
        (interactive)
        (let ((vertico--index ,n))
          (funcall-interactively 'vertico-exit))))
-  (defmacro define-insert (n)
+  (defmacro define-vertico-insert (n)
     `(defun ,(intern (format "vertico-indexed-insert-%s" n)) ()
        ,(format "Insert candidate %s in minibuffer." n)
        (interactive)
        (let ((vertico--index ,n))
          (funcall-interactively 'vertico-insert))))
   (dotimes (n 10)
-    (eval `(define-choose ,n))
-    (eval `(define-insert ,n))
+    (eval `(define-vertico-choose ,n))
+    (eval `(define-vertico-insert ,n))
     (define-key vertico-map (kbd (format "C-%s" n)) (intern (format "vertico-indexed-choose-%s" n)))
     (define-key vertico-map (kbd (format "M-%s" n)) (intern (format "vertico-indexed-insert-%s" n))))
   (vertico-indexed-mode 1))
@@ -179,32 +241,36 @@ DEFS is a plist associating completion categories to commands."
 (use-package consult
   :bind (;; C-c bindings (mode-specific-map)
          ("C-c h" . consult-history)
-         ("C-c m" . consult-mode-command)
+         ("C-c M-x" . consult-mode-command)
          ("C-c b" . consult-bookmark)
          ("C-c k" . consult-kmacro)
+         ("C-c m" . consult-man)
+         ("C-c i" . consult-info)
+         ([remap Info-search] . consult-info)
          ;; C-x bindings (ctl-x-map)
          ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command
          ("C-x b" . consult-buffer) ;; orig. switch-to-buffer
-         ("C-x B" . consult-buffer-no-preview) ;; orig. switch-to-buffer
+         ("C-x B" . consult-buffer-no-preview)
          ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window
          ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame
+         ("C-x t b" . consult-buffer-other-tab) ;; orig. switch-to-buffer-other-tab
+         ("C-x r b" . consult-bookmark) ;; orig. bookmark-jump
+         ("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer
          ;; Custom M-# bindings for fast register access
          ("M-#" . consult-register-load)
          ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated)
          ("C-M-#" . consult-register)
          ;; Other custom bindings
+         ("C-," . consult-line)
          ("C-S-s" . consult-line)
-         ("M-*" . consult-line-thing-at-point)
          ("C-c f" . consult-recent-file)
          ("C-c r" . consult-ripgrep)
+         ("C-c ." . consult-ripgrep) ;; convenient for using with embark-act (C-. C-c . to search for thing at point)
          ;; TODO find an alternative to C-c c?
          ("C-c c r" . consult-ripgrep-auto-preview)
          ("C-c c s" . consult-ripgrep-case-sensitive)
-         ("C-c c z" . consult-z-ripgrep)
-         ("C-c C-*" . consult-ripgrep-thing-at-point)
          ("C-c C-^" . consult-ripgrep-parent)
          ("M-y" . consult-yank-pop)     ;; orig. yank-pop
-         ("<help> a" . consult-apropos) ;; orig. apropos-command
          ;; M-g bindings (goto-map)
          ("M-g e" . consult-compile-error)
          ("M-g f" . consult-flycheck)
@@ -227,16 +293,14 @@ DEFS is a plist associating completion categories to commands."
                ("G" . consult-git-grep)
                ("r" . consult-ripgrep)
                ("R" . consult-ripgrep) ;; can't use r in isearch-mode, so add R too
-               ("M-r" . consult-ripgrep-unrestricted)
-               ("*" . consult-ripgrep-thing-at-point)
-               ("z" . consult-z-ripgrep)
+               ("u" . consult-ripgrep-unrestricted)
                ("^" . consult-ripgrep-parent)
                ("l" . consult-line)
                ("L" . consult-line-multi)
                ("m" . consult-multi-occur)
                ("k" . consult-keep-lines)
-               ("u" . consult-focus-lines)
-               ("e" . consult-isearch))
+               ("C-f" . consult-focus-lines)
+               ("e" . consult-isearch-history))
          (:map vertico-map
                ;; These are used for previewing with some consult commands (see consult-customize call below)
                ("C-S-p" . vertico-previous)
@@ -247,22 +311,24 @@ DEFS is a plist associating completion categories to commands."
 
   :config
 
-  ;; Optionally configure the register formatting. This improves the register
+  ;; Configure register formatting. This improves the register
   ;; preview for `consult-register', `consult-register-load',
   ;; `consult-register-store' and the Emacs built-ins.
   (setq register-preview-delay 0
         register-preview-function #'consult-register-format)
 
-  ;; Optionally tweak the register preview window.
+  ;; Tweak the register preview window.
   ;; This adds thin lines, sorting and hides the mode line of the window.
   (advice-add #'register-preview :override #'consult-register-window)
 
-  ;; Use Consult to select xref locations with preview
-  (setq xref-show-xrefs-function #'consult-xref
-        xref-show-definitions-function #'consult-xref)
-
   (add-to-list 'consult-mode-histories '(cider-repl-mode cider-repl-input-history))
 
+  (defvar consult-line-map
+    (let ((map (make-sparse-keymap)))
+      (define-key map "\C-s" #'previous-history-element)
+      map))
+  (consult-customize consult-line :keymap consult-line-map)
+
   (defun consult-ripgrep-auto-preview (&optional dir initial)
     (interactive "P")
     (consult-ripgrep dir initial))
@@ -270,10 +336,6 @@ DEFS is a plist associating completion categories to commands."
     (interactive "P")
     (let ((consult-ripgrep-args (replace-regexp-in-string "\\." "-uu ." consult-ripgrep-args)))
       (consult-ripgrep dir initial)))
-  (defun consult-z-ripgrep (&optional dir initial)
-    (interactive "P")
-    (let ((consult-ripgrep-args (replace-regexp-in-string "\\." "-z ." consult-ripgrep-args)))
-      (consult-ripgrep dir initial)))
   (defun consult-ripgrep-case-sensitive (&optional dir initial)
     (interactive "P")
     (let ((consult-ripgrep-args (replace-regexp-in-string "\\." "-s ." consult-ripgrep-args)))
@@ -283,25 +345,19 @@ DEFS is a plist associating completion categories to commands."
     (consult-buffer))
   (defun consult-ripgrep-parent (&optional initial)
     (interactive "P")
-    (consult-ripgrep (file-name-directory (directory-file-name (persp-current-project-root))) initial))
-
-  (defalias 'consult-line-thing-at-point 'consult-line)
-  (defalias 'consult-ripgrep-thing-at-point 'consult-ripgrep)
+    (consult-ripgrep (file-name-directory
+                      (directory-file-name (or (persp-current-project-root) default-directory)))
+                     initial))
 
   (consult-customize
    consult-theme
    :preview-key '(:debounce 0.2 any)
    ;; For these commands we can use C-N/C-P to scroll and preview, or M-. to preview
    consult-git-grep consult-grep
-   consult-ripgrep-parent consult-ripgrep consult-ripgrep-case-sensitive
-   consult-ripgrep-unrestricted consult-z-ripgrep consult-ripgrep-thing-at-point
+   consult-ripgrep-parent consult-ripgrep consult-ripgrep-case-sensitive consult-ripgrep-unrestricted
    consult-bookmark consult-recent-file consult-xref consult-buffer-no-preview
-   consult--source-recent-file consult--source-project-recent-file consult--source-bookmark
-   :preview-key '("M-." :debounce 0.2 "C-S-n" :debounce 0.2 "C-S-p")
-   consult-ripgrep-thing-at-point
-   :initial (concat "#" (thing-at-point 'symbol))
-   consult-line-thing-at-point
-   :initial (thing-at-point 'symbol))
+   consult--source-recent-file consult--source-project-recent-file consult--source-bookmark;
+   :preview-key '("M-." :debounce 0.2 "C-S-n" :debounce 0.2 "C-S-p"))
 
   (defvar-local consult-toggle-preview-orig nil)
   (defun consult-toggle-preview ()
@@ -403,7 +459,7 @@ DEFS is a plist associating completion categories to commands."
     "Remove a # character from the beginning of the current line.
 
 Designed to be used for consult commands that automatically add a # at the beginning of the minibuffer.
-See `+become-consult-line'."
+See `+become' and the functions that call it (e.g. `+become-consult-line')."
     (interactive)
     (save-excursion
       (beginning-of-line)
@@ -416,7 +472,29 @@ See `+become-consult-line'."
     (let ((consult-buffer-sources '(consult--project-source-project-buffer
                                     consult--project-source-project-file-recentf
                                     consult--project-source-project-file-all)))
-      (consult-buffer))))
+      (consult-buffer)))
+
+  ;; https://takeonrules.com/2024/06/08/adding-a-consult-function-for-visualizing-xref/
+  (defvar consult--xref-history nil
+    "History for the `consult-recent-xref' results.")
+  (defun consult-recent-xref (&optional markers)
+    "Jump to a marker in MARKERS list (defaults to `xref--history'.
+
+The command supports preview of the currently selected marker position.
+The symbol at point is added to the future history."
+    (interactive)
+    (consult--read
+     (consult--global-mark-candidates
+      (or markers (flatten-list xref--history)))
+     :prompt "Go to Xref: "
+     :annotate (consult--line-prefix)
+     :category 'consult-location
+     :sort nil
+     :require-match t
+     :lookup #'consult--lookup-location
+     :history '(:input consult--xref-history)
+     :add-history (thing-at-point 'symbol)
+     :state (consult--jump-state))))
 
 (use-package consult-flycheck)
 
@@ -437,6 +515,9 @@ See `+become-consult-line'."
 (use-package consult-ls-git
   :bind ("C-c g f" . consult-ls-git))
 
+(use-package consult-vc-modified-files
+  :bind (:map vc-prefix-map ("f" . consult-vc-modified-files)))
+
 (use-package consult-project-extra)
 
 (use-package marginalia
@@ -448,19 +529,38 @@ See `+become-consult-line'."
 (use-package embark
   :bind
   (("C-." . embark-act)
+   ([remap xref-find-definitions-current-list-function] . embark-dwim-beginning-of-list)
    ([remap xref-find-definitions] . embark-dwim)
+   ([remap xref-find-definitions-other-window] . embark-dwim-other-window)
    ("C-c C-o" . embark-export)
    ("C-h b" . embark-bindings)
    ("C-h B" . describe-bindings)
    (:map minibuffer-local-map
          ("M-." . embark-preview)
-         ("C-," . embark-become))
+         ("C-," . embark-become)
+         ("C-^" . embark-become-ripgrep-parent)
+         ("C-S-SPC" . embark-select))
    (:map embark-become-file+buffer-map
          ("e" . consult-project-extra-find)
          ("E" . project-switch-consult-project-extra-find)))
   :custom
   (prefix-help-command 'embark-prefix-help-command)
   :config
+  (defun embark-dwim-other-window ()
+    "Like `embark-dwim' but switch to the other window."
+    (interactive)
+    (other-window-prefix)
+    (embark-dwim))
+  (defun embark-dwim-beginning-of-list ()
+    "`embark-dwim' at the beginning of the current list.
+With a prefix argument, moves up `current-prefix-arg' sexps first."
+    (interactive)
+    (progn
+      (when current-prefix-arg
+        (sp-backward-up-sexp current-prefix-arg))
+      (sp-beginning-of-sexp)
+      (embark-dwim)))
+  (defalias 'embark-become-ripgrep-parent (kmacro "C-, ^"))
   (defun embark-preview ()
     "Previews candidate in vertico buffer, unless it's a consult command"
     (interactive)
@@ -481,17 +581,30 @@ See `+become-consult-line'."
   ;; See https://github.com/oantolin/embark/commit/47daded610b245caf01a97d74c940aff91fe14e2#r46010972
   :demand t
   :config
+  (defun +become (fn)
+    "Remove the leading # from the minibuffer, and call `FN'.
+Useful with embark-become, when changing from a command that uses # as a separator, to one that doesn't."
+    (interactive)
+    (setq unread-command-events (listify-key-sequence "\C-x\C-\M-x"))
+    (funcall-interactively fn))
   (defun +become-consult-line ()
-    "TODO."
+    "A version of `consult-line', designed for use with `embark-become'.
+The leading # added by other consult commands is removed."
     (interactive)
-    (progn
-      (setq unread-command-events (listify-key-sequence "\C-x\C-\M-x"))
-      (consult-line)))
+    (+become #'consult-line))
+  (defun +become-consult-line ()
+    "A version of `consult-imenu', designed for use with `embark-become'.
+The leading # added by other consult commands is removed."
+    (interactive)
+    (+become #'consult-imenu))
   :bind
   (:map embark-consult-async-search-map
         ("l" . +become-consult-line)
+        ("f" . consult-focus-lines)
+        ("i" . +become-consult-imenu)
         ("^" . consult-ripgrep-parent)
-        ("R" . consult-ripgrep-unrestricted))
+        ("u" . consult-ripgrep-unrestricted)
+        ("c" . consult-ripgrep-case-sensitive))
   :hook
   (embark-collect-mode . consult-preview-at-point-mode))
 
diff --git a/.emacs.d/lisp/init-misc.el b/.emacs.d/lisp/init-misc.el
index 86ec023..82c4264 100644
--- a/.emacs.d/lisp/init-misc.el
+++ b/.emacs.d/lisp/init-misc.el
@@ -64,7 +64,7 @@
           (kill-new curl-command)
           (message "curl command copied to clipboard.")))))
   :bind
-  ("C-c C-h" . restclient-call-saved-request)
+  ("C-c M-h" . restclient-call-saved-request)
   (:map restclient-mode-map ("C-c h" . restclient-save-current))
   :mode (("\\.http\\'" . restclient-mode)))
 
@@ -80,8 +80,9 @@
 
 (use-package csv-mode
   :bind (:map csv-mode-map
-              ("M-]" . csv-forward-field)
-              ("M-[" . csv-backward-field)))
+              ;; TODO find something less awkward
+              ("C-M-)" . csv-forward-field)
+              ("C-M-(" . csv-backward-field)))
 
 (use-package yaml-mode
   :diminish
diff --git a/.emacs.d/lisp/init-navigation.el b/.emacs.d/lisp/init-navigation.el
index 7d87b8a..b407e7b 100644
--- a/.emacs.d/lisp/init-navigation.el
+++ b/.emacs.d/lisp/init-navigation.el
@@ -7,6 +7,13 @@
   (avy-all-windows nil)
   (avy-all-windows-alt t)
   (avy-timeout-seconds 0.3)
+  :init
+  ;; Allow C-[ to be bound (instead of being equivalent to ESC), but only in GUI Emacs
+  ;; https://emacs.stackexchange.com/a/52334
+  (let ((frame (framep (selected-frame))))
+    (or (eq  t  frame)
+        (eq 'pc frame)
+        (define-key input-decode-map (kbd "C-[") [control-bracketleft])))
   :config
   ;; https://karthinks.com/software/avy-can-do-anything/#avy-plus-embark-any-action-anywhere
   (defun avy-action-embark (pt)
@@ -24,7 +31,7 @@
     (let ((beg (point)))
       (avy-goto-char-timer)
       (copy-region-as-kill beg (point))))
-  (defun avy-kill-in-line ()
+  (defun avy-copy-as-kill-in-line ()
     (interactive)
     (avy-goto-char-timer)
     (let ((beg (point)))
@@ -33,12 +40,12 @@
   :bind
   ("C-'" . avy-goto-char-timer)
   ("C-;" . avy-goto-char-in-line)
-  ("M-]" . avy-goto-word-1)
+  ("C-#" . avy-goto-word-1)
   ("C-c C-'" . avy-copy-as-kill)
   ("C-c C-;" . avy-copy-as-kill-in-line))
 
 (use-package casual-avy
-  :bind ("C-M-;" . casual-avy-tmenu))
+  :bind ([control-bracketleft] . casual-avy-tmenu))
 
 (use-package smartscan
   :custom (smartscan-symbol-selector "symbol")
@@ -72,7 +79,8 @@ Or remove all highlighted symbols in the current buffer (with`ARG')."
   :bind
   ("C-c o" . symbol-overlay-put-or-clear)
   ("M-N" . symbol-overlay-switch-forward)
-  ("M-P" . symbol-overlay-switch-backward))
+  ("M-P" . symbol-overlay-switch-backward)
+  (:map symbol-overlay-map ("o" . symbol-overlay-put-or-clear)))
 
 (use-package gumshoe
   :after perspective
diff --git a/.emacs.d/lisp/init-packages.el b/.emacs.d/lisp/init-packages.el
index 48080d8..55b3eb5 100644
--- a/.emacs.d/lisp/init-packages.el
+++ b/.emacs.d/lisp/init-packages.el
@@ -3,12 +3,12 @@
 ;;; Code:
 
 ;; Elpaca installer block
-(defvar elpaca-installer-version 0.7)
+(defvar elpaca-installer-version 0.11)
 (defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory))
 (defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory))
 (defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory))
 (defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git"
-                              :ref nil :depth 1
+                              :ref nil :depth 1 :inherit ignore
                               :files (:defaults "elpaca-test.el" (:exclude "extensions"))
                               :build (:not elpaca--activate-package)))
 (let* ((repo  (expand-file-name "elpaca/" elpaca-repos-directory))
@@ -18,27 +18,27 @@
   (add-to-list 'load-path (if (file-exists-p build) build repo))
   (unless (file-exists-p repo)
     (make-directory repo t)
-    (when (< emacs-major-version 28) (require 'subr-x))
+    (when (<= emacs-major-version 28) (require 'subr-x))
     (condition-case-unless-debug err
-        (if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*"))
-                 ((zerop (apply #'call-process `("git" nil ,buffer t "clone"
-                                                 ,@(when-let ((depth (plist-get order :depth)))
-                                                     (list (format "--depth=%d" depth) "--no-single-branch"))
-                                                 ,(plist-get order :repo) ,repo))))
-                 ((zerop (call-process "git" nil buffer t "checkout"
-                                       (or (plist-get order :ref) "--"))))
-                 (emacs (concat invocation-directory invocation-name))
-                 ((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch"
-                                       "--eval" "(byte-recompile-directory \".\" 0 'force)")))
-                 ((require 'elpaca))
-                 ((elpaca-generate-autoloads "elpaca" repo)))
+        (if-let* ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*"))
+                  ((zerop (apply #'call-process `("git" nil ,buffer t "clone"
+                                                  ,@(when-let* ((depth (plist-get order :depth)))
+                                                      (list (format "--depth=%d" depth) "--no-single-branch"))
+                                                  ,(plist-get order :repo) ,repo))))
+                  ((zerop (call-process "git" nil buffer t "checkout"
+                                        (or (plist-get order :ref) "--"))))
+                  (emacs (concat invocation-directory invocation-name))
+                  ((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch"
+                                        "--eval" "(byte-recompile-directory \".\" 0 'force)")))
+                  ((require 'elpaca))
+                  ((elpaca-generate-autoloads "elpaca" repo)))
             (progn (message "%s" (buffer-string)) (kill-buffer buffer))
           (error "%s" (with-current-buffer buffer (buffer-string))))
       ((error) (warn "%s" err) (delete-directory repo 'recursive))))
   (unless (require 'elpaca-autoloads nil t)
     (require 'elpaca)
     (elpaca-generate-autoloads "elpaca" repo)
-    (load "./elpaca-autoloads")))
+    (let ((load-source-file-function nil)) (load "./elpaca-autoloads"))))
 (add-hook 'after-init-hook #'elpaca-process-queues)
 (elpaca `(,@elpaca-order))
 ;; End of elpaca installer block
@@ -118,6 +118,52 @@
 ;; https://github.com/progfolio/elpaca/wiki/Logging#customizing-the-position-of-the-elpaca-log-buffer
 (add-to-list 'display-buffer-alist '("\\*elpaca-log\\*" (display-buffer-reuse-window display-buffer-at-bottom)))
 
+;; https://github.com/progfolio/elpaca/wiki/Reloading-a-package%E2%80%99s-features-after-updating-a-package
+(defun +elpaca-reload-package (package &optional allp)
+  "Reload PACKAGE's features.
+If ALLP is non-nil (interactively, with prefix), load all of its
+features; otherwise only load ones that were already loaded.
+
+This is useful to reload a package after upgrading it.  Since a
+package may provide multiple features, to reload it properly
+would require either restarting Emacs or manually unloading and
+reloading each loaded feature.  This automates that process.
+
+Note that this unloads all of the package's symbols before
+reloading.  Any data stored in those symbols will be lost, so if
+the package would normally save that data, e.g. when a mode is
+deactivated or when Emacs exits, the user should do so before
+using this command."
+  (interactive
+   (list (let ((elpaca-overriding-prompt "Reload package: "))
+           (elpaca--read-queued))
+         current-prefix-arg))
+  ;; This finds features in the currently installed version of PACKAGE, so if
+  ;; it provided other features in an older version, those are not unloaded.
+  (when (yes-or-no-p (format "Unload all of %s's symbols and reload its features? " package))
+    (let* ((package-name (symbol-name package))
+           (package-dir (file-name-directory
+                         (locate-file package-name load-path (get-load-suffixes))))
+           (package-files (directory-files package-dir 'full (rx ".el" eos)))
+           (package-features
+            (cl-loop for file in package-files
+                     when (with-temp-buffer
+                            (insert-file-contents file)
+                            (when (re-search-forward (rx bol "(provide" (1+ space)) nil t)
+                              (goto-char (match-beginning 0))
+                              (cadadr (read (current-buffer)))))
+                     collect it)))
+      (unless allp
+        (setf package-features (seq-intersection package-features features)))
+      (dolist (feature package-features)
+        (ignore-errors
+          ;; Ignore error in case it's not loaded.
+          (unload-feature feature 'force)))
+      (dolist (feature package-features)
+        (require feature))
+      (when package-features
+        (message "Reloaded: %s" (mapconcat #'symbol-name package-features " "))))))
+
 ;; https://github.com/radian-software/radian/blob/e3aad124c8e0cc870ed09da8b3a4905d01e49769/emacs/radian.el#L352
 (defmacro use-feature (name &rest args)
   "Like `use-package', but without elpaca integration.
diff --git a/.emacs.d/lisp/init-project.el b/.emacs.d/lisp/init-project.el
index 6387f05..e66a4cd 100644
--- a/.emacs.d/lisp/init-project.el
+++ b/.emacs.d/lisp/init-project.el
@@ -5,6 +5,7 @@
 (require 'subr-x)
 
 (use-package project
+  :ensure (:ref "87db670d045bea2d90139b1f741eea8db7c193ea" :pin t)
   :config
   (defun project--clojure-switch-to-test (filename project-root)
     (let* ((project-src-file (string-remove-prefix project-root filename))
@@ -28,14 +29,18 @@
     "Show a list of recently visited files in a project."
     (interactive)
     (if (boundp 'recentf-list)
+        ;; Use expand-file-name for project-root and later recentf-list to ensure consistency
         (let* ((project-root (expand-file-name (project-root (project-current))))
                (project-recentf-files (mapcar
                                        (lambda (f) (file-relative-name f project-root))
-                                       (seq-filter (apply-partially 'string-prefix-p project-root) recentf-list))))
+                                       (seq-filter (apply-partially 'string-prefix-p project-root)
+                                                   (mapcar 'expand-file-name recentf-list)))))
           (find-file (expand-file-name
                       (funcall project-read-file-name-function
                                "Find recent project files"
-                               project-recentf-files)
+                               project-recentf-files
+                               nil
+                               'file-name-history)
                       project-root)))
       (message "recentf is not enabled")))
   (defun project-switch-src-project ()
diff --git a/.emacs.d/lisp/init-search.el b/.emacs.d/lisp/init-search.el
index f471d0e..f82d527 100644
--- a/.emacs.d/lisp/init-search.el
+++ b/.emacs.d/lisp/init-search.el
@@ -15,95 +15,6 @@
     (goto-char (point-min)))
   (advice-add 'isearch-occur :after 'isearch-occur-advice)
 
-  ;; Modified from http://yummymelon.com/devnull/improving-emacs-isearch-usability-with-transient.html
-  (transient-define-prefix isearch-menu ()
-    "isearch Menu"
-    [["Edit Search String"
-      ("e"
-       "Edit the search string (recursive)"
-       isearch-edit-string
-       :transient nil)
-      ("w"
-       "Pull next word or character word from buffer"
-       isearch-yank-word-or-char
-       :transient nil)
-      ("s"
-       "Pull next symbol or character from buffer"
-       isearch-yank-symbol-or-char
-       :transient nil)
-      ("l"
-       "Pull rest of line from buffer"
-       isearch-yank-line
-       :transient nil)
-      ("y"
-       "Pull string from kill ring"
-       isearch-yank-kill
-       :transient nil)
-      ("t"
-       "Pull thing from buffer"
-       isearch-forward-thing-at-point
-       :transient nil)]
-
-     ["Replace"
-      ("q"
-       "Start ‘query-replace’"
-       anzu-isearch-query-replace
-       :if-nil buffer-read-only
-       :transient nil)
-      ("x"
-       "Start ‘query-replace-regexp’"
-       anzu-isearch-query-replace-regexp
-       :if-nil buffer-read-only
-       :transient nil)]]
-
-    [["Toggle"
-      ("X"
-       "Toggle regexp searching"
-       isearch-toggle-regexp
-       :transient nil)
-      ("S"
-       "Toggle symbol searching"
-       isearch-toggle-symbol
-       :transient nil)
-      ("W"
-       "Toggle word searching"
-       isearch-toggle-word
-       :transient nil)
-      ("F"
-       "Toggle case fold"
-       isearch-toggle-case-fold
-       :transient nil)
-      ("L"
-       "Toggle lax whitespace"
-       isearch-toggle-lax-whitespace
-       :transient nil)]
-
-     ["Misc"
-      ("o"
-       "occur"
-       isearch-occur
-       :transient nil)
-      ("h"
-       "highlight"
-       isearch-highlight-regexp
-       :transient nil)
-      ("H"
-       "highlight lines"
-       isearch-highlight-lines-matching-regexp
-       :transient nil)
-      ("l"
-       "consult-line"
-       consult-line
-       :transient nil)
-      ("<"
-       "isearch-beginning-of-buffer"
-       isearch-beginning-of-buffer
-       :transient nil)
-      (">"
-       "isearch-end-of-buffer"
-       isearch-end-of-buffer
-       :transient nil)]])
-
   :custom
   (search-whitespace-regexp ".*\\b")
   (isearch-lax-whitespace t)
@@ -112,16 +23,25 @@
   (isearch-lazy-count t)
   (lazy-count-prefix-format nil)
   (lazy-count-suffix-format "   (%s/%s)")
+  (lazy-highlight-initial-delay 0)
   (isearch-message-properties '(read-only t cursor-intangible t face isearch-prompt))
   :bind-keymap ("C-c s" . search-map) ;; M-s clashes with paredit/smartparens bindings
   :bind
-  ("C-*" . isearch-forward-symbol-at-point)
-  (:map isearch-mode-map ("<f2>" . isearch-menu))
   (:map search-map
-        ("M-s M-<" . isearch-beginning-of-buffer)
-        ("M-s M->" . isearch-end-of-buffer)
-        ("C-c s M-<" . isearch-beginning-of-buffer)
-        ("C-c s M->" . isearch-end-of-buffer)))
+        ("<" . isearch-beginning-of-buffer)
+        (">" . isearch-end-of-buffer)))
+
+(use-feature casual-isearch
+  :after isearch
+  :bind (:map isearch-mode-map ("C-o" . casual-isearch-tmenu))
+  :config
+  ;; Replace isearch-query-replace functions with their aznu equivalents
+  (transient-replace-suffix 'casual-isearch-tmenu "r" '("r" "Start ‘anzu-query-replace’" anzu-isearch-query-replace
+                                                        :if-nil buffer-read-only))
+  (transient-replace-suffix 'casual-isearch-tmenu "x" '("x" "Start ‘anzu-query-replace-regexp’" anzu-isearch-query-replace-regexp
+                                                        :if-nil buffer-read-only))
+  ;; Add consult-line to Misc section
+  (transient-append-suffix 'casual-isearch-tmenu "u" '("l" "consult-line" consult-line)))
 
 (use-package isearch-dabbrev
   :after isearch
@@ -153,34 +73,32 @@
 
 (use-package deadgrep
   :config
-  (defun deadgrep-symbol-at-point ()
-    (interactive)
-    (deadgrep (thing-at-point 'symbol)))
   (defun deadgrep-current-directory (search-term)
     (interactive (list (deadgrep--read-search-term)))
     (deadgrep search-term (file-name-directory buffer-file-name)))
-  (defvar include-all nil)
+  (defvar deadgrep--include-all nil)
   (defun deadgrep--include-all-advice (rg-args)
-    (if include-all
+    (if deadgrep--include-all
         (push "-uuuLz" rg-args)
       rg-args))
   (advice-add 'deadgrep--arguments :filter-return #'deadgrep--include-all-advice)
   (defun deadgrep-all (search-term)
     (interactive (list (deadgrep--read-search-term)))
-    (let ((include-all t))
+    (let ((deadgrep--include-all t))
       (deadgrep search-term)))
+  :hook (deadgrep-mode . next-error-follow-minor-mode)
   :bind
   ("C-c c d" . deadgrep)
   ("C-c c M-d" . deadgrep-all)
-  ("C-S-z" . deadgrep-symbol-at-point)
   ("C-c c C-d" . deadgrep-current-directory)
   (:map deadgrep-mode-map
-        ("e" . deadgrep-edit-mode))
+        ("e" . deadgrep-edit-mode)
+        ("{" . deadgrep-backward-filename)
+        ("}" . deadgrep-forward-filename))
   (:map search-map
         ("d" . deadgrep)
         ("M-d" . deadgrep-all)
-        ("C-d" . deadgrep-current-directory)
-        ("D" . deadgrep-symbol-at-point)))
+        ("C-d" . deadgrep-current-directory)))
 
 (use-package affe
   :config
@@ -190,28 +108,22 @@
     (setq input (cdr (orderless-compile input)))
     (cons input (apply-partially #'orderless--highlight input t)))
   (setq affe-regexp-compiler #'affe-orderless-regexp-compiler)
-  ;; Manual preview key for `affe-grep'
-  (consult-customize affe-grep :preview-key (kbd "M-."))
-  (defun my/affe-grep-symbol-at-point (&optional dir initial)
-    (interactive
-     (list prefix-arg (when-let ((s (symbol-at-point)))
-                        (symbol-name s))))
-    (affe-grep dir initial))
-  (defun my/affe-find-symbol-at-point (&optional dir initial)
-    (interactive
-     (list prefix-arg (when-let ((s (symbol-at-point)))
-                        (symbol-name s))))
-    (affe-find dir initial))
+  (defalias 'affe-grep-symbol-at-point 'affe-grep)
+  (defalias 'affe-find-symbol-at-point 'affe-find)
+  (consult-customize
+   affe-grep :preview-key "M-."
+   affe-grep-symbol-at-point :initial (thing-at-point 'symbol) :preview-key "M-."
+   affe-find-symbol-at-point :initial (thing-at-point 'symbol) :preview-key "M-.")
   :bind
-  ("C-#" . affe-grep)
+  ("C-c C-#" . affe-grep)
   ("C-c z" . affe-find)
-  ("C-c Z" . my/affe-find-symbol-at-point)
-  ("C-~" . my/affe-grep-symbol-at-point)
+  ("C-c Z" . affe-find-symbol-at-point)
+  ("C-c C-~" . affe-grep-symbol-at-point)
   (:map search-map
         ("#" . affe-grep)
-        ("~" . my/affe-grep-symbol-at-point)
+        ("~" . affe-grep-symbol-at-point)
         ("a" . affe-find)
-        ("A" . my/affe-find-symbol-at-point)))
+        ("A" . affe-find-symbol-at-point)))
 
 (provide 'init-search)
 ;;; init-search.el ends here
diff --git a/.emacs.d/lisp/init-shell.el b/.emacs.d/lisp/init-shell.el
index 8a64d4b..bf737cb 100644
--- a/.emacs.d/lisp/init-shell.el
+++ b/.emacs.d/lisp/init-shell.el
@@ -9,21 +9,31 @@
   (eshell-mode-hook . (lambda () (setenv "TERM" "xterm-256color")))
   :custom
   (eshell-directory-name (expand-file-name "eshell" save-dir))
+  ;; https://lambdaland.org/posts/2024-08-19_fancy_eshell_prompt/#eshell-prompt
+  (eshell-highlight-prompt nil)
+  (eshell-prompt-regexp "^[^#$\n]* [$#] ")
   (eshell-prompt-function
-   ;; Based on https://www.reddit.com/r/emacs/comments/6f0rkz/my_fancy_eshell_prompt/
    (lambda ()
-     (concat
-      (propertize "┌─[" 'face `(:foreground "green"))
-      (propertize (user-login-name) 'face `(:foreground "red"))
-      (propertize "@" 'face `(:foreground "green"))
-      (propertize (system-name) 'face `(:foreground "LightBlue"))
-      (propertize "]──[" 'face `(:foreground "green"))
-      (propertize (format-time-string "%H:%M" (current-time)) 'face `(:foreground "yellow"))
-      (propertize "]──[" 'face `(:foreground "green"))
-      (propertize (concat (eshell/pwd)) 'face `(:foreground "white"))
-      (propertize "]\n" 'face `(:foreground "green"))
-      (propertize "└─>" 'face `(:foreground "green"))
-      (propertize (if (= (user-uid) 0) " # " " $ ") 'face `(:foreground "green")))))
+     (let* ((cwd (abbreviate-file-name (eshell/pwd)))
+            (ref (magit-get-shortname "HEAD"))
+            (stat (magit-file-status))
+            (x-stat eshell-last-command-status)
+            (git-chunk
+             (if ref
+                 (format "%s%s%s "
+                         (propertize (if stat "[" "(") 'font-lock-face (list :foreground (if stat "red" "green")))
+                         (propertize ref 'font-lock-face '(:foreground "yellow"))
+                         (propertize (if stat "]" ")") 'font-lock-face (list :foreground (if stat "red" "green"))))
+               "")))
+       (propertize
+        (format "%s %s %s$ "
+                (if (< 0 x-stat) (format (propertize "!%s" 'font-lock-face '(:foreground "red")) x-stat)
+                  (propertize "➤" 'font-lock-face (list :foreground (if (< 0 x-stat) "red" "green"))))
+                (propertize cwd 'font-lock-face '(:foreground "#45babf"))
+                git-chunk)
+        'read-only t
+        'front-sticky   '(font-lock-face read-only)
+        'rear-nonsticky '(font-lock-face read-only)))))
   :config
   (setenv "PAGER" "cat"))
 
diff --git a/.emacs.d/lisp/init-sql.el b/.emacs.d/lisp/init-sql.el
index d71e73d..cf3a89a 100644
--- a/.emacs.d/lisp/init-sql.el
+++ b/.emacs.d/lisp/init-sql.el
@@ -37,7 +37,7 @@
          (format "SQL history will not be saved because %s is nil"
                  (symbol-name rval))))))
 
-  (add-hook 'sql-interactive-mode-hook 'my-sql-save-history-hook))
+  :hook (sql-interactive-mode . my-sql-save-history-hook))
 
 
 (use-package sqlup-mode
@@ -46,9 +46,10 @@
   :hook
   (sql-mode . sqlup-mode)
   (sql-interactive-mode . sqlup-mode)
-  :bind ("C-c c u" . sqlup-capitalize-keywords-in-region))
+  :bind ("C-c c C-u" . sqlup-capitalize-keywords-in-region))
 
 (use-package sql-indent
+  :diminish sqlind-minor-mode
   :commands sqlind-minor-mode)
 
 (use-package sqlformat
diff --git a/.emacs.d/lisp/init-ui.el b/.emacs.d/lisp/init-ui.el
index cb1c831..50e9cdb 100644
--- a/.emacs.d/lisp/init-ui.el
+++ b/.emacs.d/lisp/init-ui.el
@@ -8,6 +8,8 @@
   :hook
   (elpaca-after-init . (lambda ()
                          (cond
+                          ((find-font (font-spec :name "aporetic serif mono"))
+                           (set-face-attribute 'default nil :font "aporetic serif mono"))
                           ((find-font (font-spec :name "iosevka comfy"))
                            (set-face-attribute 'default nil :font "iosevka comfy"))
                           ((find-font (font-spec :name "iosevka"))
@@ -16,37 +18,11 @@
                          (global-display-line-numbers-mode)
                          (global-hl-line-mode +1)
 
-                         (global-set-key (kbd "C-x C-S-k") 'kill-buffer)
-
                          (add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
                          (load-theme 'non-modo t)))
-  ;; http://yummymelon.com/devnull/enhancing-navigation-in-emacs-view-mode.html
-  (view-mode . (lambda ()
-                 (cond ((derived-mode-p 'org-mode)
-                        (define-key view-mode-map (kbd "p") 'org-previous-visible-heading)
-                        (define-key view-mode-map (kbd "n") 'org-next-visible-heading))
-                       ((derived-mode-p 'markdown-mode)
-                        (define-key view-mode-map (kbd "p") 'markdown-outline-previous)
-                        (define-key view-mode-map (kbd "n") 'markdown-outline-next))
-                       ((derived-mode-p 'html-mode)
-                        (define-key view-mode-map (kbd "p") 'sgml-skip-tag-backward)
-                        (define-key view-mode-map (kbd "n") 'sgml-skip-tag-forward))
-                       ((derived-mode-p 'emacs-lisp-mode)
-                        (define-key view-mode-map (kbd "p") 'backward-sexp)
-                        (define-key view-mode-map (kbd "n") 'forward-sexp))
-                       ((derived-mode-p 'clojure-mode)
-                        (define-key view-mode-map (kbd "p") 'backward-sexp)
-                        (define-key view-mode-map (kbd "n") 'forward-sexp))
-                       ((derived-mode-p 'makefile-mode)
-                        (define-key view-mode-map (kbd "p") 'makefile-previous-dependency)
-                        (define-key view-mode-map (kbd "n") 'makefile-next-dependency))
-                       ((derived-mode-p 'c-mode)
-                        (define-key view-mode-map (kbd "p") 'c-beginning-of-defun)
-                        (define-key view-mode-map (kbd "n") 'c-end-of-defun))
-                       (t
-                        (define-key view-mode-map (kbd "p") 'scroll-down-command)
-                        (define-key view-mode-map (kbd "n") 'scroll-up-command)))))
+  :bind ("C-x C-S-k" . kill-buffer)
   :config
+  (setq-default display-line-numbers-widen t)
   ;; https://github.com/rougier/elegant-emacs/blob/master/sanity.el
   (setq inhibit-startup-screen t
         inhibit-startup-echo-area-message t
@@ -65,13 +41,22 @@
                              (run-with-timer 0.05 nil 'invert-face 'mode-line))
         visible-bell t)
 
-  ;; TODO do we want these? (copied from prelude)
+  ;; A combination of settings from prelude and minimal-emacs.d, may need tweaking
   (setq scroll-margin 0
         scroll-conservatively 100000
-        scroll-preserve-screen-position 1)
+        scroll-preserve-screen-position 1
+        hscroll-margin 2
+        hscroll-step 1
+        auto-window-vscroll nil)
   (setq pixel-scroll-precision-mode t)
+  (setq-default word-wrap t
+                truncate-lines t
+                fill-column 80)
+  ;; If enabled and `truncate-lines' is disabled, soft wrapping will not occur
+  ;; when the window is narrower than `truncate-partial-width-windows' characters.
+  (setq truncate-partial-width-windows nil)
 
-  (fset 'yes-or-no-p 'y-or-n-p)
+  (setq use-short-answers t)
 
   (setq frame-title-format
         '("Emacs: " (:eval (if (buffer-file-name)
@@ -79,9 +64,41 @@
                              "%b"))))
 
   (when (eq system-type 'darwin)
-    (setq mac-option-modifier 'meta)
-    (setq mac-right-option-modifier 'none)
-    (setq mac-command-modifier 'super)))
+    (setq mac-option-modifier 'meta
+          mac-right-option-modifier 'none)
+    ;; After swapping control and command, this works nicely,
+    ;; otherwise use (setq mac-command-modifier 'super)
+    (setq mac-command-modifier 'control
+          mac-control-modifier 'super)))
+
+(use-feature view
+  ;; http://yummymelon.com/devnull/enhancing-navigation-in-emacs-view-mode.html
+  :hook
+  (view-mode . (lambda ()
+                 (cond ((derived-mode-p 'org-mode)
+                        (define-key view-mode-map (kbd "p") 'org-previous-visible-heading)
+                        (define-key view-mode-map (kbd "n") 'org-next-visible-heading))
+                       ((derived-mode-p 'markdown-mode)
+                        (define-key view-mode-map (kbd "p") 'markdown-outline-previous)
+                        (define-key view-mode-map (kbd "n") 'markdown-outline-next))
+                       ((derived-mode-p 'html-mode)
+                        (define-key view-mode-map (kbd "p") 'sgml-skip-tag-backward)
+                        (define-key view-mode-map (kbd "n") 'sgml-skip-tag-forward))
+                       ((derived-mode-p 'emacs-lisp-mode)
+                        (define-key view-mode-map (kbd "p") 'backward-sexp)
+                        (define-key view-mode-map (kbd "n") 'forward-sexp))
+                       ((derived-mode-p 'clojure-mode)
+                        (define-key view-mode-map (kbd "p") 'backward-sexp)
+                        (define-key view-mode-map (kbd "n") 'forward-sexp))
+                       ((derived-mode-p 'makefile-mode)
+                        (define-key view-mode-map (kbd "p") 'makefile-previous-dependency)
+                        (define-key view-mode-map (kbd "n") 'makefile-next-dependency))
+                       ((derived-mode-p 'c-mode)
+                        (define-key view-mode-map (kbd "p") 'c-beginning-of-defun)
+                        (define-key view-mode-map (kbd "n") 'c-end-of-defun))
+                       (t
+                        (define-key view-mode-map (kbd "p") 'scroll-down-command)
+                        (define-key view-mode-map (kbd "n") 'scroll-up-command))))))
 
 (use-package hl-todo
   :bind
@@ -116,7 +133,7 @@
   (dolist (mode whitespace-disabled-modes)
     (add-hook (intern (concat (symbol-name mode) "-hook")) #'turn-off-whitespace-mode))
   :hook
-  ((text-mode prog-mode) . (lambda () (whitespace-mode +1))))
+  ((text-mode prog-mode) . whitespace-mode))
 
 (use-package goggles
   :diminish
@@ -131,6 +148,9 @@
   :hook (prog-mode . idle-highlight-mode))
 
 (use-feature paren
+  :custom
+  (show-paren-when-point-inside-paren t)
+  (show-paren-when-point-in-periphery t)
   :config
   (show-paren-mode +1))
 
@@ -194,6 +214,9 @@
     ;; Run setup hook for `eval-expression' (calls `eldoc--eval-expression-setup')
     (run-hooks 'eval-expression-minibuffer-setup-hook)
 
+    (mono-complete-mode +1)
+    (setq-local mono-complete-fallback-command 'dabbrev-expand)
+
     ;; smartparens, but don't insert pairs of '
     (smartparens-strict-mode)
     (setq-local sp-pair-list (assoc-delete-all "'" sp-pair-list))
@@ -217,5 +240,8 @@
   (set-face-foreground 'highlight-indent-guides-character-face "grey25")
   :hook ((prog-mode text-mode conf-mode) . highlight-indent-guides-mode))
 
+;; Main causal collection package; the individual packages are configured in the appropriate places
+(use-package casual)
+
 (provide 'init-ui)
 ;;; init-ui.el ends here
diff --git a/.emacs.d/lisp/init-windows.el b/.emacs.d/lisp/init-windows.el
index fcf39cc..15ec232 100644
--- a/.emacs.d/lisp/init-windows.el
+++ b/.emacs.d/lisp/init-windows.el
@@ -5,11 +5,8 @@
 (use-feature emacs
   :custom
   (switch-to-buffer-obey-display-actions t)
-  :config
-  (defcustom large-frame-width-threshold 500
-    "Minimum width (in chars) to consider the frame large."
-    :group 'djm
-    :type 'natnum))
+  (split-height-threshold nil)
+  (split-width-threshold 200))
 
 (use-feature ibuffer
   :bind
@@ -22,7 +19,8 @@
         ("$" . ibuffer-toggle-filter-group))
   :hook (ibuffer-mode . ibuffer-auto-mode))
 
-(use-package casual-ibuffer
+(use-feature casual-ibuffer
+  :after ibuffer
   :bind (:map ibuffer-mode-map
               ("C-o" . casual-ibuffer-tmenu)
               ("F" . casual-ibuffer-filter-tmenu)
@@ -30,6 +28,7 @@
 
 (use-feature winner
   :defer 5
+  :custom (winner-boring-buffers-regexp "\*Minibuf-[0-9]+")
   :config
   (winner-mode +1)
   (defvar winner-repeat-map
@@ -66,16 +65,7 @@
   (fullframe elpaca-fetch-all quit-window))
 
 (use-package transpose-frame
-  :bind (:map ctl-x-4-map ("t" . transpose-frame))
-  :config
-  (defun transpose-large-frame ()
-    "Trasnpose the window arrangement, if the frame is large.
-
-This is based on the frame width, with the threshold being customised using
-`large-frame-width-threshold'."
-    (when (> large-frame-width-threshold (frame-char-width)) (transpose-frame)))
-  :hook
-  (cider-connected . transpose-large-frame))
+  :bind (:map ctl-x-4-map ("t" . transpose-frame)))
 
 (use-package ace-window
   :diminish
@@ -152,7 +142,7 @@ This is based on the frame width, with the threshold being customised using
                                           ("P" "[project]" frog-jump-buffer-filter-same-project)
                                           ("S" "[similar]" frog-jump-buffer-filter-similar-name)))
   :bind
-  ("C-," . frog-jump-buffer)
+  ("C-c C-," . frog-jump-buffer)
   ("C-x 4 C-," . frog-jump-buffer-other-window))
 
 (use-package buffer-ring