diff options
author | Case Duckworth | 2021-01-21 23:17:28 -0600 |
---|---|---|
committer | Case Duckworth | 2021-01-21 23:17:28 -0600 |
commit | 6f7da55585ecb39e6e0d302b1bab2ac67063afb2 (patch) | |
tree | b5b1048532999b09e96d6a99ac5ae0a6a7680852 | |
parent | 2020-01-21 (diff) | |
download | emacs-6f7da55585ecb39e6e0d302b1bab2ac67063afb2.tar.gz emacs-6f7da55585ecb39e6e0d302b1bab2ac67063afb2.zip |
2020-01-21
-rw-r--r-- | config.org | 219 | ||||
-rw-r--r-- | init.el | 22 |
2 files changed, 150 insertions, 91 deletions
diff --git a/config.org b/config.org index ea8c78c..1ce20e1 100644 --- a/config.org +++ b/config.org | |||
@@ -269,64 +269,26 @@ Only when there's more than one tab. | |||
269 | 269 | ||
270 | ** Fonts | 270 | ** Fonts |
271 | 271 | ||
272 | *** Find an installed font from a list of alternatives | 272 | I have different fonts installed on Linux and on Windows. |
273 | 273 | ||
274 | #+begin_src emacs-lisp :noweb-ref functions | 274 | #+begin_src emacs-lisp :noweb-ref linux-specific |
275 | (defun set-face-from-alternatives (face frame &rest fontspecs) | 275 | (set-face-attribute 'default nil |
276 | "Set FACE on FRAME from first available spec from FONTSPECS. | 276 | :family "Iosevka Acdw" |
277 | FACE and FRAME work the same as with `set-face-attribute.'" | 277 | :height 105) |
278 | (catch :return | ||
279 | (dolist (spec fontspecs) | ||
280 | (when-let ((found (find-font (apply #'font-spec spec)))) | ||
281 | (set-face-attribute face frame :font found) | ||
282 | (throw :return found))))) | ||
283 | #+end_src | ||
284 | 278 | ||
285 | *** Setup fonts on first window focus | 279 | (set-face-attribute 'fixed-pitch nil |
286 | 280 | :family "Iosevka Acdw" | |
287 | At the end of this function, it removes itself from | 281 | :height 105) |
288 | =after-focus-change-function=, so it only runs once. | 282 | #+end_src |
289 | 283 | ||
290 | #+begin_src emacs-lisp :noweb-ref functions | 284 | #+begin_src emacs-lisp :noweb-ref windows-specific |
291 | (defun acdw/setup-fonts () | 285 | (set-face-attribute 'default nil |
292 | "Setup fonts. This has to happen after the frame is setup for | 286 | :family "Consolas" |
293 | the first time, so it should be added to `after-focus-change-function'. It | 287 | :height 110) |
294 | removes itself from that hook." | ||
295 | (interactive) | ||
296 | (set-face-from-alternatives 'default nil | ||
297 | '(:family "Iosevka Acdw" | ||
298 | :slant normal | ||
299 | :weight normal | ||
300 | :height 105) | ||
301 | '(:family "Iosevka Extended" | ||
302 | :slant normal | ||
303 | :weight normal | ||
304 | :height 105) | ||
305 | '(:family "Consolas" | ||
306 | :slant normal | ||
307 | :weight normal | ||
308 | :height 100)) | ||
309 | ;; `fixed-pitch' inherits from `default' | ||
310 | (set-face-attribute 'fixed-pitch nil :inherit 'default) | ||
311 | ;; variable-pitch is different | ||
312 | (set-face-from-alternatives 'variable-pitch nil | ||
313 | '(:family "DejaVu Sans" | ||
314 | :slant normal | ||
315 | :weight normal) | ||
316 | '(:family "Georgia" | ||
317 | :slant normal | ||
318 | :weight normal)) | ||
319 | ;; remove self from hook | ||
320 | (remove-function after-focus-change-function #'acdw/setup-fonts)) | ||
321 | #+end_src | ||
322 | |||
323 | Of course, it only makes sense to run the font setup at all if I'm | ||
324 | using the graphical Emacs. | ||
325 | 288 | ||
326 | #+begin_src emacs-lisp :noweb-ref hooks | 289 | (set-face-attribute 'fixed-pitch nil |
327 | (when (display-graphic-p) | 290 | :family "Consolas" |
328 | (add-function :before after-focus-change-function | 291 | :height 110) |
329 | #'acdw/setup-fonts)) | ||
330 | #+end_src | 292 | #+end_src |
331 | 293 | ||
332 | *** Underlines | 294 | *** Underlines |
@@ -341,7 +303,7 @@ underline below all the text. | |||
341 | 303 | ||
342 | ** Theming | 304 | ** Theming |
343 | 305 | ||
344 | *** Modus themes | 306 | *** Modus themes :package: |
345 | 307 | ||
346 | #+begin_src emacs-lisp :noweb-ref packages | 308 | #+begin_src emacs-lisp :noweb-ref packages |
347 | (straight-use-package 'modus-themes) | 309 | (straight-use-package 'modus-themes) |
@@ -386,6 +348,45 @@ underline below all the text. | |||
386 | #'modus-themes-load-vivendi) | 348 | #'modus-themes-load-vivendi) |
387 | #+end_src | 349 | #+end_src |
388 | 350 | ||
351 | *** Mode line | ||
352 | |||
353 | **** Simple modeline :package: | ||
354 | |||
355 | After trying =doom-mode-line= and =smart-mode-line=, I think I've finally | ||
356 | landed on a good one: =simple-modeline=. | ||
357 | |||
358 | #+begin_src emacs-lisp :noweb-ref packages | ||
359 | (straight-use-package 'simple-modeline) | ||
360 | #+end_src | ||
361 | |||
362 | #+begin_src emacs-lisp :noweb-ref settings | ||
363 | (setq-default simple-modeline-segments | ||
364 | '((simple-modeline-segment-modified | ||
365 | simple-modeline-segment-buffer-name | ||
366 | simple-modeline-segment-position) | ||
367 | (simple-modeline-segment-minor-modes | ||
368 | simple-modeline-segment-input-method | ||
369 | simple-modeline-segment-vc | ||
370 | simple-modeline-segment-misc-info | ||
371 | simple-modeline-segment-process | ||
372 | simple-modeline-segment-major-mode))) | ||
373 | #+end_src | ||
374 | |||
375 | #+begin_src emacs-lisp :noweb-ref modes | ||
376 | (simple-modeline-mode +1) | ||
377 | #+end_src | ||
378 | |||
379 | **** Blackout some modes :package: | ||
380 | |||
381 | Like =diminish= or =delight=, =blackout= allows me to remove some | ||
382 | minor-modes from the modeline. | ||
383 | |||
384 | #+begin_src emacs-lisp :noweb-ref packages | ||
385 | (straight-use-package '(blackout | ||
386 | :host github | ||
387 | :repo "raxod502/blackout")) | ||
388 | #+end_src | ||
389 | |||
389 | * Interactivity | 390 | * Interactivity |
390 | 391 | ||
391 | ** Dialogs and alerts | 392 | ** Dialogs and alerts |
@@ -577,11 +578,36 @@ the user is looking at something else. | |||
577 | #+begin_src emacs-lisp :noweb-ref functions | 578 | #+begin_src emacs-lisp :noweb-ref functions |
578 | (defun when-unfocused (func &rest args) | 579 | (defun when-unfocused (func &rest args) |
579 | "Run FUNC, with ARGS, iff all frames are out of focus." | 580 | "Run FUNC, with ARGS, iff all frames are out of focus." |
580 | (require 'seq) | ||
581 | (when (seq-every-p #'null (mapcar #'frame-focus-state (frame-list))) | 581 | (when (seq-every-p #'null (mapcar #'frame-focus-state (frame-list))) |
582 | (apply func args))) | 582 | (apply func args))) |
583 | #+end_src | 583 | #+end_src |
584 | 584 | ||
585 | ** Garbage collection | ||
586 | |||
587 | *** Garbage Collection Magic Hack :package: | ||
588 | |||
589 | Look, I'm not going to look too deeply into this. It's /magic/ afer | ||
590 | all. | ||
591 | |||
592 | #+begin_src emacs-lisp :noweb-ref packages | ||
593 | (straight-use-package 'gcmh) | ||
594 | #+end_src | ||
595 | |||
596 | #+begin_src emacs-lisp :noweb-ref modes | ||
597 | (gcmh-mode +1) | ||
598 | (blackout 'gcmh-mode) | ||
599 | #+end_src | ||
600 | |||
601 | *** Garbage Collect when out of focus | ||
602 | |||
603 | #+begin_src emacs-lisp :noweb-ref hooks | ||
604 | (defun hook--gc-when-unfocused () | ||
605 | (when-unfocused #'garbage-collect)) | ||
606 | |||
607 | (add-function :after after-focus-change-function | ||
608 | #'hook--gc-when-unfocused) | ||
609 | #+end_src | ||
610 | |||
585 | * Files | 611 | * Files |
586 | 612 | ||
587 | ** Encoding | 613 | ** Encoding |
@@ -670,6 +696,7 @@ Bozhidar Batsov's [[https://github.com/bbatsov/super-save][super-save]] package. | |||
670 | 696 | ||
671 | #+begin_src emacs-lisp :noweb-ref modes | 697 | #+begin_src emacs-lisp :noweb-ref modes |
672 | (super-save-mode +1) | 698 | (super-save-mode +1) |
699 | (blackout 'super-save-mode) | ||
673 | #+end_src | 700 | #+end_src |
674 | 701 | ||
675 | ** Auto-revert files | 702 | ** Auto-revert files |
@@ -819,6 +846,44 @@ It manages my whitespace for me, anyway. | |||
819 | (setq-default set-mark-repeat-command-pop t) | 846 | (setq-default set-mark-repeat-command-pop t) |
820 | #+end_src | 847 | #+end_src |
821 | 848 | ||
849 | ** Undo :package: | ||
850 | |||
851 | *** Undo Fu | ||
852 | |||
853 | #+begin_src emacs-lisp :noweb-ref packages | ||
854 | (straight-use-package 'undo-fu) | ||
855 | #+end_src | ||
856 | |||
857 | #+begin_src emacs-lisp :noweb-ref bindings | ||
858 | (define-key global-map (kbd "C-/") #'undo-fu-only-undo) | ||
859 | (define-key global-map (kbd "C-?") #'undo-fu-only-redo) | ||
860 | #+end_src | ||
861 | |||
862 | *** Undo Fu session | ||
863 | |||
864 | I'm not putting this in [[*Persistence]] because it'd be confusing away | ||
865 | from =undo-fu=. | ||
866 | |||
867 | #+begin_src emacs-lisp :noweb-ref packages | ||
868 | (straight-use-package 'undo-fu-session) | ||
869 | #+end_src | ||
870 | |||
871 | #+begin_src emacs-lisp :noweb-ref settings | ||
872 | (setq-default undo-fu-session-incompatible-files | ||
873 | '("/COMMIT_EDITMSG\\'" | ||
874 | "/git-rebase-todo\\'")) | ||
875 | #+end_src | ||
876 | |||
877 | #+begin_src emacs-lisp :noweb-ref no-littering | ||
878 | (let ((dir (no-littering-expand-var-file-name "undos"))) | ||
879 | (make-directory dir :parents) | ||
880 | (setq-default undo-fu-session-directory dir)) | ||
881 | #+end_src | ||
882 | |||
883 | #+begin_src emacs-lisp :noweb-ref modes | ||
884 | (global-undo-fu-session-mode +1) | ||
885 | #+end_src | ||
886 | |||
822 | * Writing | 887 | * Writing |
823 | 888 | ||
824 | ** Word count :package: | 889 | ** Word count :package: |
@@ -957,20 +1022,20 @@ enables me to open them in the same buffer, fancily indented. | |||
957 | (define-key dired-mode-map "i" #'dired-subtree-toggle)) | 1022 | (define-key dired-mode-map "i" #'dired-subtree-toggle)) |
958 | #+end_src | 1023 | #+end_src |
959 | 1024 | ||
960 | *** Collapse singleton directories | 1025 | *** Collapse singleton directories :package: |
961 | 1026 | ||
962 | If a directory only has one item in it, =dired-collapse= shows what | 1027 | If a directory only has one item in it, =dired-collapse= shows what |
963 | that one item is. | 1028 | that one item is. |
964 | 1029 | ||
965 | #+begin_src emacs-lisp :noweb-ref packages | 1030 | #+begin_src emacs-lisp :noweb-ref packages |
966 | (straight-use-package 'dired-subtree) | 1031 | (straight-use-package 'dired-collapse) |
967 | #+end_src | 1032 | #+end_src |
968 | 1033 | ||
969 | #+begin_src emacs-lisp :noweb-ref hooks | 1034 | #+begin_src emacs-lisp :noweb-ref hooks |
970 | (add-hook 'dired-mode-hook #'dired-collapse-mode) | 1035 | (add-hook 'dired-mode-hook #'dired-collapse-mode) |
971 | #+end_src | 1036 | #+end_src |
972 | 1037 | ||
973 | ** Org mode | 1038 | * Org mode :package: |
974 | 1039 | ||
975 | #+begin_src emacs-lisp :noweb-ref packages | 1040 | #+begin_src emacs-lisp :noweb-ref packages |
976 | (straight-use-package 'org) | 1041 | (straight-use-package 'org) |
@@ -994,7 +1059,7 @@ that one item is. | |||
994 | org-pretty-entities t | 1059 | org-pretty-entities t |
995 | ;; Source blocks | 1060 | ;; Source blocks |
996 | org-src-tab-acts-natively t | 1061 | org-src-tab-acts-natively t |
997 | org-src-window-setup 'current-window ; could change this | 1062 | org-src-window-setup 'split-window-below ; could change this based on geom |
998 | org-confirm-babel-evaluate nil | 1063 | org-confirm-babel-evaluate nil |
999 | ;; Behavior | 1064 | ;; Behavior |
1000 | org-adapt-indentation nil ; don't indent things | 1065 | org-adapt-indentation nil ; don't indent things |
@@ -1005,7 +1070,7 @@ that one item is. | |||
1005 | org-export-headline-levels 8) | 1070 | org-export-headline-levels 8) |
1006 | #+end_src | 1071 | #+end_src |
1007 | 1072 | ||
1008 | *** Org templates | 1073 | ** Org templates |
1009 | 1074 | ||
1010 | #+begin_src emacs-lisp :noweb-ref settings | 1075 | #+begin_src emacs-lisp :noweb-ref settings |
1011 | (with-eval-after-load 'org-tempo | 1076 | (with-eval-after-load 'org-tempo |
@@ -1023,7 +1088,7 @@ that one item is. | |||
1023 | (add-to-list 'org-structure-template-alist cell))) | 1088 | (add-to-list 'org-structure-template-alist cell))) |
1024 | #+end_src | 1089 | #+end_src |
1025 | 1090 | ||
1026 | *** Org Return: DWIM :unpackaged: | 1091 | ** Org Return: DWIM :unpackaged: |
1027 | 1092 | ||
1028 | #+begin_src emacs-lisp :noweb-ref functions | 1093 | #+begin_src emacs-lisp :noweb-ref functions |
1029 | (defun unpackaged/org-element-descendant-of (type element) | 1094 | (defun unpackaged/org-element-descendant-of (type element) |
@@ -1477,9 +1542,11 @@ See [[*Determine where I am][the definition above]] for rationale as to why this | |||
1477 | 1542 | ||
1478 | **** Load the config | 1543 | **** Load the config |
1479 | 1544 | ||
1480 | I keep most of my config in =config.el=, which is tangled directly | 1545 | I keep most of my config in =config.el=, which is tangled directly from |
1481 | from this file. This init just loads that file, either from lisp or | 1546 | this file. This init just loads that file, either from lisp ~or |
1482 | directly from Org if it's newer. | 1547 | directly from Org if it's newer~. I found out that =org-babel-load-file= |
1548 | /caches/ its runs, and checks for me whether the .org or .el file is | ||
1549 | newer. /Plus/ it can byte-compile!! | ||
1483 | 1550 | ||
1484 | #+begin_src emacs-lisp | 1551 | #+begin_src emacs-lisp |
1485 | (let* (;; Speed up init | 1552 | (let* (;; Speed up init |
@@ -1492,19 +1559,15 @@ directly from Org if it's newer. | |||
1492 | (config.org (concat config ".org")) | 1559 | (config.org (concat config ".org")) |
1493 | (straight-org-dir (expand-file-name "straight/build/org" | 1560 | (straight-org-dir (expand-file-name "straight/build/org" |
1494 | user-emacs-directory))) | 1561 | user-emacs-directory))) |
1495 | ;; Unless config.org is /newer/ than config.el, *or* the config | 1562 | (unless (load config 'no-error)) |
1496 | ;; is able to be loaded without errors, load the config from | 1563 | ;; A plain require here just loads the older `org' |
1497 | ;; config.org. | 1564 | ;; in Emacs' install dir. We need to add the newer |
1498 | (unless (or (file-newer-than-file-p config.org config.el) | 1565 | ;; one to the `load-path', hopefully that's all. |
1499 | (load config 'no-error)) | 1566 | (when (file-exists-p straight-org-dir) |
1500 | ;; A plain require here just loads the older `org' | 1567 | (add-to-list 'load-path straight-org-dir)) |
1501 | ;; in Emacs' install dir. We need to add the newer | 1568 | ;; Load config.org |
1502 | ;; one to the `load-path', hopefully that's all. | 1569 | (require 'org) |
1503 | (when (file-exists-p straight-org-dir) | 1570 | (org-babel-load-file config.org :compile)) |
1504 | (add-to-list 'load-path straight-org-dir)) | ||
1505 | ;; Load config.org | ||
1506 | (require 'org) | ||
1507 | (org-babel-load-file config.org))) | ||
1508 | #+end_src | 1571 | #+end_src |
1509 | 1572 | ||
1510 | *** early-init.el | 1573 | *** early-init.el |
diff --git a/init.el b/init.el index 221956c..332468c 100644 --- a/init.el +++ b/init.el | |||
@@ -39,16 +39,12 @@ If COMMANDS is empty or nil, simply return the result of CONDITIONS." | |||
39 | (config.org (concat config ".org")) | 39 | (config.org (concat config ".org")) |
40 | (straight-org-dir (expand-file-name "straight/build/org" | 40 | (straight-org-dir (expand-file-name "straight/build/org" |
41 | user-emacs-directory))) | 41 | user-emacs-directory))) |
42 | ;; Unless config.org is /newer/ than config.el, *or* the config | 42 | (unless (load config 'no-error)) |
43 | ;; is able to be loaded without errors, load the config from | 43 | ;; A plain require here just loads the older `org' |
44 | ;; config.org. | 44 | ;; in Emacs' install dir. We need to add the newer |
45 | (unless (or (file-newer-than-file-p config.org config.el) | 45 | ;; one to the `load-path', hopefully that's all. |
46 | (load config 'no-error)) | 46 | (when (file-exists-p straight-org-dir) |
47 | ;; A plain require here just loads the older `org' | 47 | (add-to-list 'load-path straight-org-dir)) |
48 | ;; in Emacs' install dir. We need to add the newer | 48 | ;; Load config.org |
49 | ;; one to the `load-path', hopefully that's all. | 49 | (require 'org) |
50 | (when (file-exists-p straight-org-dir) | 50 | (org-babel-load-file config.org :compile)) |
51 | (add-to-list 'load-path straight-org-dir)) | ||
52 | ;; Load config.org | ||
53 | (require 'org) | ||
54 | (org-babel-load-file config.org))) | ||