summary refs log tree commit diff stats
path: root/README.md
diff options
context:
space:
mode:
authorCase Duckworth2021-01-03 08:49:53 -0600
committerCase Duckworth2021-01-03 08:49:53 -0600
commit0cdf45ec992444b614e88ec6f88355d62d62c39d (patch)
treefee92b4c6524399e171ad70dcec56fb89b038230 /README.md
parentUpdate README (diff)
downloademacs-0cdf45ec992444b614e88ec6f88355d62d62c39d.tar.gz
emacs-0cdf45ec992444b614e88ec6f88355d62d62c39d.zip
Change max headline depth
Diffstat (limited to 'README.md')
-rw-r--r--README.md1064
1 files changed, 553 insertions, 511 deletions
diff --git a/README.md b/README.md index 5a1bfdc..bb12961 100644 --- a/README.md +++ b/README.md
@@ -152,15 +152,17 @@ This comes in handy when I want to garbage collect, say, or save recent files.
152 152
153### Tool Bars 153### Tool Bars
154 154
1551. Tool bars and menu bars
156 155
157 (menu-bar-mode -1) 156#### Tool bars and menu bars
158 (tool-bar-mode -1)
159 157
1602. Scroll bars 158 (menu-bar-mode -1)
159 (tool-bar-mode -1)
161 160
162 (scroll-bar-mode -1) 161
163 (horizontal-scroll-bar-mode -1) 162#### Scroll bars
163
164 (scroll-bar-mode -1)
165 (horizontal-scroll-bar-mode -1)
164 166
165 167
166### Dialogs 168### Dialogs
@@ -168,262 +170,283 @@ This comes in handy when I want to garbage collect, say, or save recent files.
168 (cuss use-dialog-box nil 170 (cuss use-dialog-box nil
169 "Don't use dialog boxes to ask questions.") 171 "Don't use dialog boxes to ask questions.")
170 172
1711. Yes or no questions
172 173
173 (fset 'yes-or-no-p #'y-or-n-p) 174#### Yes or no questions
175
176 (fset 'yes-or-no-p #'y-or-n-p)
177
178
179#### The Bell
174 180
1752. The Bell 181from [EmacsWiki](https://www.emacswiki.org/emacs/AlarmBell#h5o-3).
176 182
177 from [EmacsWiki](https://www.emacswiki.org/emacs/AlarmBell#h5o-3). 183 (setq visible-bell nil
184 ring-bell-function 'flash-mode-line)
178 185
179 (setq visible-bell nil 186 (defun flash-mode-line ()
180 ring-bell-function 'flash-mode-line) 187 (invert-face 'mode-line)
181 188 (run-with-timer 0.1 nil #'invert-face 'mode-line))
182 (defun flash-mode-line ()
183 (invert-face 'mode-line)
184 (run-with-timer 0.1 nil #'invert-face 'mode-line))
185 189
186 190
187### Frames 191### Frames
188 192
1891. Fringes
190 193
191 (cuss indicate-empty-lines t 194#### Fringes
192 "Show an indicator on the left fringe of empty lines past the
193 end of the buffer.")
194 (cuss indicate-buffer-boundaries 'right
195 "Indicate the beginning and end of the buffer and whether it
196 scrolls off-window in the right fringe.")
197 195
1982. Minibuffer 196 (cuss indicate-empty-lines t
197 "Show an indicator on the left fringe of empty lines past the
198 end of the buffer.")
199 (cuss indicate-buffer-boundaries 'right
200 "Indicate the beginning and end of the buffer and whether it
201 scrolls off-window in the right fringe.")
199 202
200 (cuss minibuffer-prompt-properties
201 '(read-only t cursor-intangible t face minibuffer-prompt)
202 "Keep the cursor away from the minibuffer prompt.")
203 203
2043. Tabs 204#### Minibuffer
205 205
206 (cuss tab-bar-tab-name-function 206 (cuss minibuffer-prompt-properties
207 #'tab-bar-tab-name-current-with-count 207 '(read-only t cursor-intangible t face minibuffer-prompt)
208 "Show the tab name as the name of the current buffer, plus a 208 "Keep the cursor away from the minibuffer prompt.")
209 count of the windows in the tab.") 209
210 210
211 (cuss tab-bar-show 1 211#### Tabs
212 "Show the tab bar, when there's more than one tab.") 212
213 (cuss tab-bar-tab-name-function
214 #'tab-bar-tab-name-current-with-count
215 "Show the tab name as the name of the current buffer, plus a
216 count of the windows in the tab.")
217
218 (cuss tab-bar-show 1
219 "Show the tab bar, when there's more than one tab.")
213 220
214 221
215### Windows 222### Windows
216 223
2171. Winner mode
218 224
219 (when (fboundp 'winner-mode) 225#### Winner mode
220 (winner-mode +1))
221 226
2222. Switch windows 227 (when (fboundp 'winner-mode)
228 (winner-mode +1))
223 229
224 (global-set-key (kbd "M-o") #'other-window) 230
231#### Switch windows
232
233 (global-set-key (kbd "M-o") #'other-window)
225 234
226 235
227### Buffers 236### Buffers
228 237
2291. Uniquify buffers 238
230 239#### Uniquify buffers
231 (require 'uniquify) 240
232 (cuss uniquify-buffer-name-style 'forward 241 (require 'uniquify)
233 "Uniquify buffers' names by going up the path trees until they 242 (cuss uniquify-buffer-name-style 'forward
234 become unique.") 243 "Uniquify buffers' names by going up the path trees until they
235 244 become unique.")
2362. Startup buffers 245
237 246
238 (cuss inhibit-startup-screen t 247#### Startup buffers
239 "Don't show Emacs' startup buffer.") 248
240 249 (cuss inhibit-startup-screen t
241 (cuss initial-buffer-choice t 250 "Don't show Emacs' startup buffer.")
242 "Start with *scratch*.") 251
243 252 (cuss initial-buffer-choice t
244 (cuss initial-scratch-message "" 253 "Start with *scratch*.")
245 "Empty *scratch* buffer.") 254
246 255 (cuss initial-scratch-message ""
2473. Kill the current buffer 256 "Empty *scratch* buffer.")
248 257
249 (defun acdw/kill-a-buffer (&optional prefix) 258
250 "Kill a buffer based on the following rules: 259#### Kill the current buffer
251 260
252 C-x k ⇒ Kill current buffer & window 261 (defun acdw/kill-a-buffer (&optional prefix)
253 C-u C-x k ⇒ Kill OTHER window and its buffer 262 "Kill a buffer based on the following rules:
254 C-u C-u C-x C-k ⇒ Kill all other buffers and windows 263
255 264 C-x k ⇒ Kill current buffer & window
256 Prompt only if there are unsaved changes." 265 C-u C-x k ⇒ Kill OTHER window and its buffer
257 (interactive "P") 266 C-u C-u C-x C-k ⇒ Kill all other buffers and windows
258 (pcase (or (car prefix) 0) 267
259 ;; C-x k ⇒ Kill current buffer & window 268 Prompt only if there are unsaved changes."
260 (0 (kill-current-buffer) 269 (interactive "P")
261 (unless (one-window-p) (delete-window))) 270 (pcase (or (car prefix) 0)
262 ;; C-u C-x k ⇒ Kill OTHER window and its buffer 271 ;; C-x k ⇒ Kill current buffer & window
263 (4 (other-window 1) 272 (0 (kill-current-buffer)
264 (kill-current-buffer) 273 (unless (one-window-p) (delete-window)))
265 (unless (one-window-p) (delete-window))) 274 ;; C-u C-x k ⇒ Kill OTHER window and its buffer
266 ;; C-u C-u C-x C-k ⇒ Kill all other buffers and windows 275 (4 (other-window 1)
267 (16 (mapc 'kill-buffer (delq (current-buffer) (buffer-list))) 276 (kill-current-buffer)
268 (delete-other-windows)))) 277 (unless (one-window-p) (delete-window)))
269 278 ;; C-u C-u C-x C-k ⇒ Kill all other buffers and windows
270 (define-key ctl-x-map "k" #'acdw/kill-a-buffer) 279 (16 (mapc 'kill-buffer (delq (current-buffer) (buffer-list)))
271 280 (delete-other-windows))))
272 1. Remap `C-x M-k` to bring up the buffer-killing menu 281
273 282 (define-key ctl-x-map "k" #'acdw/kill-a-buffer)
274 (define-key ctl-x-map (kbd "M-k") #'kill-buffer) 283
275 284
2764. Immortal `*scratch*` buffer 285##### Remap `C-x M-k` to bring up the buffer-killing menu
277 286
278 (defun immortal-scratch () 287 (define-key ctl-x-map (kbd "M-k") #'kill-buffer)
279 (if (eq (current-buffer) (get-buffer "*scratch*")) 288
280 (progn (bury-buffer) 289
281 nil) 290#### Immortal `*scratch*` buffer
282 t)) 291
283 292 (defun immortal-scratch ()
284 (add-hook 'kill-buffer-query-functions 'immortal-scratch) 293 (if (eq (current-buffer) (get-buffer "*scratch*"))
294 (progn (bury-buffer)
295 nil)
296 t))
297
298 (add-hook 'kill-buffer-query-functions 'immortal-scratch)
285 299
286 300
287### Modeline 301### Modeline
288 302
2891. Smart mode line
290 303
291 (straight-use-package 'smart-mode-line) 304#### Smart mode line
292
293 (cuss sml/no-confirm-load-theme t
294 "Pass the NO-CONFIRM flag to `load-theme'.")
295
296 (sml/setup)
297 305
2982. Rich minority 306 (straight-use-package 'smart-mode-line)
307
308 (cuss sml/no-confirm-load-theme t
309 "Pass the NO-CONFIRM flag to `load-theme'.")
310
311 (sml/setup)
299 312
300 Since this *comes* with smart mode line, I’m just going to use it, 313
301 instead of `diminish` or another package. I do have to write this 314#### Rich minority
302 helper function, though, to add things to the whitelist. 315
316Since this *comes* with smart mode line, I’m just going to use it,
317instead of `diminish` or another package. I do have to write this
318helper function, though, to add things to the whitelist.
319
320 (defun rm/whitelist-add (regexp)
321 "Add a REGEXP to the whitelist for `rich-minority'."
322 (if (listp 'rm--whitelist-regexps)
323 (add-to-list 'rm--whitelist-regexps regexp)
324 (setq rm--whitelist-regexps `(,regexp)))
325 (setq rm-whitelist
326 (mapconcat 'identity rm--whitelist-regexps "\\|")))
303 327
304 (defun rm/whitelist-add (regexp) 328 (straight-use-package 'rich-minority)
305 "Add a REGEXP to the whitelist for `rich-minority'." 329
306 (if (listp 'rm--whitelist-regexps) 330 (rm/whitelist-add "^$")
307 (add-to-list 'rm--whitelist-regexps regexp)
308 (setq rm--whitelist-regexps `(,regexp)))
309 (setq rm-whitelist
310 (mapconcat 'identity rm--whitelist-regexps "\\|")))
311
312 (straight-use-package 'rich-minority)
313
314 (rm/whitelist-add "^$")
315 331
316 332
317### Theme 333### Theme
318 334
3191. Modus Themes 335
320 336#### Modus Themes
321 (straight-use-package 'modus-themes) 337
322 338 (straight-use-package 'modus-themes)
323 (cuss modus-themes-slanted-constructs t 339
324 "Use more slanted constructs.") 340 (cuss modus-themes-slanted-constructs t
325 (cuss modus-themes-bold-constructs t 341 "Use more slanted constructs.")
326 "Use more bold constructs.") 342 (cuss modus-themes-bold-constructs t
327 343 "Use more bold constructs.")
328 (cuss modus-themes-region 'bg-only 344
329 "Only highlight the background of the selected region.") 345 (cuss modus-themes-region 'bg-only
330 346 "Only highlight the background of the selected region.")
331 (cuss modus-themes-org-blocks 'grayscale 347
332 "Show org-blocks with a grayscale background.") 348 (cuss modus-themes-org-blocks 'grayscale
333 (cuss modus-themes-headings 349 "Show org-blocks with a grayscale background.")
334 '((1 . line) 350 (cuss modus-themes-headings
335 (t . t)) 351 '((1 . line)
336 "Highlight top headings with `line' style, and others by default.") 352 (t . t))
337 353 "Highlight top headings with `line' style, and others by default.")
338 (cuss modus-themes-scale-headings t 354
339 "Scale headings by the ratios below.") 355 (cuss modus-themes-scale-headings t
340 (cuss modus-themes-scale-1 1.1) 356 "Scale headings by the ratios below.")
341 (cuss modus-themes-scale-2 1.15) 357 (cuss modus-themes-scale-1 1.1)
342 (cuss modus-themes-scale-3 1.21) 358 (cuss modus-themes-scale-2 1.15)
343 (cuss modus-themes-scale-4 1.27) 359 (cuss modus-themes-scale-3 1.21)
344 (cuss modus-themes-scale-5 1.33) 360 (cuss modus-themes-scale-4 1.27)
345 361 (cuss modus-themes-scale-5 1.33)
346 (load-theme 'modus-operandi t) 362
347 363 (load-theme 'modus-operandi t)
3482. Change themes based on time of day 364
349 365
350 (cuss calendar-latitude 30.4515) 366#### Change themes based on time of day
351 (cuss calendar-longitude -91.1871) 367
352 368 (cuss calendar-latitude 30.4515)
353 ;; sunrise 369 (cuss calendar-longitude -91.1871)
354 (run-at-time (nth 1 (split-string (sunrise-sunset))) 370
355 (* 60 60 24) 371 ;; sunrise
356 (lambda () 372 (run-at-time (nth 1 (split-string (sunrise-sunset)))
357 (modus-themes-load-operandi))) 373 (* 60 60 24)
358 374 (lambda ()
359 ;; sunset 375 (modus-themes-load-operandi)))
360 (run-at-time (nth 4 (split-string (sunrise-sunset))) 376
361 (* 60 60 24) 377 ;; sunset
362 (lambda () 378 (run-at-time (nth 4 (split-string (sunrise-sunset)))
363 (modus-themes-load-vivendi))) 379 (* 60 60 24)
380 (lambda ()
381 (modus-themes-load-vivendi)))
364 382
365 383
366### Fonts 384### Fonts
367 385
3681. Define fonts 386
369 387#### Define fonts
370 (defun set-face-from-alternatives (face fonts) 388
371 (catch :return 389 (defun set-face-from-alternatives (face fonts)
372 (dolist (font fonts) 390 (catch :return
373 (when (find-font (font-spec :family (car font))) 391 (dolist (font fonts)
374 (apply #'set-face-attribute `(,face 392 (when (find-font (font-spec :family (car font)))
375 nil 393 (apply #'set-face-attribute `(,face
376 :family (car font) 394 nil
377 ,@(cdr font))) 395 :family (car font)
378 (throw :return font))))) 396 ,@(cdr font)))
379 397 (throw :return font)))))
380 (defun acdw/setup-fonts () 398
381 "Setup fonts. This has to happen after the frame is setup for 399 (defun acdw/setup-fonts ()
382 the first time, so it should be added to `window-setup-hook'. It 400 "Setup fonts. This has to happen after the frame is setup for
383 removes itself from that hook." 401 the first time, so it should be added to `window-setup-hook'. It
384 (interactive) 402 removes itself from that hook."
385 (when (display-graphic-p) 403 (interactive)
386 (set-face-from-alternatives 'default 404 (when (display-graphic-p)
387 '(("Input Mono" 405 (set-face-from-alternatives 'default
388 :height 105) 406 '(("Input Mono"
389 ("Go Mono" 407 :height 105)
390 :height 100) 408 ("Go Mono"
391 ("Consolas" 409 :height 100)
392 :height 100))) 410 ("Consolas"
393 411 :height 100)))
394 (set-face-from-alternatives 'fixed-pitch 412
395 '(("Input Mono") 413 (set-face-from-alternatives 'fixed-pitch
396 ("Go Mono") 414 '(("Input Mono")
397 ("Consolas"))) 415 ("Go Mono")
398 416 ("Consolas")))
399 (set-face-from-alternatives 'variable-pitch 417
400 '(("Input Serif") 418 (set-face-from-alternatives 'variable-pitch
401 ("Georgia"))) 419 '(("Input Serif")
402 420 ("Georgia")))
403 (remove-function after-focus-change-function #'acdw/setup-fonts))) 421
404 422 (remove-function after-focus-change-function #'acdw/setup-fonts)))
405 (add-function :before after-focus-change-function #'acdw/setup-fonts) 423
406 424 (add-function :before after-focus-change-function #'acdw/setup-fonts)
4072. Custom faces 425
408 426
409 (cussface '(font-lock-comment-face 427#### Custom faces
410 ((t (:inherit (custom-comment italic variable-pitch)))))) 428
411 429 (cussface '(font-lock-comment-face
4123. Line spacing 430 ((t (:inherit (custom-comment italic variable-pitch))))))
413 431
414 (cuss line-spacing 0.1 432
415 "Add 10% extra space below each line.") 433#### Line spacing
416 434
4174. Underlines 435 (cuss line-spacing 0.1
418 436 "Add 10% extra space below each line.")
419 (cuss x-underline-at-descent-line t 437
420 "Draw the underline at the same place as the descent line.") 438
421 439#### Underlines
4225. Unicode Fonts 440
423 441 (cuss x-underline-at-descent-line t
424 (straight-use-package 'unicode-fonts) 442 "Draw the underline at the same place as the descent line.")
425 (require 'unicode-fonts) 443
426 (unicode-fonts-setup) 444
445#### Unicode Fonts
446
447 (straight-use-package 'unicode-fonts)
448 (require 'unicode-fonts)
449 (unicode-fonts-setup)
427 450
428 451
429## Interactivity 452## Interactivity
@@ -431,83 +454,90 @@ This comes in handy when I want to garbage collect, say, or save recent files.
431 454
432### Completing read 455### Completing read
433 456
4341. Shadow file names in `completing-read`. 457
435 458#### Shadow file names in `completing-read`.
436 (cuss file-name-shadow-properties '(invisible t)) 459
437 460 (cuss file-name-shadow-properties '(invisible t))
438 (file-name-shadow-mode +1) 461
439 462 (file-name-shadow-mode +1)
4402. Ignore case in `completing-read` 463
441 464
442 (cuss completion-ignore-case t) 465#### Ignore case in `completing-read`
443 (cuss read-buffer-completion-ignore-case t) 466
444 (cuss read-file-name-completion-ignore-case t) 467 (cuss completion-ignore-case t)
445 468 (cuss read-buffer-completion-ignore-case t)
4463. Minibuffer recursivity 469 (cuss read-file-name-completion-ignore-case t)
447 470
448 (cuss enable-recursive-minibuffers t) 471
449 (minibuffer-depth-indicate-mode +1) 472#### Minibuffer recursivity
450 473
4514. Selectrum 474 (cuss enable-recursive-minibuffers t)
452 475 (minibuffer-depth-indicate-mode +1)
453 (straight-use-package 'selectrum) 476
454 (require 'selectrum) 477
455 (selectrum-mode +1) 478#### Selectrum
456 479
4575. Prescient 480 (straight-use-package 'selectrum)
458 481 (require 'selectrum)
459 (straight-use-package 'prescient) 482 (selectrum-mode +1)
460 (require 'prescient) 483
461 (prescient-persist-mode +1) 484
462 485#### Prescient
463 (straight-use-package 'selectrum-prescient) 486
464 (require 'selectrum-prescient) 487 (straight-use-package 'prescient)
465 (selectrum-prescient-mode +1) 488 (require 'prescient)
466 489 (prescient-persist-mode +1)
4676. Consult 490
468 491 (straight-use-package 'selectrum-prescient)
469 (straight-use-package '(consult 492 (require 'selectrum-prescient)
470 :host github 493 (selectrum-prescient-mode +1)
471 :repo "minad/consult")) 494
472 (require 'consult) 495
473 496#### Consult
474 (straight-use-package '(consult-selectrum 497
475 :host github 498 (straight-use-package '(consult
476 :repo "minad/consult")) 499 :host github
477 (require 'consult-selectrum) 500 :repo "minad/consult"))
478 501 (require 'consult)
479 (with-eval-after-load 'consult 502
480 (define-key ctl-x-map "b" #'consult-buffer) 503 (straight-use-package '(consult-selectrum
481 (define-key ctl-x-map (kbd "C-r") #'consult-buffer) 504 :host github
482 (define-key ctl-x-map "4b" #'consult-buffer-other-window) 505 :repo "minad/consult"))
483 (define-key ctl-x-map "5b" #'consult-buffer-other-frame) 506 (require 'consult-selectrum)
484 507
485 (define-key goto-map "o" #'consult-outline) 508 (with-eval-after-load 'consult
486 (define-key goto-map "g" #'consult-line) 509 (define-key ctl-x-map "b" #'consult-buffer)
487 (define-key goto-map (kbd "M-g") #'consult-line) 510 (define-key ctl-x-map (kbd "C-r") #'consult-buffer)
488 (define-key goto-map "l" #'consult-line) 511 (define-key ctl-x-map "4b" #'consult-buffer-other-window)
489 (define-key goto-map "m" #'consult-mark) 512 (define-key ctl-x-map "5b" #'consult-buffer-other-frame)
490 (define-key goto-map "i" #'consult-imenu) 513
491 (define-key goto-map "e" #'consult-error) 514 (define-key goto-map "o" #'consult-outline)
492 515 (define-key goto-map "g" #'consult-line)
493 (global-set-key (kbd "M-y") #'consult-yank-pop) 516 (define-key goto-map (kbd "M-g") #'consult-line)
494 517 (define-key goto-map "l" #'consult-line)
495 (define-key help-map "a" #'consult-apropos) 518 (define-key goto-map "m" #'consult-mark)
496 519 (define-key goto-map "i" #'consult-imenu)
497 (fset 'multi-occur #'consult-multi-occur)) 520 (define-key goto-map "e" #'consult-error)
498 521
4997. Marginalia 522 (global-set-key (kbd "M-y") #'consult-yank-pop)
500 523
501 (straight-use-package '(marginalia 524 (define-key help-map "a" #'consult-apropos)
502 :host github 525
503 :repo "minad/marginalia" 526 (fset 'multi-occur #'consult-multi-occur))
504 :branch "main")) 527
505 528
506 (cuss marginalia-annotators 529#### Marginalia
507 '(marginalia-annotators-heavy 530
508 marginalia-annotators-light)) 531 (straight-use-package '(marginalia
509 532 :host github
510 (marginalia-mode +1) 533 :repo "minad/marginalia"
534 :branch "main"))
535
536 (cuss marginalia-annotators
537 '(marginalia-annotators-heavy
538 marginalia-annotators-light))
539
540 (marginalia-mode +1)
511 541
512 542
513### Completion 543### Completion
@@ -664,32 +694,34 @@ from [u/TheFrenchPoulp](https://www.reddit.com/r/emacs/comments/km9by4/weekly_ti
664 694
665### Encoding 695### Encoding
666 696
6671. UTF-8
668 697
669 (set-language-environment "UTF-8") 698#### UTF-8
670 (set-terminal-coding-system 'utf-8)
671 (cuss locale-coding-system 'utf-8)
672 (set-default-coding-systems 'utf-8)
673 (set-selection-coding-system 'utf-8)
674 (prefer-coding-system 'utf-8)
675 699
6762. Convert all files to UNIX-style line endings 700 (set-language-environment "UTF-8")
701 (set-terminal-coding-system 'utf-8)
702 (cuss locale-coding-system 'utf-8)
703 (set-default-coding-systems 'utf-8)
704 (set-selection-coding-system 'utf-8)
705 (prefer-coding-system 'utf-8)
677 706
678 from [Emacs Wiki](https://www.emacswiki.org/emacs/EndOfLineTips). 707
679 708#### Convert all files to UNIX-style line endings
680 (defun ewiki/no-junk-please-were-unixish () 709
681 "Convert line endings to UNIX, dammit." 710from [Emacs Wiki](https://www.emacswiki.org/emacs/EndOfLineTips).
682 (let ((coding-str (symbol-name buffer-file-coding-system))) 711
683 (when (string-match "-\\(?:dos\\|mac\\)$" coding-str) 712 (defun ewiki/no-junk-please-were-unixish ()
684 (set-buffer-file-coding-system 'unix)))) 713 "Convert line endings to UNIX, dammit."
685 714 (let ((coding-str (symbol-name buffer-file-coding-system)))
686 I add it to the `find-file-hook` *and* `before-save-hook` because I 715 (when (string-match "-\\(?:dos\\|mac\\)$" coding-str)
687 don't want to ever work with anything other than UNIX line endings 716 (set-buffer-file-coding-system 'unix))))
688 ever again. I just don't care. Even Microsoft Notepad can handle 717
689 UNIX line endings, so I don't want to hear it. 718I add it to the `find-file-hook` *and* `before-save-hook` because I
690 719don't want to ever work with anything other than UNIX line endings
691 (add-hook 'find-file-hook #'ewiki/no-junk-please-were-unixish) 720ever again. I just don't care. Even Microsoft Notepad can handle
692 (add-hook 'before-save-hook #'ewiki/no-junk-please-were-unixish) 721UNIX line endings, so I don't want to hear it.
722
723 (add-hook 'find-file-hook #'ewiki/no-junk-please-were-unixish)
724 (add-hook 'before-save-hook #'ewiki/no-junk-please-were-unixish)
693 725
694 726
695### Backups 727### Backups
@@ -748,38 +780,41 @@ from [u/TheFrenchPoulp](https://www.reddit.com/r/emacs/comments/km9by4/weekly_ti
748 780
749### Killing & Yanking 781### Killing & Yanking
750 782
7511. Replace selection when typing
752 783
753 (delete-selection-mode +1) 784#### Replace selection when typing
785
786 (delete-selection-mode +1)
754 787
7552. Work better with the system clipboard
756 788
757 (cuss save-interprogram-paste-before-kill t 789#### Work better with the system clipboard
758 "Save existing clipboard text into the kill ring before 790
759 replacing it.") 791 (cuss save-interprogram-paste-before-kill t
760 792 "Save existing clipboard text into the kill ring before
761 (cuss yank-pop-change-selection t 793 replacing it.")
762 "Update the X selection when rotating the kill ring.") 794
795 (cuss yank-pop-change-selection t
796 "Update the X selection when rotating the kill ring.")
763 797
764 798
765### Searching & Replacing 799### Searching & Replacing
766 800
7671. Replace with Anzu
768 801
769 (straight-use-package 'anzu) 802#### Replace with Anzu
770 (require 'anzu) 803
771 804 (straight-use-package 'anzu)
772 ;; show search count in the modeline 805 (require 'anzu)
773 (global-anzu-mode +1) 806
774 807 ;; show search count in the modeline
775 (cuss anzu-replace-to-string-separator " → " 808 (global-anzu-mode +1)
776 "What to separate the search from the replacement.") 809
777 810 (cuss anzu-replace-to-string-separator " → "
778 (global-set-key [remap query-replace] #'anzu-query-replace) 811 "What to separate the search from the replacement.")
779 (global-set-key [remap query-replace-regexp] #'anzu-query-replace-regexp) 812
780 813 (global-set-key [remap query-replace] #'anzu-query-replace)
781 (define-key isearch-mode-map [remap isearch-query-replace] #'anzu-isearch-query-replace) 814 (global-set-key [remap query-replace-regexp] #'anzu-query-replace-regexp)
782 (define-key isearch-mode-map [remap isearch-query-replace-regexp] #'anzu-isearch-query-replace-regexp) 815
816 (define-key isearch-mode-map [remap isearch-query-replace] #'anzu-isearch-query-replace)
817 (define-key isearch-mode-map [remap isearch-query-replace-regexp] #'anzu-isearch-query-replace-regexp)
783 818
784 819
785### Overwrite mode 820### Overwrite mode
@@ -1070,172 +1105,179 @@ I’ve put org mode under Applications, as opposed to Writing, because it’s m
1070 (cuss org-directory "~/Org") 1105 (cuss org-directory "~/Org")
1071 (cuss org-ellipsis "…") 1106 (cuss org-ellipsis "…")
1072 (cuss org-catch-invisible-edits 'show) 1107 (cuss org-catch-invisible-edits 'show)
1108
1109 (cuss org-export-headline-levels 8
1110 "Maximum level of headlines to export /as/ a headline.")
1073 1111
10741. Tags
1075 1112
1076 (cuss org-tags-column 0 1113#### Tags
1077 "Show tags directly after the headline. 1114
1078 This is the best-looking option with variable-pitch fonts.") 1115 (cuss org-tags-column 0
1079 1116 "Show tags directly after the headline.
1080 (cussface 1117 This is the best-looking option with variable-pitch fonts.")
1081 '(org-tag 1118
1082 ((t 1119 (cussface
1083 (:height 0.8 :weight normal :slant italic :foreground "grey40" :inherit 1120 '(org-tag
1084 (variable-pitch)))))) 1121 ((t
1122 (:height 0.8 :weight normal :slant italic :foreground "grey40" :inherit
1123 (variable-pitch))))))
1085 1124
1086 1125
1087### General 1126### General
1088 1127
10891. [Org Return: DWIM](https://github.com/alphapapa/unpackaged.el#org-return-dwim) 1128
1090 1129#### [Org Return: DWIM](https://github.com/alphapapa/unpackaged.el#org-return-dwim)
1091 (defun unpackaged/org-element-descendant-of (type element) 1130
1092 "Return non-nil if ELEMENT is a descendant of TYPE. 1131 (defun unpackaged/org-element-descendant-of (type element)
1093 TYPE should be an element type, like `item' or `paragraph'. 1132 "Return non-nil if ELEMENT is a descendant of TYPE.
1094 ELEMENT should be a list like that returned by `org-element-context'." 1133 TYPE should be an element type, like `item' or `paragraph'.
1095 ;; MAYBE: Use `org-element-lineage'. 1134 ELEMENT should be a list like that returned by `org-element-context'."
1096 (when-let* ((parent (org-element-property :parent element))) 1135 ;; MAYBE: Use `org-element-lineage'.
1097 (or (eq type (car parent)) 1136 (when-let* ((parent (org-element-property :parent element)))
1098 (unpackaged/org-element-descendant-of type parent)))) 1137 (or (eq type (car parent))
1099 1138 (unpackaged/org-element-descendant-of type parent))))
1100 ;;;###autoload 1139
1101 (defun unpackaged/org-return-dwim (&optional default) 1140 ;;;###autoload
1102 "A helpful replacement for `org-return'. With prefix, call `org-return'. 1141 (defun unpackaged/org-return-dwim (&optional default)
1103 1142 "A helpful replacement for `org-return'. With prefix, call `org-return'.
1104 On headings, move point to position after entry content. In 1143
1105 lists, insert a new item or end the list, with checkbox if 1144 On headings, move point to position after entry content. In
1106 appropriate. In tables, insert a new row or end the table." 1145 lists, insert a new item or end the list, with checkbox if
1107 ;; Inspired by John Kitchin: http://kitchingroup.cheme.cmu.edu/blog/2017/04/09/A-better-return-in-org-mode/ 1146 appropriate. In tables, insert a new row or end the table."
1108 (interactive "P") 1147 ;; Inspired by John Kitchin: http://kitchingroup.cheme.cmu.edu/blog/2017/04/09/A-better-return-in-org-mode/
1109 (if default 1148 (interactive "P")
1110 (org-return) 1149 (if default
1111 (cond 1150 (org-return)
1112 ;; Act depending on context around point. 1151 (cond
1113 1152 ;; Act depending on context around point.
1114 ;; NOTE: I prefer RET to not follow links, but by uncommenting this block, links will be 1153
1115 ;; followed. 1154 ;; NOTE: I prefer RET to not follow links, but by uncommenting this block, links will be
1116 1155 ;; followed.
1117 ;; ((eq 'link (car (org-element-context))) 1156
1118 ;; ;; Link: Open it. 1157 ;; ((eq 'link (car (org-element-context)))
1119 ;; (org-open-at-point-global)) 1158 ;; ;; Link: Open it.
1120 1159 ;; (org-open-at-point-global))
1121 ((org-at-heading-p) 1160
1122 ;; Heading: Move to position after entry content. 1161 ((org-at-heading-p)
1123 ;; NOTE: This is probably the most interesting feature of this function. 1162 ;; Heading: Move to position after entry content.
1124 (let ((heading-start (org-entry-beginning-position))) 1163 ;; NOTE: This is probably the most interesting feature of this function.
1125 (goto-char (org-entry-end-position)) 1164 (let ((heading-start (org-entry-beginning-position)))
1126 (cond ((and (org-at-heading-p) 1165 (goto-char (org-entry-end-position))
1127 (= heading-start (org-entry-beginning-position))) 1166 (cond ((and (org-at-heading-p)
1128 ;; Entry ends on its heading; add newline after 1167 (= heading-start (org-entry-beginning-position)))
1129 (end-of-line) 1168 ;; Entry ends on its heading; add newline after
1130 (insert "\n\n")) 1169 (end-of-line)
1131 (t 1170 (insert "\n\n"))
1132 ;; Entry ends after its heading; back up 1171 (t
1133 (forward-line -1) 1172 ;; Entry ends after its heading; back up
1134 (end-of-line) 1173 (forward-line -1)
1135 (when (org-at-heading-p) 1174 (end-of-line)
1136 ;; At the same heading 1175 (when (org-at-heading-p)
1137 (forward-line) 1176 ;; At the same heading
1138 (insert "\n") 1177 (forward-line)
1139 (forward-line -1)) 1178 (insert "\n")
1140 ;; FIXME: looking-back is supposed to be called with more arguments. 1179 (forward-line -1))
1141 (while (not (looking-back (rx (repeat 3 (seq (optional blank) "\n"))) nil)) 1180 ;; FIXME: looking-back is supposed to be called with more arguments.
1142 (insert "\n")) 1181 (while (not (looking-back (rx (repeat 3 (seq (optional blank) "\n"))) nil))
1143 (forward-line -1))))) 1182 (insert "\n"))
1144 1183 (forward-line -1)))))
1145 ((org-at-item-checkbox-p) 1184
1146 ;; Checkbox: Insert new item with checkbox. 1185 ((org-at-item-checkbox-p)
1147 (org-insert-todo-heading nil)) 1186 ;; Checkbox: Insert new item with checkbox.
1148 1187 (org-insert-todo-heading nil))
1149 ((org-in-item-p) 1188
1150 ;; Plain list. Yes, this gets a little complicated... 1189 ((org-in-item-p)
1151 (let ((context (org-element-context))) 1190 ;; Plain list. Yes, this gets a little complicated...
1152 (if (or (eq 'plain-list (car context)) ; First item in list 1191 (let ((context (org-element-context)))
1153 (and (eq 'item (car context)) 1192 (if (or (eq 'plain-list (car context)) ; First item in list
1154 (not (eq (org-element-property :contents-begin context) 1193 (and (eq 'item (car context))
1155 (org-element-property :contents-end context)))) 1194 (not (eq (org-element-property :contents-begin context)
1156 (unpackaged/org-element-descendant-of 'item context)) ; Element in list item, e.g. a link 1195 (org-element-property :contents-end context))))
1157 ;; Non-empty item: Add new item. 1196 (unpackaged/org-element-descendant-of 'item context)) ; Element in list item, e.g. a link
1158 (org-insert-item) 1197 ;; Non-empty item: Add new item.
1159 ;; Empty item: Close the list. 1198 (org-insert-item)
1160 ;; TODO: Do this with org functions rather than operating on the text. Can't seem to find the right function. 1199 ;; Empty item: Close the list.
1161 (delete-region (line-beginning-position) (line-end-position)) 1200 ;; TODO: Do this with org functions rather than operating on the text. Can't seem to find the right function.
1162 (insert "\n")))) 1201 (delete-region (line-beginning-position) (line-end-position))
1163 1202 (insert "\n"))))
1164 ((when (fboundp 'org-inlinetask-in-task-p) 1203
1165 (org-inlinetask-in-task-p)) 1204 ((when (fboundp 'org-inlinetask-in-task-p)
1166 ;; Inline task: Don't insert a new heading. 1205 (org-inlinetask-in-task-p))
1167 (org-return)) 1206 ;; Inline task: Don't insert a new heading.
1168 1207 (org-return))
1169 ((org-at-table-p) 1208
1170 (cond ((save-excursion 1209 ((org-at-table-p)
1171 (beginning-of-line) 1210 (cond ((save-excursion
1172 ;; See `org-table-next-field'. 1211 (beginning-of-line)
1173 (cl-loop with end = (line-end-position) 1212 ;; See `org-table-next-field'.
1174 for cell = (org-element-table-cell-parser) 1213 (cl-loop with end = (line-end-position)
1175 always (equal (org-element-property :contents-begin cell) 1214 for cell = (org-element-table-cell-parser)
1176 (org-element-property :contents-end cell)) 1215 always (equal (org-element-property :contents-begin cell)
1177 while (re-search-forward "|" end t))) 1216 (org-element-property :contents-end cell))
1178 ;; Empty row: end the table. 1217 while (re-search-forward "|" end t)))
1179 (delete-region (line-beginning-position) (line-end-position)) 1218 ;; Empty row: end the table.
1180 (org-return)) 1219 (delete-region (line-beginning-position) (line-end-position))
1181 (t 1220 (org-return))
1182 ;; Non-empty row: call `org-return'. 1221 (t
1183 (org-return)))) 1222 ;; Non-empty row: call `org-return'.
1184 (t 1223 (org-return))))
1185 ;; All other cases: call `org-return'. 1224 (t
1186 (org-return))))) 1225 ;; All other cases: call `org-return'.
1187 1226 (org-return)))))
1188 (with-eval-after-load 'org 1227
1189 (define-key org-mode-map (kbd "RET") #'unpackaged/org-return-dwim)) 1228 (with-eval-after-load 'org
1190 1229 (define-key org-mode-map (kbd "RET") #'unpackaged/org-return-dwim))
11912. Insert blank lines around headers 1230
1192 1231
1193 from [unpackaged.el](https://github.com/alphapapa/unpackaged.el#ensure-blank-lines-between-headings-and-before-contents). 1232#### Insert blank lines around headers
1194 1233
1195 ;;;###autoload 1234from [unpackaged.el](https://github.com/alphapapa/unpackaged.el#ensure-blank-lines-between-headings-and-before-contents).
1196 (defun unpackaged/org-fix-blank-lines (&optional prefix) 1235
1197 "Ensure that blank lines exist between headings and between headings and their contents. 1236 ;;;###autoload
1198 With prefix, operate on whole buffer. Ensures that blank lines 1237 (defun unpackaged/org-fix-blank-lines (&optional prefix)
1199 exist after each headings's drawers." 1238 "Ensure that blank lines exist between headings and between headings and their contents.
1200 (interactive "P") 1239 With prefix, operate on whole buffer. Ensures that blank lines
1201 (org-map-entries (lambda () 1240 exist after each headings's drawers."
1202 (org-with-wide-buffer 1241 (interactive "P")
1203 ;; `org-map-entries' narrows the buffer, which prevents us 1242 (org-map-entries (lambda ()
1204 ;; from seeing newlines before the current heading, so we 1243 (org-with-wide-buffer
1205 ;; do this part widened. 1244 ;; `org-map-entries' narrows the buffer, which prevents us
1206 (while (not (looking-back "\n\n" nil)) 1245 ;; from seeing newlines before the current heading, so we
1207 ;; Insert blank lines before heading. 1246 ;; do this part widened.
1208 (insert "\n"))) 1247 (while (not (looking-back "\n\n" nil))
1209 (let ((end (org-entry-end-position))) 1248 ;; Insert blank lines before heading.
1210 ;; Insert blank lines before entry content 1249 (insert "\n")))
1211 (forward-line) 1250 (let ((end (org-entry-end-position)))
1212 (while (and (org-at-planning-p) 1251 ;; Insert blank lines before entry content
1213 (< (point) (point-max))) 1252 (forward-line)
1214 ;; Skip planning lines 1253 (while (and (org-at-planning-p)
1215 (forward-line)) 1254 (< (point) (point-max)))
1216 (while (re-search-forward org-drawer-regexp end t) 1255 ;; Skip planning lines
1217 ;; Skip drawers. You might think that `org-at-drawer-p' 1256 (forward-line))
1218 ;; would suffice, but for some reason it doesn't work 1257 (while (re-search-forward org-drawer-regexp end t)
1219 ;; correctly when operating on hidden text. This 1258 ;; Skip drawers. You might think that `org-at-drawer-p'
1220 ;; works, taken from `org-agenda-get-some-entry-text'. 1259 ;; would suffice, but for some reason it doesn't work
1221 (re-search-forward "^[ \t]*:END:.*\n?" end t) 1260 ;; correctly when operating on hidden text. This
1222 (goto-char (match-end 0))) 1261 ;; works, taken from `org-agenda-get-some-entry-text'.
1223 (unless (or (= (point) (point-max)) 1262 (re-search-forward "^[ \t]*:END:.*\n?" end t)
1224 (org-at-heading-p) 1263 (goto-char (match-end 0)))
1225 (looking-at-p "\n")) 1264 (unless (or (= (point) (point-max))
1226 (insert "\n")))) 1265 (org-at-heading-p)
1227 t (if prefix 1266 (looking-at-p "\n"))
1228 nil 1267 (insert "\n"))))
1229 'tree))) 1268 t (if prefix
1230 1269 nil
1231 1. Add a before-save-hook 1270 'tree)))
1232 1271
1233 (defun cribbed/org-mode-fix-blank-lines () 1272
1234 (when (eq major-mode 'org-mode) 1273##### Add a before-save-hook
1235 (let ((current-prefix-arg 4)) ; Emulate C-u 1274
1236 (call-interactively 'unpackaged/org-fix-blank-lines)))) 1275 (defun cribbed/org-mode-fix-blank-lines ()
1237 1276 (when (eq major-mode 'org-mode)
1238 (add-hook 'before-save-hook #'cribbed/org-mode-fix-blank-lines) 1277 (let ((current-prefix-arg 4)) ; Emulate C-u
1278 (call-interactively 'unpackaged/org-fix-blank-lines))))
1279
1280 (add-hook 'before-save-hook #'cribbed/org-mode-fix-blank-lines)
1239 1281
1240 1282
1241### Org Agenda 1283### Org Agenda
@@ -1326,13 +1368,13 @@ I’ve put org mode under Applications, as opposed to Writing, because it’s m
1326 1368
1327### early-init.el 1369### early-init.el
1328 1370
1329 ;; early-init.el -*- no-byte-compile: t; -*- 1371 ;; early-init.el -*- no-byte-compile: t; -*-
1330 1372
1331 ;; I use `straight.el' instead of `package.el'. 1373 ;; I use `straight.el' instead of `package.el'.
1332 ;; (setq package-enable-at-startup nil) 1374 (setq package-enable-at-startup nil)
1333 1375
1334 ;; Don't resize the frame when loading fonts 1376 ;; Don't resize the frame when loading fonts
1335 (setq frame-inhibit-implied-resize t) 1377 (setq frame-inhibit-implied-resize t)
1336 1378
1337 1379
1338## Ease tangling and loading of Emacs' init 1380## Ease tangling and loading of Emacs' init