summary refs log tree commit diff stats
path: root/init.el
diff options
context:
space:
mode:
Diffstat (limited to 'init.el')
-rw-r--r--init.el120
1 files changed, 76 insertions, 44 deletions
diff --git a/init.el b/init.el index 99b7645..cf69c1b 100644 --- a/init.el +++ b/init.el
@@ -96,15 +96,17 @@
96 (global-auto-revert-mode +1)) 96 (global-auto-revert-mode +1))
97 97
98(setup browse-url 98(setup browse-url
99 (setq-default browse-url-browser-function 'eww-browse-url 99 (when (acdw/system :work)
100 (add-to-list 'exec-path "C:/Program Files/Mozilla Firefox"))
101
102 (setq-default browse-url-browser-function ; can be alist (regex . function)
103 '(("." . eww-browse-url))
100 browse-url-secondary-browser-function 104 browse-url-secondary-browser-function
101 (if (executable-find "firefox") 105 (if (executable-find "firefox") ; prefer Firefox
102 'browse-url-firefox 106 'browse-url-firefox
103 'browse-url-default-browser) 107 'browse-url-default-browser)
104 browse-url-new-window-flag t 108 browse-url-new-window-flag t
105 browse-url-firefox-new-window-is-tab t) 109 browse-url-firefox-new-window-is-tab t))
106 (when (acdw/system :work)
107 (add-to-list 'exec-path "C:/Program Files/Mozilla Firefox")))
108 110
109(setup buffers 111(setup buffers
110 (:global "C-x k" acdw/kill-a-buffer)) 112 (:global "C-x k" acdw/kill-a-buffer))
@@ -112,12 +114,6 @@
112(setup completion 114(setup completion
113 (:option completion-ignore-case t 115 (:option completion-ignore-case t
114 read-buffer-completion-ignore-case t 116 read-buffer-completion-ignore-case t
115 icomplete-delay-completions-threshold 0
116 icomplete-max-delay-chars 0
117 icomplete-compute-delay 0
118 icomplete-show-matches-on-no-input t
119 icomplete-with-buffer-completion-tables t
120 icomplete-in-buffer t
121 completion-styles '(partial-completion substring flex) 117 completion-styles '(partial-completion substring flex)
122 completion-category-defaults nil 118 completion-category-defaults nil
123 completion-category-overrides 119 completion-category-overrides
@@ -259,7 +255,8 @@
259 255
260(setup eshell 256(setup eshell
261 (:option eshell-directory-name (acdw/dir "eshell/" t) 257 (:option eshell-directory-name (acdw/dir "eshell/" t)
262 eshell-aliases-file (acdw/dir "eshell/aliases" t)) 258 eshell-aliases-file (acdw/dir "eshell/aliases" t)
259 eshell-kill-on-exit nil)
263 260
264 (defun eshell-quit-or-delete-char (arg) 261 (defun eshell-quit-or-delete-char (arg)
265 "Delete the character to the right, or quit eshell on an empty line." 262 "Delete the character to the right, or quit eshell on an empty line."
@@ -268,10 +265,16 @@
268 (eshell-life-is-too-much) 265 (eshell-life-is-too-much)
269 (delete-forward-char arg))) 266 (delete-forward-char arg)))
270 267
271 (global-set-key (kbd "<f12>") #'eshell) 268 (defun eshell-pop-or-quit (&optional buffer-name)
269 "Pop open an eshell buffer, or if in an eshell buffer, bury it."
270 (interactive)
271 (if (eq (current-buffer) (get-buffer (or buffer-name "*eshell*")))
272 (eshell-life-is-too-much)
273 (eshell)))
274
275 (:leader "s" eshell-pop-or-quit)
272 276
273 (hook-defun eshell-setup 'eshell-mode-hook 277 (hook-defun eshell-setup 'eshell-mode-hook
274 (define-key eshell-mode-map (kbd "<f12>") #'bury-buffer)
275 (define-key eshell-mode-map (kbd "C-d") #'eshell-quit-or-delete-char) 278 (define-key eshell-mode-map (kbd "C-d") #'eshell-quit-or-delete-char)
276 (when (boundp 'simple-modeline--mode-line) 279 (when (boundp 'simple-modeline--mode-line)
277 (setq mode-line-format '(:eval simple-modeline--mode-line))))) 280 (setq mode-line-format '(:eval simple-modeline--mode-line)))))
@@ -308,15 +311,18 @@
308 (unless (file-exists-p ispell-personal-dictionary) 311 (unless (file-exists-p ispell-personal-dictionary)
309 (write-region "" nil ispell-personal-dictionary nil 0)) 312 (write-region "" nil ispell-personal-dictionary nil 0))
310 313
311 (defun flyspell-start () 314 (defun flyspell-start (&optional dont-warn-when-unknown-mode)
312 "Start `flyspell-mode' or `flyspell-prog-mode', depending on current mode." 315 "Start `flyspell-mode' or `flyspell-prog-mode', depending on current mode."
313 (interactive) 316 (interactive)
314 (cond ((derived-mode-p 'text-mode) 317 (cond ((derived-mode-p 'text-mode)
315 (flyspell-mode)) 318 (flyspell-mode))
316 ((derived-mode-p 'prog-mode) 319 ((derived-mode-p 'prog-mode)
317 (flyspell-prog-mode)) 320 (flyspell-prog-mode))
318 (t (message "Non-text or -prog mode. Run `flyspell-mode'.")))) 321 ((not dont-warn-when-unknown-mode) ; god this is ugly
319 (:leader "s" flyspell-start) 322 (message "Non-text or -prog mode. Run `flyspell-mode'."))))
323
324 (when (acdw/system :home)
325 (flyspell-start t))
320 326
321 (:when-loaded 327 (:when-loaded
322 (setup (:straight flyspell-correct) 328 (setup (:straight flyspell-correct)
@@ -366,6 +372,9 @@
366(setup imenu 372(setup imenu
367 (:option imenu-auto-rescan t)) 373 (:option imenu-auto-rescan t))
368 374
375(setup Info
376 (:hook variable-pitch-mode))
377
369(setup isearch 378(setup isearch
370 (:option search-default-mode t)) 379 (:option search-default-mode t))
371 380
@@ -562,6 +571,14 @@
562 (:hook flymake-mode 571 (:hook flymake-mode
563 flymake-shellcheck-load))) 572 flymake-shellcheck-load)))
564 573
574(setup shell-command
575 (:option shell-command-switch (acdw/system
576 ;; I should be testing on some variable
577 (:home "-csi")
578 (:work "-c"))
579 shell-command-prompt-show-cwd t
580 shell-command-default-error-buffer "*shell-command-errors*"))
581
565(setup shr 582(setup shr
566 (:option shr-width fill-column 583 (:option shr-width fill-column
567 shr-max-width fill-column 584 shr-max-width fill-column
@@ -580,6 +597,9 @@
580 uniquify-after-kill-buffer-p t 597 uniquify-after-kill-buffer-p t
581 uniquify-ignore-buffers-re "^\\*")) 598 uniquify-ignore-buffers-re "^\\*"))
582 599
600(setup variable-pitch-mode
601 (:hook acdw-fonts/adapt-variable-pitch))
602
583(setup view 603(setup view
584 (:option view-read-only t) 604 (:option view-read-only t)
585 605
@@ -944,7 +964,11 @@ if ripgrep is installed, otherwise `consult-grep'."
944 (:bind "RET" acdw-org/return-dwim 964 (:bind "RET" acdw-org/return-dwim
945 "<S-return>" acdw-org/org-table-copy-down) 965 "<S-return>" acdw-org/org-table-copy-down)
946 966
947 (add-hook 'before-save-hook #'acdw-org/fix-blank-lines-in-buffer) 967 (defun acdw/org-fix-lines-before-save ()
968 (add-hook 'before-save-hook #'acdw-org/fix-blank-lines-in-buffer 0 :local))
969
970 (:hook variable-pitch-mode
971 acdw/org-fix-lines-before-save)
948 972
949 (advice-add 'org-delete-backward-char 973 (advice-add 'org-delete-backward-char
950 :override #'acdw-org/delete-backward-char)) 974 :override #'acdw-org/delete-backward-char))
@@ -981,19 +1005,21 @@ if ripgrep is installed, otherwise `consult-grep'."
981 1005
982(setup (:straight simple-modeline) 1006(setup (:straight simple-modeline)
983 (setup (:straight minions)) 1007 (setup (:straight minions))
984 (:option simple-modeline-segments 1008 (:option
985 '((acdw-modeline/modified 1009 ;; `acdw-org/count-words' is too slow to use in the modeline.
986 acdw-modeline/buffer-name 1010 ;; (prepend acdw-modeline/word-count-modes) '(org-mode . acdw-org/count-words)
987 acdw-modeline/vc-branch 1011 simple-modeline-segments '((acdw-modeline/modified
988 simple-modeline-segment-position 1012 acdw-modeline/buffer-name
989 simple-modeline-segment-word-count) 1013 acdw-modeline/vc-branch
990 (simple-modeline-segment-misc-info 1014 simple-modeline-segment-position)
991 acdw-modeline/winum 1015 (simple-modeline-segment-misc-info
992 acdw-modeline/text-scale 1016 acdw-modeline/word-count
993 simple-modeline-segment-process 1017 acdw-modeline/winum
994 acdw-modeline/god-mode-indicator 1018 acdw-modeline/text-scale
995 acdw-modeline/minions 1019 simple-modeline-segment-process
996 simple-modeline-segment-major-mode))) 1020 acdw-modeline/god-mode-indicator
1021 acdw-modeline/minions
1022 simple-modeline-segment-major-mode)))
997 1023
998 (require 'acdw-modeline) 1024 (require 'acdw-modeline)
999 (simple-modeline-mode +1)) 1025 (simple-modeline-mode +1))
@@ -1070,21 +1096,27 @@ if ripgrep is installed, otherwise `consult-grep'."
1070 (global-whitespace-cleanup-mode +1)) 1096 (global-whitespace-cleanup-mode +1))
1071 1097
1072(setup (:straight winum) 1098(setup (:straight winum)
1073 (:option winum-auto-setup-mode-line nil 1099 (:option winum-scope 'frame-local
1100 winum-auto-setup-mode-line nil
1074 winum-ignored-buffers '(" *which-key*")) 1101 winum-ignored-buffers '(" *which-key*"))
1075 1102
1076 (when (display-graphic-p) 1103 (when-unfocused winum-map-keys
1077 (:with-map winum-keymap 1104 (defvar winum--keys-mapped nil
1078 (:bind "M-0" winum-select-window-0-or-10 1105 "Whether `winum' keys have been mapped already.")
1079 "M-1" winum-select-window-1 1106 (when (and (not winum--keys-mapped)
1080 "M-2" winum-select-window-2 1107 (display-graphic-p))
1081 "M-3" winum-select-window-3 1108 (:with-map winum-keymap
1082 "M-4" winum-select-window-4 1109 (:bind "M-0" winum-select-window-0-or-10
1083 "M-5" winum-select-window-5 1110 "M-1" winum-select-window-1
1084 "M-6" winum-select-window-6 1111 "M-2" winum-select-window-2
1085 "M-7" winum-select-window-7 1112 "M-3" winum-select-window-3
1086 "M-8" winum-select-window-8 1113 "M-4" winum-select-window-4
1087 "M-9" winum-select-window-9))) 1114 "M-5" winum-select-window-5
1115 "M-6" winum-select-window-6
1116 "M-7" winum-select-window-7
1117 "M-8" winum-select-window-8
1118 "M-9" winum-select-window-9))
1119 (setq winum--keys-mapped t)))
1088 1120
1089 (winum-mode +1)) 1121 (winum-mode +1))
1090 1122