about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--init.el92
-rw-r--r--lisp/acdw-fonts.el45
2 files changed, 106 insertions, 31 deletions
diff --git a/init.el b/init.el index 3bec384..867f5a0 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)))))
@@ -306,15 +309,18 @@
306 (unless (file-exists-p ispell-personal-dictionary) 309 (unless (file-exists-p ispell-personal-dictionary)
307 (write-region "" nil ispell-personal-dictionary nil 0)) 310 (write-region "" nil ispell-personal-dictionary nil 0))
308 311
309 (defun flyspell-start () 312 (defun flyspell-start (&optional dont-warn-when-unknown-mode)
310 "Start `flyspell-mode' or `flyspell-prog-mode', depending on current mode." 313 "Start `flyspell-mode' or `flyspell-prog-mode', depending on current mode."
311 (interactive) 314 (interactive)
312 (cond ((derived-mode-p 'text-mode) 315 (cond ((derived-mode-p 'text-mode)
313 (flyspell-mode)) 316 (flyspell-mode))
314 ((derived-mode-p 'prog-mode) 317 ((derived-mode-p 'prog-mode)
315 (flyspell-prog-mode)) 318 (flyspell-prog-mode))
316 (t (message "Non-text or -prog mode. Run `flyspell-mode'.")))) 319 ((not dont-warn-when-unknown-mode) ; god this is ugly
317 (:leader "s" flyspell-start) 320 (message "Non-text or -prog mode. Run `flyspell-mode'."))))
321
322 (when (acdw/system :home)
323 (flyspell-start t))
318 324
319 (:when-loaded 325 (:when-loaded
320 (setup (:straight flyspell-correct) 326 (setup (:straight flyspell-correct)
@@ -364,6 +370,9 @@
364(setup imenu 370(setup imenu
365 (:option imenu-auto-rescan t)) 371 (:option imenu-auto-rescan t))
366 372
373(setup Info
374 (:hook variable-pitch-mode))
375
367(setup isearch 376(setup isearch
368 (:option search-default-mode t)) 377 (:option search-default-mode t))
369 378
@@ -560,6 +569,14 @@
560 (:hook flymake-mode 569 (:hook flymake-mode
561 flymake-shellcheck-load))) 570 flymake-shellcheck-load)))
562 571
572(setup shell-command
573 (:option shell-command-switch (acdw/system
574 ;; I should be testing on some variable
575 (:home "-csi")
576 (:work "-c"))
577 shell-command-prompt-show-cwd t
578 shell-command-default-error-buffer "*shell-command-errors*"))
579
563(setup shr 580(setup shr
564 (:option shr-width fill-column 581 (:option shr-width fill-column
565 shr-max-width fill-column 582 shr-max-width fill-column
@@ -577,6 +594,9 @@
577 uniquify-after-kill-buffer-p t 594 uniquify-after-kill-buffer-p t
578 uniquify-ignore-buffers-re "^\\*")) 595 uniquify-ignore-buffers-re "^\\*"))
579 596
597(setup variable-pitch-mode
598 (:hook acdw-fonts/adapt-variable-pitch))
599
580(setup view 600(setup view
581 (:option view-read-only t) 601 (:option view-read-only t)
582 602
@@ -935,7 +955,11 @@ if ripgrep is installed, otherwise `consult-grep'."
935 (:bind "RET" acdw-org/return-dwim 955 (:bind "RET" acdw-org/return-dwim
936 "<S-return>" acdw-org/org-table-copy-down) 956 "<S-return>" acdw-org/org-table-copy-down)
937 957
938 (add-hook 'before-save-hook #'acdw-org/fix-blank-lines-in-buffer) 958 (defun acdw/org-fix-lines-before-save ()
959 (add-hook 'before-save-hook #'acdw-org/fix-blank-lines-in-buffer 0 :local))
960
961 (:hook variable-pitch-mode
962 acdw/org-fix-lines-before-save)
939 963
940 (advice-add 'org-delete-backward-char 964 (advice-add 'org-delete-backward-char
941 :override #'acdw-org/delete-backward-char)) 965 :override #'acdw-org/delete-backward-char))
@@ -1063,21 +1087,27 @@ if ripgrep is installed, otherwise `consult-grep'."
1063 (global-whitespace-cleanup-mode +1)) 1087 (global-whitespace-cleanup-mode +1))
1064 1088
1065(setup (:straight winum) 1089(setup (:straight winum)
1066 (:option winum-auto-setup-mode-line nil 1090 (:option winum-scope 'frame-local
1091 winum-auto-setup-mode-line nil
1067 winum-ignored-buffers '(" *which-key*")) 1092 winum-ignored-buffers '(" *which-key*"))
1068 1093
1069 (when (display-graphic-p) 1094 (when-unfocused winum-map-keys
1070 (:with-map winum-keymap 1095 (defvar winum--keys-mapped nil
1071 (:bind "M-0" winum-select-window-0-or-10 1096 "Whether `winum' keys have been mapped already.")
1072 "M-1" winum-select-window-1 1097 (when (and (not winum--keys-mapped)
1073 "M-2" winum-select-window-2 1098 (display-graphic-p))
1074 "M-3" winum-select-window-3 1099 (:with-map winum-keymap
1075 "M-4" winum-select-window-4 1100 (:bind "M-0" winum-select-window-0-or-10
1076 "M-5" winum-select-window-5 1101 "M-1" winum-select-window-1
1077 "M-6" winum-select-window-6 1102 "M-2" winum-select-window-2
1078 "M-7" winum-select-window-7 1103 "M-3" winum-select-window-3
1079 "M-8" winum-select-window-8 1104 "M-4" winum-select-window-4
1080 "M-9" winum-select-window-9))) 1105 "M-5" winum-select-window-5
1106 "M-6" winum-select-window-6
1107 "M-7" winum-select-window-7
1108 "M-8" winum-select-window-8
1109 "M-9" winum-select-window-9))
1110 (setq winum--keys-mapped t)))
1081 1111
1082 (winum-mode +1)) 1112 (winum-mode +1))
1083 1113
diff --git a/lisp/acdw-fonts.el b/lisp/acdw-fonts.el index 6c0cb8d..1b73af7 100644 --- a/lisp/acdw-fonts.el +++ b/lisp/acdw-fonts.el
@@ -127,5 +127,50 @@ This is for emoji fonts."
127 (set-fontset-font t 'symbol 127 (set-fontset-font t 'symbol
128 (font-spec :family font) nil 'append))))) 128 (font-spec :family font) nil 'append)))))
129 129
130
131;;; Variable-pitch
132;; from https://github.com/turbana/emacs-config#variable-pitch
133
134(defcustom acdw-fonts/fixed-pitch-faces '(linum
135 org-block
136 org-block-begin-line
137 org-block-end-line
138 org-checkbox
139 org-code
140 org-date
141 org-document-info-keyword
142 org-hide
143 org-indent
144 org-link
145 org-meta-line
146 org-special-keyword
147 org-table
148 whitespace-space)
149 "Faces to keep fixed-pitch in `acdw/variable-pitch-mode'."
150 :type 'sexp
151 :group 'faces)
152
153(defun acdw-fonts//variable-pitch-add-inherit (attrs parent)
154 "Add `:inherit PARENT' to ATTRS unless already present.
155Handles cases where `:inherit' is already specified."
156 (let ((current-parent (plist-get attrs :inherit)))
157 (unless (or (eq parent current-parent)
158 (and (listp current-parent)
159 (member parent current-parent)))
160 (plist-put attrs :inherit (if current-parent
161 (list current-parent parent)
162 parent)))))
163
164(defun acdw-fonts/adapt-variable-pitch ()
165 "Adapt `variable-pitch-mode' to keep some fonts fixed-pitch."
166 (when variable-pitch-mode
167 (mapc (lambda (face)
168 (when (facep face)
169 (apply #'set-face-attribute
170 face nil (acdw-fonts//variable-pitch-add-inherit
171 (face-attr-construct face)
172 'fixed-pitch))))
173 acdw-fonts/fixed-pitch-faces)))
174
130(provide 'acdw-fonts) 175(provide 'acdw-fonts)
131;;; acdw-fonts.el ends here 176;;; acdw-fonts.el ends here