about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--config.org179
1 files changed, 109 insertions, 70 deletions
diff --git a/config.org b/config.org index b23420f..14cc597 100644 --- a/config.org +++ b/config.org
@@ -192,7 +192,7 @@ Let's try settings from [[https://github.com/nex3/perspective-el#some-musings-on
192*** Switch to other window or buffer :crux: 192*** Switch to other window or buffer :crux:
193 193
194#+begin_src emacs-lisp :noweb-ref bindings 194#+begin_src emacs-lisp :noweb-ref bindings
195 (define-key acdw/map (kbd "M-o") #'crux-other-window-or-switch-buffer) 195 (acdw/bind "M-o" #'crux-other-window-or-switch-buffer)
196#+end_src 196#+end_src
197 197
198*** The *Help* window 198*** The *Help* window
@@ -269,7 +269,7 @@ someday.
269#+end_src 269#+end_src
270 270
271#+begin_src emacs-lisp :noweb-ref bindings 271#+begin_src emacs-lisp :noweb-ref bindings
272 (define-key acdw/leader (kbd "C-x") #'scratch) 272 (acdw/bind "C-x" #'scratch :map acdw/leader)
273#+end_src 273#+end_src
274 274
275*** Kill buffers better 275*** Kill buffers better
@@ -294,7 +294,7 @@ someday.
294#+end_src 294#+end_src
295 295
296#+begin_src emacs-lisp :noweb-ref bindings 296#+begin_src emacs-lisp :noweb-ref bindings
297 (define-key acdw/map (kbd "C-x k") #'kill-a-buffer) 297 (acdw/bind "C-x k" #'kill-a-buffer)
298#+end_src 298#+end_src
299 299
300*** Kill old buffers after a while 300*** Kill old buffers after a while
@@ -953,19 +953,15 @@ Let's have =prescient= and =selectrum= work together.
953#+end_src 953#+end_src
954 954
955#+begin_src emacs-lisp :noweb-ref bindings 955#+begin_src emacs-lisp :noweb-ref bindings
956 (with-eval-after-load 'icomplete 956 (acdw/bind-after-map 'icomplete icomplete-minibuffer-map
957 (define-key icomplete-minibuffer-map (kbd "<down>") 957 (("<down>" #'icomplete-forward-completions)
958 #'icomplete-forward-completions) 958 ("C-n" #'icomplete-forward-completions)
959 (define-key icomplete-minibuffer-map (kbd "C-n") 959 ("<up>" #'icomplete-backward-completions)
960 #'icomplete-forward-completions) 960 ("C-p" #'icomplete-backward-completions)))
961 (define-key icomplete-minibuffer-map (kbd "<up>")
962 #'icomplete-backward-completions)
963 (define-key icomplete-minibuffer-map (kbd "C-p")
964 #'icomplete-backward-completions))
965 961
966 (with-eval-after-load 'icomplete-vertical 962 (acdw/bind "C-v" #'icomplete-vertical-toggle
967 (define-key icomplete-minibuffer-map (kbd "C-v") 963 :after 'icomplete-vertical
968 #'icomplete-vertical-toggle)) 964 :map icomplete-minibuffer-map)
969#+end_src 965#+end_src
970 966
971#+begin_src emacs-lisp :noweb-ref modes 967#+begin_src emacs-lisp :noweb-ref modes
@@ -997,39 +993,39 @@ Consult has a lot of great bindings that work well with Emacs's
997default completion system. These all come from the [[https://github.com/minad/consult#configuration][example configuration]]. 993default completion system. These all come from the [[https://github.com/minad/consult#configuration][example configuration]].
998 994
999#+begin_src emacs-lisp :noweb-ref bindings 995#+begin_src emacs-lisp :noweb-ref bindings
1000 (with-eval-after-load 'consult 996 (acdw/bind-after-map 'consult acdw/map
1001 ;; C-c bindings (`mode-specific-map') 997 ;; C-c bindings (`mode-specific-map')
1002 (define-key acdw/map (kbd "C-c h") #'consult-history) 998 (("C-c h" #'consult-history)
1003 (define-key acdw/map (kbd "C-c m") #'consult-mode-command) 999 ("C-c m" #'consult-mode-command)
1004 ;; C-x bindings (`ctl-x-map') 1000 ;; C-x bindings (`ctl-x-map')
1005 (define-key acdw/map (kbd "C-x M-:") #'consult-complex-command) 1001 ("C-x M-:" #'consult-complex-command)
1006 (define-key acdw/map (kbd "C-x b") #'consult-buffer) 1002 ("C-x b" #'consult-buffer)
1007 (define-key acdw/map (kbd "C-x 4 b") #'consult-buffer-other-window) 1003 ("C-x 4 b" #'consult-buffer-other-window)
1008 (define-key acdw/map (kbd "C-x 5 b") #'consult-buffer-other-frame) 1004 ("C-x 5 b" #'consult-buffer-other-frame)
1009 (define-key acdw/map (kbd "C-x r x") #'consult-register) 1005 ("C-x r x" #'consult-register)
1010 (define-key acdw/map (kbd "C-x r b") #'consult-bookmark) 1006 ("C-x r b" #'consult-bookmark)
1011 ;; M-g bindings (`goto-map') 1007 ;; M-g bindings (`goto-map')
1012 (define-key acdw/map (kbd "M-g g") #'consult-line) 1008 ("M-g g" #'consult-line)
1013 (define-key acdw/map (kbd "M-g M-g") #'consult-line) 1009 ("M-g M-g" #'consult-line)
1014 (define-key acdw/map (kbd "M-g o") #'consult-outline) 1010 ("M-g o" #'consult-outline)
1015 (define-key acdw/map (kbd "M-g m") #'consult-mark) 1011 ("M-g m" #'consult-mark)
1016 (define-key acdw/map (kbd "M-g k") #'consult-global-mark) 1012 ("M-g k" #'consult-global-mark)
1017 (define-key acdw/map (kbd "M-g i") #'consult-imenu) 1013 ("M-g i" #'consult-imenu)
1018 (define-key acdw/map (kbd "M-g e") #'consult-error) 1014 ("M-g e" #'consult-error)
1019 ;; M-s bindings (`search-map') 1015 ;; M-s bindings (`search-map')
1020 (define-key acdw/map (kbd "M-s g") #'consult-grep) ; alts: 1016 ("M-s g" #'consult-grep) ; alts:
1021 ; consult-git-grep, 1017 ; consult-git-grep,
1022 ; consult-ripgrep 1018 ; consult-ripgrep
1023 (define-key acdw/map (kbd "M-s f") #'consult-find) ; alts: 1019 ("M-s f" #'consult-find) ; alts:
1024 ; consult-locate 1020 ; consult-locate
1025 (define-key acdw/map (kbd "M-s l") #'consult-line) 1021 ("M-s l" #'consult-line)
1026 (define-key acdw/map (kbd "M-s m") #'consult-multi-occur) 1022 ("M-s m" #'consult-multi-occur)
1027 (define-key acdw/map (kbd "M-s k") #'consult-keep-lines) 1023 ("M-s k" #'consult-keep-lines)
1028 (define-key acdw/map (kbd "M-s u") #'consult-focus-lines) 1024 ("M-s u" #'consult-focus-lines)
1029 ;; Other bindings 1025 ;; Other bindings
1030 (define-key acdw/map (kbd "M-y") #'consult-yank-pop) 1026 ("M-y" #'consult-yank-pop)
1031 (define-key acdw/map (kbd "<f1> a") #'consult-apropos) 1027 ("<f1> a" #'consult-apropos)
1032 (define-key acdw/map (kbd "C-h a") #'consult-apropos)) 1028 ("C-h a" #'consult-apropos)))
1033#+end_src 1029#+end_src
1034 1030
1035#+begin_src emacs-lisp :noweb-ref settings 1031#+begin_src emacs-lisp :noweb-ref settings
@@ -1084,7 +1080,7 @@ Before I install any completion framework, I want a good default for
1084completing. =hippie-expand= fills that niche. 1080completing. =hippie-expand= fills that niche.
1085 1081
1086#+begin_src emacs-lisp :noweb-ref bindings 1082#+begin_src emacs-lisp :noweb-ref bindings
1087 (define-key acdw/map (kbd "M-/") #'hippie-expand) 1083 (acdw/bind "M-/" #'hippie-expand)
1088#+end_src 1084#+end_src
1089 1085
1090** Bindings 1086** Bindings
@@ -1113,6 +1109,49 @@ on as I please.
1113 (blackout 'acdw/mode) 1109 (blackout 'acdw/mode)
1114#+end_src 1110#+end_src
1115 1111
1112*** =acdw/bind= macro
1113
1114Since defining keys can be a chore, I've written this macro to make it just a
1115/little/ bit easier. It's /not/ as comprehensive as =bind-key=, but it's just a
1116little sugar on top of =define-key= et al.
1117
1118#+begin_src emacs-lisp :noweb-ref functions
1119 (defmacro acdw/bind (key def &rest args)
1120 "A simple key-binding macro that takes care of the annoying stuff.
1121
1122 If KEY is a vector, it's passed directly to `define-key',
1123 otherwise it wraps it in `kbd'. It does NOT quote any
1124 definitions, because I like to keep those explicit in the
1125 definitions.
1126
1127 The following keywords are recognized:
1128
1129 :after PACKAGE-OR-FEATURE .. wrap key definition in `with-eval-after-load'
1130 :map KEYMAP .. define key in KEYMAP instead of `acdw/map'"
1131 (let* ((after (plist-get args :after))
1132 (map (or (plist-get args :map) 'acdw/map))
1133 (key (if (vectorp key) key `(kbd ,key)))
1134 (def-key `(define-key ,map ,key ,def)))
1135 (if after
1136 `(with-eval-after-load ,after
1137 ,def-key)
1138 def-key)))
1139
1140 (defmacro acdw/bind-after-map (feature keymap bindings)
1141 "Wrap multiple calls to `acdw/bind' in a `with-eval-after-load' form.
1142
1143 FEATURE is the argument to `with-eval-after-load'. KEYMAP is
1144 passed to the `:map' argument of `acdw/bind', if it's non-nil."
1145 (declare (indent 2))
1146 (let (bind-list)
1147 (dolist (bind bindings bind-list)
1148 (if keymap
1149 (push `(acdw/bind ,@bind :map ,keymap) bind-list)
1150 (push `(acdw/bind ,@bind) bind-list)))
1151 `(with-eval-after-load ,feature
1152 ,@bind-list)))
1153#+end_src
1154
1116**** Turn off acdw/mode in the minibuffer 1155**** Turn off acdw/mode in the minibuffer
1117 1156
1118#+begin_src emacs-lisp :noweb-ref acdw-mode 1157#+begin_src emacs-lisp :noweb-ref acdw-mode
@@ -1464,7 +1503,7 @@ that I /literally/ never use. So I'm going to bind it to =find-file= ... since
1464that's the only time I accidentally call it, anyway. 1503that's the only time I accidentally call it, anyway.
1465 1504
1466#+begin_src emacs-lisp :noweb-ref bindings 1505#+begin_src emacs-lisp :noweb-ref bindings
1467 (define-key acdw/map (kbd "C-x f") #'find-file) 1506 (acdw/bind "C-x f" #'find-file)
1468#+end_src 1507#+end_src
1469 1508
1470*** Auto-fill vs. Visual-line 1509*** Auto-fill vs. Visual-line
@@ -1621,7 +1660,7 @@ see also
1621#+end_src 1660#+end_src
1622 1661
1623#+begin_src emacs-lisp :noweb-ref bindings 1662#+begin_src emacs-lisp :noweb-ref bindings
1624 (define-key acdw/map (kbd "C-=") #'er/expand-region) 1663 (acdw/bind "C-=" #'er/expand-region)
1625#+end_src 1664#+end_src
1626 1665
1627*** Pulse the modified region with goggles 1666*** Pulse the modified region with goggles
@@ -1649,8 +1688,8 @@ see also
1649#+end_src 1688#+end_src
1650 1689
1651#+begin_src emacs-lisp :noweb-ref bindings 1690#+begin_src emacs-lisp :noweb-ref bindings
1652 (define-key acdw/map (kbd "C-/") #'undo-fu-only-undo) 1691 (acdw/bind "C-/" #'undo-fu-only-undo)
1653 (define-key acdw/map (kbd "C-?") #'undo-fu-only-redo) 1692 (acdw/bind "C-?" #'undo-fu-only-redo)
1654#+end_src 1693#+end_src
1655 1694
1656*** Undo Fu session 1695*** Undo Fu session
@@ -1719,13 +1758,13 @@ I've switched =query-replace= and =query-replace-regexp= with their anzu
1719versions, because of the regex thing. 1758versions, because of the regex thing.
1720 1759
1721#+begin_src emacs-lisp :noweb-ref bindings 1760#+begin_src emacs-lisp :noweb-ref bindings
1722 (define-key acdw/map [remap query-replace] #'anzu-query-replace-regexp) 1761 (acdw/bind-after-map 'anzu nil
1723 (define-key acdw/map [remap query-replace-regexp] #'anzu-query-replace) 1762 (([remap query-replace] #'anzu-query-replace-regexp)
1724 1763 ([remap query-replace-regexp] #'anzu-query-replace)
1725 (define-key isearch-mode-map [remap isearch-query-replace] 1764 ([remap isearch-query-replace] #'anzu-isearch-query-replace
1726 #'anzu-isearch-query-replace) 1765 :map isearch-mode-map)
1727 (define-key isearch-mode-map [remap isearch-query-replace-regexp] 1766 ([remap isearch-query-replace-regexp] #'anzu-isearch-query-replace-regexp
1728 #'anzu-isearch-query-replace-regexp) 1767 :map isearch-mode-map)))
1729#+end_src 1768#+end_src
1730 1769
1731** Commenting :crux: 1770** Commenting :crux:
@@ -1739,7 +1778,7 @@ already commented. That's it.
1739#+end_src 1778#+end_src
1740 1779
1741#+begin_src emacs-lisp :noweb-ref bindings 1780#+begin_src emacs-lisp :noweb-ref bindings
1742 (define-key acdw/map (kbd "M-;") #'comment-or-uncomment-region) 1781 (acdw/bind "M-;" #'comment-or-uncomment-region)
1743#+end_src 1782#+end_src
1744 1783
1745* Writing 1784* Writing
@@ -1772,7 +1811,7 @@ I just found out that =M-== counts the words in a region. That's great, but I
1772often want to count the words in the whole buffer. 1811often want to count the words in the whole buffer.
1773 1812
1774#+begin_src emacs-lisp :noweb-ref bindings 1813#+begin_src emacs-lisp :noweb-ref bindings
1775 (define-key acdw/map (kbd "M-=") #'count-words) 1814 (acdw/bind "M-=" #'count-words)
1776#+end_src 1815#+end_src
1777 1816
1778** Spell checking 1817** Spell checking
@@ -1813,8 +1852,9 @@ Display corrections with =completing-read=.
1813#+end_src 1852#+end_src
1814 1853
1815#+begin_src emacs-lisp :noweb-ref bindings 1854#+begin_src emacs-lisp :noweb-ref bindings
1816 (with-eval-after-load 'flyspell 1855 (acdw/bind "C-;" #'flyspell-correct-wrapper
1817 (define-key flyspell-mode-map (kbd "C-;") #'flyspell-correct-wrapper)) 1856 :after 'flyspell
1857 :map flyspell-mode-map)
1818#+end_src 1858#+end_src
1819 1859
1820* Reading 1860* Reading
@@ -2108,7 +2148,7 @@ move up a directory with a keybinding, I'll change =-a= to =-A=.
2108#+end_src 2148#+end_src
2109 2149
2110#+begin_src emacs-lisp :noweb-ref bindings 2150#+begin_src emacs-lisp :noweb-ref bindings
2111 (define-key acdw/map (kbd "C-x C-j") #'dired-jump) 2151 (acdw/bind "C-x C-j" #'dired-jump)
2112#+end_src 2152#+end_src
2113 2153
2114*** Expand subtrees :package: 2154*** Expand subtrees :package:
@@ -2121,8 +2161,7 @@ enables me to open them in the same buffer, fancily indented.
2121#+end_src 2161#+end_src
2122 2162
2123#+begin_src emacs-lisp :noweb-ref bindings 2163#+begin_src emacs-lisp :noweb-ref bindings
2124 (with-eval-after-load 'dired 2164 (acdw/bind "i" #'dired-subtree-toggle :after 'dired :map dired-mode-map)
2125 (define-key dired-mode-map "i" #'dired-subtree-toggle))
2126#+end_src 2165#+end_src
2127 2166
2128*** Collapse singleton directories :package: 2167*** Collapse singleton directories :package:
@@ -2147,7 +2186,7 @@ that one item is.
2147#+end_src 2186#+end_src
2148 2187
2149#+begin_src emacs-lisp :noweb-ref bindings 2188#+begin_src emacs-lisp :noweb-ref bindings
2150 (define-key acdw/leader "g" #'magit-status) 2189 (acdw/bind "g" #'magit-status :map acdw/leader)
2151#+end_src 2190#+end_src
2152 2191
2153**** Use =~/.authinfo= for passwords 2192**** Use =~/.authinfo= for passwords
@@ -2298,7 +2337,7 @@ See [[https://github.com/redguardtoo/mastering-emacs-in-one-year-guide/blob/mast
2298#+end_src 2337#+end_src
2299 2338
2300#+begin_src emacs-lisp :noweb-ref bindings 2339#+begin_src emacs-lisp :noweb-ref bindings
2301 (define-key acdw/leader "f" #'elfeed) 2340 (acdw/bind "f" #'elfeed :map acdw/leader)
2302#+end_src 2341#+end_src
2303 2342
2304**** Elfeed feeds 2343**** Elfeed feeds
@@ -2499,11 +2538,11 @@ others.
2499#+end_src 2538#+end_src
2500 2539
2501#+begin_src emacs-lisp :noweb-ref bindings 2540#+begin_src emacs-lisp :noweb-ref bindings
2502 (with-eval-after-load 'elpher 2541 (acdw/bind-after-map 'elpher elpher-mode-map
2503 (define-key elpher-mode-map "n" #'elpher-next-link) 2542 (("n" #'elpher-next-link)
2504 (define-key elpher-mode-map "p" #'elpher-prev-link) 2543 ("p" #'elpher-prev-link)
2505 (define-key elpher-mode-map "o" #'elpher-follow-current-link) 2544 ("o" #'elpher-follow-current-link)
2506 (define-key elpher-mode-map "G" #'elpher-go-current)) 2545 ("G" #'elpher-go-current)))
2507#+end_src 2546#+end_src
2508 2547
2509#+begin_src emacs-lisp :noweb-ref hooks 2548#+begin_src emacs-lisp :noweb-ref hooks