summaryrefslogtreecommitdiff
path: root/jakob.org
blob: 10b83ff63eadcb3d57472a5bb58349fc58cc44b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
What follows is my personal configuration for GNU Emacs, done in the style of
literate programming. Literate configurations typically rely on =org-babel= to
evaluate the Lisp forms upon starting Emacs, but this configuration takes a
different approach: [[./init.el][init.el]] defines a function, =eval-document=, which "tangles"
all of the relevant Org source blocks into a temporary buffer and proceeds to
invoke =eval-buffer=. The main implication of this is that there won't be a
=jakob.el= in the Emacs configuration directory.

Also worth noting is that there is no specific namespace (i.e. =jakob-=, =jakob/=,
or =my-=) for functions defined in this file.

* Bootstrapping

There are a few packages I use that require early initialization, which is done
under this heading.

** Package Management

I use [[https://github.com/raxod502/straight.el][straight.el]] insetad of =package.el=.

#+BEGIN_SRC elisp
(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))
#+END_SRC

For installation and configuration of packages, I use the [[https://github.com/jwiegley/use-package][use-package]] macro.

#+BEGIN_SRC elisp
(straight-use-package 'use-package)
(setq straight-use-package-by-default t)
#+END_SRC

=bind-key= is required early on to support =use-package='s =:bind= declarations.

#+BEGIN_SRC elisp
(use-package bind-key :defer t)
#+END_SRC

** Libraries

A handful of the Elisp snippets in this file depend on third-party libraries
which aren't loaded by default.

#+BEGIN_SRC elisp
(require 'cl)
#+END_SRC

** Configuration

Create some bindings for quickly getting to this configuration file.

#+BEGIN_SRC elisp
(defun config-goto ()
  "Find the literate config file."
  (interactive)
  (find-file "~/.emacs.d/jakob.org"))

(defun config-reload ()
  "Re-evaluate the literate config file."
  (interactive)
  (eval-document "~/.emacs.d/jakob.org"))

(bind-key "C-c e" #'config-goto)
(bind-key "C-c r" #'config-reload)
#+END_SRC

* Vanilla Emacs

Any configuration that addresses the core of Emacs rather than a built-in or
third-party package goes here.

** Startup

Having Emacs open to =*scratch*= feels as if it's inviting me to punch out some
Lisp forms and evaluate them. I like to pretend that my computers are Lisp
machines.

#+BEGIN_SRC elisp
(setq inhibit-startup-message t
      inhibit-startup-buffer-menu t
      initial-scratch-message nil
      initial-buffer-choice nil)
#+END_SRC

** Filesystem

A recurring theme in this configuration file is configuring where Emacs packages
drop their various state files. =no-littering.el= is a package that handles this
with =var/= and =etc/= directories in =~/.emacs.d/=, but it's implemented in a way
that pollutes the global namespace with variables for packages that I don't use,
and would require a significant amount of configuration on my part anyway. I've
decided to manually set relevant variables to subdirectories of =~/.cache= and
=~/.local/share=.

Save backup files to one directory instead of making a mess of the filesystem.

#+BEGIN_SRC elisp
(setq backup-directory-alist `(("." . "~/.cache/emacs")))
#+END_SRC

=auto-save=, in addition to the actual files it saves, maintains another file
listing the files it's currently taking care of.

#+BEGIN_SRC elisp
(setq auto-save-list-file-prefix "~/.cache/emacs/auto-save-list/.saves-")
#+END_SRC

Disables the creation of locking symlinks in the current directory. This is a
very opinionated choice, and might not be a good idea for the average user.

#+BEGIN_SRC elisp
(setq create-lockfiles nil)
#+END_SRC

Although I personally prefer writing elisp to =custom.el=, a few packages
(specifically =package.el=) do make use of it. This snippet ensures that a
massacre is not made of my =init.el=.

#+BEGIN_SRC elisp
(setq custom-file "~/.emacs.d/custom.el")
(when (file-exists-p custom-file)
  (load custom-file))
#+END_SRC

I don't really care about persisting minibuffer history between sessions. Even
if I disable =savehist-mode=, it still writes to disk, so the least I can do is
move the history file to somewhere that isn't =~/.emacs.d=.

#+BEGIN_SRC elisp
(savehist-mode -1)
(setq savehist-file "~/.cache/emacs/history")
#+END_SRC

** User Interface

Use a consistent confirmation dialog of "y or n".

#+BEGIN_SRC elisp
(fset 'yes-or-no-p 'y-or-n-p)
#+END_SRC

Automatically revert buffers and dired listings when something on disk changes.

#+BEGIN_SRC elisp
(use-package autorevert
  :config
  (global-auto-revert-mode 1)
  (setq global-auto-revert-non-file-buffers t
        auto-revert-verbose nil))
#+END_SRC

I got sick of seeing "Command attempted to use minibuffer while in minibuffer".

#+BEGIN_SRC elisp
(setq enable-recursive-minibuffers t)
#+END_SRC

Use soft wrapping instead of "scrolling" when overflowing the width of a frame.

#+BEGIN_SRC elisp
(global-visual-line-mode t)
#+END_SRC

Actually select help windows when I pop them so that I can kill them with <q>.

#+BEGIN_SRC elisp
(setq help-window-select t)
#+END_SRC

Most *NIX tools work best when files are terminated with a newline.

#+BEGIN_SRC emacs-lisp
(setq require-final-newline t)
#+END_SRC

Sentences should be separated by a single space, so treat two sentences as two
when filling.

#+BEGIN_SRC elisp
(setq sentence-end-double-space nil)
#+END_SRC

I like using the tab key, but prefer spaces to tabstops, and the width I prefer
to use is 4 characters.

#+BEGIN_SRC elisp
(setq-default indent-tabs-mode nil
              tab-width 4)
#+END_SRC

Modern conventions state that 80 characters is the standard width.

#+BEGIN_SRC elisp
(setq-default fill-column 80)
#+END_SRC

When killing, add whatever's in the system clipboard if it isn't there already,
so I can get it back with <M-y>.

#+BEGIN_SRC elisp
(setq save-interprogram-paste-before-kill t)
#+END_SRC

Enable the default-disabled functions that I use.

#+BEGIN_SRC elisp
(put 'downcase-region 'disabled nil)
(put 'upcase-region 'disabled nil)
#+END_SRC

#+BEGIN_SRC elisp
(show-paren-mode t)
(column-number-mode t)
#+END_SRC

Unbind =C-z= and =C-x C-z= so I'm not accidentally calling =suspend-frame=.

#+BEGIN_SRC elisp
(global-unset-key (kbd "C-z"))
(global-unset-key (kbd "C-x C-z"))
#+END_SRC

* Quality-of-Life
** Ivy

As [[https://icosahedron.website/@zge/101330910258980695][suggested by a friend]], I tried out Ivy as a replacement for ido. It was love
at first sight. It's snappy, and works even better than ido after setting
=exwm-workspace-show-all-buffers= and =exwm-layout-show-all-buffers=.

Configure how the =completing-read= is displayed.

#+BEGIN_SRC elisp
(use-package ivy
  :init
  (setq ivy-height 5)
  (setq ivy-count-format "")
#+END_SRC

Enable Ivy globally.

#+BEGIN_SRC elisp
  :config
  (ivy-mode 1)
#+END_SRC

Transformer to highlight channels in the =completing-read= of
=irc-switch-buffer= that have had activity recently.

#+BEGIN_SRC elisp
  :config
  (defun irc-switch-buffer-transformer (str)
    "Transform channels with activity with `ivy-virtual' face."
    (let ((modified (map 'list
                         (lambda (channel)
                           (buffer-name (first channel)))
                         erc-modified-channels-alist)))
      (if (member str modified)
          (propertize str 'face 'ivy-virtual)
        str)))
  (ivy-set-display-transformer 'irc-switch-buffer
                               'irc-switch-buffer-transformer))
#+END_SRC

Use Counsel as a frontend to a couple of interactive commands.

#+BEGIN_SRC elisp
(use-package counsel
  :demand t
  :bind
  (("C-x b" . counsel-switch-buffer)))
#+END_SRC

Use Swiper instead of isearch.

#+BEGIN_SRC elisp
(use-package swiper
  :bind
  ("C-s" . swiper))
#+END_SRC

** Yasnippet

Load all snippets when =yas-minor-mode= is enabled.

#+BEGIN_SRC elisp
(use-package yasnippet
  :demand t
  :hook
  (yas-minor-mode . yas-reload-all))
#+END_SRC

** avy

#+BEGIN_SRC elisp
(use-package avy
  :bind
  ("M-s" . avy-goto-char))
#+END_SRC

** Imenu

Set up keybindings for =imenu=.

#+BEGIN_SRC elisp
(use-package imenu
  :bind ("C-c s" . imenu))
#+END_SRC

* Appearance

This feature doesn't see frequent use, but I prefer three proportionally-sized
windows to two really tiny ones over a really big one.

#+BEGIN_SRC elisp
(setq window-combination-resize t)
#+END_SRC

Don't do jerky jumps when the cursor reaches the end of the window. Instead,
just scroll by one line.

#+BEGIN_SRC elisp
(setq scroll-conservatively most-positive-fixnum)
#+END_SRC

The menu bar can be accessed with =M-`= if I really need it, so I don't see the
point in having it take up the space at the top. The rest of these rarely see
use from me, and I'd prefer to disable them and have access to the extra screen
real estate.

#+BEGIN_SRC elisp
(menu-bar-mode -1)
(scroll-bar-mode -1)
(tool-bar-mode -1)
(fringe-mode -1)
#+END_SRC

Hacking is a lot more serene when visual stimulus is kept to a minimum.

#+BEGIN_SRC elisp
(blink-cursor-mode 0)
#+END_SRC

** Theme

This is my custom theme, the code for which is very loosely adapted from
[[https://github.com/kuanyui/moe-theme.el][moe-theme.el]], but most of the palette has been altered to emulate the appearance
of my old setup of Emacs in a terminal emulator.

#+BEGIN_SRC elisp
(deftheme chayote
  "Inspired by the appearance of Emacs in my terminal emulator.")
#+END_SRC

The colors have been extracted into a variable, =palette=, and a macro,
=with-palette=, to provide access to the theme's color definitions without
significantly polluting the global namespace.

#+BEGIN_SRC elisp
(defvar palette
  '((yellow-1 "#ffd787") (yellow-2 "#ffd700") (yellow-3 "#c4a000")
    (yellow-3-5 "#aaaa11") (yellow-4 "#875f00")

    (orange-1 "#ffaf87") (orange-2 "#ff8700") (orange-3 "#ff5d17")
    (orange-4 "#d75f00") (orange-5 "#af5f00")

    (magenta-1 "#ff7bbb") (magenta-2 "#ff4ea3") (magenta-3 "#ff1f8b")

    (green-1 "#87ff87") (green-2 "#a1db00") (green-3 "#5faf00")
    (green-4 "#008700") (green-5 "#005f00")

    (cyan-1 "#afd7d7") (cyan-2 "#87ffd7") (cyan-3 "#00d7af")
    (cyan-4 "#00ac8a") (cyan-5 "#5faf87") (cyan-6 "#005f5f")
    (cyan-7 "#236f73")

    (blue-1 "#1fb6d3") (blue-2 "#1f5bff") (blue-3 "#005f87")
    (blue-4 "#5f7ab1") (blue-5 "#0000af") (blue-6 "#00005f")

    (purple-1 "#d18aff") (purple-2 "#af5fff") (purple-3 "#9a08ff")
    (purple-4 "#6c0099")

    (red-1 "#ef2929") (red-2 "#dd0000") (red-3 "#a40000")
    (red-4 "#5f0000")

    (white-1 "#f0e9dc") (white-2 "#c6c6c6") (white-3 "#b2b2b2")

    (black-1 "#a8a8a8") (black-2 "#8a8a8a") (black-2-5 "#6c6c6c")
    (black-3 "#4e4e4e") (black-4 "#3a3a3a") (black-5 "#303539")
    (black-6 "#000000")

    (LIGHT_BG "#fdfde7") (white-0 "#eeeeee")

    (green-02 "#5fd700") (green-01 "#d7ff00") (green-0 "#d7ff5f")
    (green-00 "#d7ff87")

    (cyan-0 "#d7ffd7")

    (blue-01 "#c3c9f8") (blue-0 "#afd7ff") (blue-00 "#d7d7ff")

    (yellow-0 "#ffff87") (yellow-00 "#ffffaf")

    (purple-0 "#af87ff") (purple-00 "#e6a8df")

    (red-0 "#ff4b4b") (red-00 "#ffafaf")

    (magenta-0 "#ffafd7") (magenta-00 "#ffd7ff")

    (orange-0 "#ffaf87") (orange-00 "#ffd787") (orange-000 "#ffd7af")

    (linum-dark "#87875f") (linum-light "#d7d7af"))
  "The palette of colors in use with my 'chayote' theme.")

(defmacro with-palette (&rest form)
  "Evaluate `FORM' in a lexical environment with access to the
individual colors making up the theme's palette."
  `(let ((class '((class color) (min-colors 89)))
         ,@palette)
     ,@form))
#+END_SRC

To help me in modifying the theme, I've defined a function similar to
=list-colors-display=, but for showing the colors in the palette I've defined.

#+BEGIN_SRC elisp
(defun display-palette ()
  "Display names of colors defined in `PALETTE', and show what
they look like."
  (interactive)
  (with-help-window "*Chayote Colors*"
    (with-current-buffer standard-output
      (erase-buffer)
      (dolist (color palette)
        (let* ((name (symbol-name (first color)))
               (value (second color)))
          (put-text-property 0 (length name)
                             'font-lock-face `(:foreground ,value)
                             name)
          (insert name)
          (insert (propertize " " 'display '(space :align-to (- right 9))))
        (insert " ")
          (put-text-property 0 (length value)
                             'font-lock-face `(:background ,value)
                             value)
        (insert value)
          (terpri)))
      (set-buffer-modified-p nil)
      (setq truncate-lines t))))
#+END_SRC

#+BEGIN_SRC elisp
(with-palette
  (custom-theme-set-faces
   'chayote
   `(default ((,class (:foreground ,white-1 :background ,black-5 :family "Terminus" :height 90))))
   `(cursor ((,class (:background ,white-0))))

   `(link ((,class (:foreground ,blue-1 :underline t))))

   ;; Highlighting faces
   `(highlight ((,class (:background ,black-3))))
   `(hl-line ((,class (:background ,black-4))))
   `(highlight-symbol-face ((,class (:background ,green-5))))
   `(region ((,class (:background ,blue-4))))
   `(secondary-selection ((,class (:background ,blue-3 :foreground ,white-0))))
   `(isearch ((,class (:foreground ,white-1 :background ,orange-3))))
   `(lazy-highlight ((,class (:background ,magenta-3 :foreground ,white-1))))
   `(trailing-whitespace ((,class (:background ,red-3))))
   `(show-paren-match ((,class (:background ,blue-3 :foreground nil))))
   `(header-line ((,class (:background ,blue-3 :foreground ,white-0))))
   `(help-argument-name ((,class (:foreground ,magenta-1 :italic t))))
   `(eldoc-highlight-function-argument ((,class (:foreground ,green-01 :bold t :underline t :background ,green-5))))

   ;; Mode line & frames' faces
   `(mode-line ((,class (:box nil :background ,white-1 :foreground ,black-5))))
   `(mode-line-inactive ((,class (:background ,white-3 :foreground ,black-5))))
   `(mode-line-buffer-id ((,class (:box nil :foreground ,black-5 :background nil))))
   `(vertical-border ((,class (:foreground ,black-3 :background ,black-3))))

   ;; Escape and prompt faces
   `(minibuffer-prompt ((,class (:foreground ,blue-1))))
   `(escape-glyph ((,class (:foreground ,yellow-3))))
   `(error ((,class (:foreground ,red-0))))
   `(warning ((,class (:foreground ,orange-1))))
   `(success ((,class (:foreground ,green-1))))

   ;; Font lock faces
   `(font-lock-builtin-face ((,class (:foreground ,cyan-1))))
   `(font-lock-comment-delimiter-face ((,class (:inherit font-lock-comment-face))))
   `(font-lock-comment-face ((,class (:foreground ,orange-2))))
   `(font-lock-constant-face ((,class (:foreground ,cyan-2))))
   `(font-lock-doc-face ((,class (:inherit font-lock-string-face))))
   `(font-lock-doc-string-face ((,class (:inherit font-lock-string-face))))
   `(font-lock-function-name-face ((,class (:foreground ,blue-0))))
   `(font-lock-keyword-face ((,class (:foreground ,blue-1))))
   `(font-lock-negation-char-face ((,class (:foreground ,red-0))))
   `(font-lock-preprocessor-face ((,class (:inherit font-lock-builtin-face))))
   `(font-lock-regexp-grouping-backslash ((,class (:foreground ,yellow-1))))
   `(font-lock-regexp-grouping-construct ((,class (:foreground ,purple-1))))
   `(font-lock-string-face ((,class (:foreground ,orange-1))))
   `(font-lock-type-face ((,class (:foreground ,green-1))))
   `(font-lock-variable-name-face ((,class (:foreground ,yellow-1))))
   `(font-lock-warning-face ((,class (:weight bold :foreground ,red-2))))

   ;; company
   `(company-tooltip ((,class (:background ,black-4))))
   `(company-scrollbar-bg ((,class (:background ,black-4))))
   `(company-scrollbar-fg ((,class (:background ,orange-2))))
   `(company-tooltip-selection ((,class (:background ,black-3))))
   `(company-tooltip-common ((,class (:foreground ,blue-1))))
   `(company-tooltip-annotation ((,class (:foreground ,cyan-1))))

   ;; org-mode
   `(org-block ((,class (:foreground ,white-1 :background ,black-4))))
   `(org-block-begin-line ((,class (:foreground ,black-3))))
   `(org-verbatim ((,class (:foreground ,blue-1 :background ,black-4))))
   `(org-link ((,class (:inherit link))))
   `(org-warning ((,class (:foreground ,white-0 :background ,red-4))))

   ;; erc
   `(erc-input-face ((,class (:foreground ,white-1)))))

  (custom-theme-set-variables
   'chayote
   `(ansi-color-names-vector [,black-5 ,red-0 ,green-0 ,yellow-1
                              ,blue-1 ,purple-1 ,blue-0 ,white-1])))
#+END_SRC

** Modeline

This is the vanilla modeline without the handful of components that I consider
unimportant.

#+BEGIN_SRC elisp
(setq-default mode-line-format
              '("%e"
                mode-line-front-space
                mode-line-client
                mode-line-modified
                " "
                mode-line-directory
                mode-line-buffer-identification
                " "
                mode-line-position
                " "
                mode-line-modes
                mode-line-misc-info
                mode-line-end-spaces))
#+END_SRC

To make things a little easier on my eyes, I've chosen to add visual separation
between my additions to the modeline.

#+BEGIN_SRC elisp
(defconst mode-line-separator " | "
  "A separator to place between components of the modeline.")
#+END_SRC

A function to simplify the addition of new =:eval= forms to the end of
=mode-line-format=.

#+BEGIN_SRC elisp
(defun add-to-mode-line (widget)
  "Appends a `MODE-LINE-SEPARATOR' and `WIDGET' onto the end of
`MODE-LINE-FORMAT'."
  (let ((eval-form `(:eval (funcall ,widget))))
    (setq-default mode-line-format
                  (append mode-line-format
                          (list mode-line-separator eval-form)))))
#+END_SRC

My implementation of a clock for the modeline. The modeline is refreshed by a
timer to ensure that it doesn't go too stale, as it could theoretically go
several minutes without being updated.

#+BEGIN_SRC elisp
(add-to-mode-line
 (lambda () (format-time-string "%Y-%m-%d %H:%M")))

(let ((timer (run-at-time t 60.0 #'ignore)))
  (timer-set-function timer
                      (lambda ()
                        (force-mode-line-update))))
#+END_SRC

My implementation of a battery monitor for the modeline. Because strings in
=mode-line-format= can contain control sequences, the percent symbol has to be
escaped twice -- once for =battery-format=, and once for =mode-line-format=.

#+BEGIN_SRC elisp
(use-package battery
  :straight nil
  :config
  (add-to-mode-line
   (lambda ()
     (let* ((status (battery-linux-sysfs))
            (fullness (string-to-number (cdr (assoc 112 status))))
            (text (battery-format "%L: %t, %p%%%%" status))
            (low-battery-face '(:foreground "white"
                                :background "red")))
       (when (< fullness 10.0)
         (put-text-property 0 (length text)
                            'font-lock-face low-battery-face
                            text))
       text))))
#+END_SRC

** Pretty Symbols

Enable =prettify-symbols= globally.

#+BEGIN_SRC elisp
(global-prettify-symbols-mode t)
#+END_SRC

This is snippet was taken verbatim from [[https://emacs.stackexchange.com/questions/17283/is-it-possible-to-get-prettified-symbols-in-org-mode-source-blocks][Emacs StackExchange]] to enable
=prettify-symbols= in Org source code blocks. Sadly, I can't think of a way to
implement this as advice.

#+BEGIN_SRC elisp
(defun org-src-font-lock-fontify-block (lang start end)
  "Fontify code block.
This function is called by emacs automatic fontification, as long
as `org-src-fontify-natively' is non-nil."
  (let ((lang-mode (org-src--get-lang-mode lang)))
    (when (fboundp lang-mode)
      (let ((string (buffer-substring-no-properties start end))
        (modified (buffer-modified-p))
        (org-buffer (current-buffer)) pos next)
    (remove-text-properties start end '(face nil))
    (with-current-buffer
        (get-buffer-create
         (concat " org-src-fontification:" (symbol-name lang-mode)))
      (delete-region (point-min) (point-max))
      (insert string " ") ;; so there's a final property change
      (unless (eq major-mode lang-mode) (funcall lang-mode))
      ;; Avoid `font-lock-ensure', which does not display fonts in
      ;; source block.
      (font-lock-fontify-buffer)
      (setq pos (point-min))
      (while (setq next (next-single-property-change pos 'face))
        (put-text-property
         (+ start (1- pos)) (1- (+ start next)) 'face
         (get-text-property pos 'face) org-buffer)
        (setq pos next))
      ;; Addition: also copy 'composition info for prettified symbols
      (setq pos (point-min))
      (while (setq next (next-single-property-change pos 'composition))
        (put-text-property
         (+ start (1- pos)) (1- (+ start next)) 'composition
         (get-text-property pos 'composition) org-buffer)
        (setq pos next))
      ;; End addition
      )
    (add-text-properties
     start end
     '(font-lock-fontified t fontified t font-lock-multiline t))
    (set-buffer-modified-p modified)))))
#+END_SRC

** dim

[[https://www.emacswiki.org/emacs/DelightedModes][Delight]] doesn't work for me, and [[https://github.com/myrjola/diminish.el][diminish]] is sadly lacking in the feature
department, so I'm choosing to clean up my modeline with dim. =use-package=
doesn't have an equivalent of =:diminish= or =:delight=, so the declarations occur
here.

#+BEGIN_SRC elisp
(use-package dim
  :config
  (dim-minor-name 'visual-line-mode "")
  (dim-minor-name 'ivy-mode ""))
#+END_SRC

* Window Management

Yes, I use Emacs as my window manager. You should try it out some time!

#+BEGIN_SRC elisp
(use-package exwm-config
  :straight nil
  :after exwm)

(use-package exwm
  :config
  (exwm-enable)
#+END_SRC

I find that four workspaces is enough to start out with. I liked being able to
use my X windows across workspaces, but this doesn't play nicely with
=counsel-switch-buffer=.

#+BEGIN_SRC elisp
  :init
  (setq exwm-workspace-number 4)
#+END_SRC

"Global key bindings" in EXWM work essentially anywhere, including buffers that
are currently in char mode. The bindings below should be fairly straightforward.
I've taken this as an opportunity to incorporate windmove to my workflow, now
that I have the super key at my disposal. The choice of keys for that was
inspired by the WASD movement typical of first-person shooter games.

#+BEGIN_SRC elisp
  :init
  (setq exwm-input-global-keys
        `(([?\s-r] . exwm-reset)
          ([?\s-w] . windmove-up)
          ([?\s-a] . windmove-left)
          ([?\s-s] . windmove-down)
          ([?\s-d] . windmove-right)
          ([?\s-p] . (lambda (command)
                       (interactive (list (read-shell-command "$ ")))
                       (start-process-shell-command command nil command)))
          ([?\s-X] . (lambda ()
                       (interactive)
                       (start-process "" nil "/usr/bin/slock")))
          ([?\s-f] . (lambda ()
                       (interactive)
                       (start-process "" nil "/usr/bin/firefox")))
          ([?\s-m] . (lambda ()
                       (interactive)
                       (start-process "" nil "/usr/bin/kitty" "--class" "mutt" "/usr/bin/mutt")))
          (,(kbd "s-<return>") . (lambda ()
                                   (interactive)
                                   (start-process "" nil "/usr/bin/kitty")))

          ;; Keys are offset such that <s-1> corresponds to the 0th workspace.
          ,@(mapcar (lambda (i)
                      `(,(kbd (format "s-%d" i)) .
                        (lambda ()
                          (interactive)
                          (exwm-workspace-switch-create ,(- i 1)))))
                    (number-sequence 1 9))))
#+END_SRC

Ah, yes. Simulation keys, the real reason I decided to install EXWM.

#+BEGIN_SRC elisp
  :init
  (setq exwm-input-simulation-keys
        '(([?\C-b] . [left])
          ([?\M-b] . [C-left])
          ([?\C-f] . [right])
          ([?\M-f] . [C-right])
          ([?\C-p] . [up])
          ([?\C-n] . [down])
          ([?\C-a] . [home])
          ([?\C-e] . [end])
          ([?\M-v] . [prior])
          ([?\C-v] . [next])
          ([?\C-d] . [delete])
          ([?\C-k] . [S-end delete])

          ([?\C-w] . [?\C-x])
          ([?\M-w] . [?\C-c])
          ([?\C-y] . [?\C-v])

          ([?\C-s] . [?\C-f])))
#+END_SRC

The tab switching functionality of Saka Key is pretty limited, so I'm using
simulation keys for tab switching. Simulation keys is also disabled for kitty
because it gets in the way of readline.

#+BEGIN_SRC elisp
  :hook
  (exwm-manage-finish . (lambda ()
                          (when (and exwm-class-name
                                     (string= exwm-class-name "Firefox"))
                            (exwm-input-set-local-simulation-keys
                             (concatenate 'list
                                          exwm-input-simulation-keys
                                          '(([?\C-q] . [?\C-w])))))
                          (when (and exwm-class-name
                                     (or
                                      (string= exwm-class-name "kitty")
                                      (string= exwm-class-name "mutt")))
                            (exwm-input-set-local-simulation-keys nil))))
#+END_SRC

EXWM's buffers are named =*EXWM*= upon creation, which makes switching between
windows a pain. This snippet renames buffers when their class or title changes.

#+BEGIN_SRC elisp
  :hook
  (exwm-update-class . (lambda ()
                         (exwm-workspace-rename-buffer exwm-class-name)))
  (exwm-update-title . (lambda ()
                         (when (not exwm-instance-name)
                           (exwm-workspace-rename-buffer exwm-title))))
#+END_SRC

Start the Emacs daemon so that =emacsclient= can be used from the command line
to pop a new buffer for editing.

#+BEGIN_SRC elisp
  :config
  (server-start))
#+END_SRC

EXWM has issues popping any sort of pinentry window, so we'll just let Emacs do
pinentry's job.

#+BEGIN_SRC elisp
(use-package epa
  :straight nil
  :config
  (setq epa-pinentry-mode 'loopback))
#+END_SRC

* System

** ag

#+BEGIN_SRC elisp
(use-package ag
  :bind
  ("C-c k" . counsel-ag))
#+END_SRC

** Dired

Hide the targets of symbolic links in dired listings. This is just a visual
preference of mine.

#+BEGIN_SRC elisp
(use-package dired
  :straight nil
  :init
  (setq-default dired-listing-switches "-alL"))
#+END_SRC

** Tramp

Preference of hygene. See [[Filesystem]].

#+BEGIN_SRC elisp
(use-package tramp
  :straight nil
  :init
  (setq-default tramp-persistency-file-name "~/.cache/emacs/tramp"))
#+END_SRC

#+BEGIN_SRC elisp
(use-package nsm
  :straight nil
  :init
  (setq nsm-settings-file "/home/jakob/.emacs.d/network-security.data"))
#+END_SRC

* Documents

** Org

Preference of hygene. See [[Filesystem]]. Org is also forcefully loaded because
there are a number of things declared via =:config= that I want run as soon as
Emacs starts.

#+BEGIN_SRC elisp
(use-package org
  :straight nil
  :demand t
  :init
  (setq-default org-id-locations-file "~/.cache/emacs/org-id-locations")
  (setq-default org-latex-preview-ltxpng-directory "~/.cache/emacs/ltximg/")
  (setq-default org-preview-latex-image-directory "~/.cache/emacs/ltximg/")
#+END_SRC

Only load the =org-contrib= modules that I actually use.

#+BEGIN_SRC elisp
  :init
  (setq org-modules '(org-drill))
#+END_SRC

Some general configurations for quality-of-life and appearance.

#+BEGIN_SRC elisp
  :init
  (setq org-return-follows-link t)
  (setq org-startup-folded nil)
  (setq org-startup-with-inline-images t)
  (setq org-hide-emphasis-markers t)
  (setq org-tags-column 100)
#+END_SRC

Don't indent text following a headline.

#+BEGIN_SRC elisp
  :init
  (setq org-adapt-indentation nil)
#+END_SRC

Fix =org-src= blocks such that <tab> indents according to the mode's indentation
rules, and so that there is no implicit indentation of the source code ([[https://stackoverflow.com/questions/15773354/indent-code-in-org-babel-src-blocks][1]], [[https://emacs.stackexchange.com/questions/9472/org-mode-source-block-doesnt-respect-parent-buffer-indentation][2]]).

#+BEGIN_SRC elisp
  :init
  (setq org-src-tab-acts-natively t)
  (setq org-edit-src-content-indentation 0)
#+END_SRC

Just reuse the current window when I punch in =C-c '=, rather than mess up my
window configuration.

#+BEGIN_SRC elisp
  :init
  (setq org-src-window-setup 'current-window)
#+END_SRC

Scale up embedded LaTeX so that I can actually read it.

#+BEGIN_SRC elisp
  :config
  (setq org-format-latex-options
        (plist-put org-format-latex-options :scale 1.5))
#+END_SRC

Enable [[Yasnippet]].

#+BEGIN_SRC elisp
  :hook
  (org-mode . yas-minor-mode-on)
#+END_SRC

Replace my [[Imenu]] binding with =org-goto=, as it allows me to select headings with
subheadings. Keybindings for working with my Org workflow from anywhere are also
here, since =use-package= doesn't like split =:bind= declarations.

#+BEGIN_SRC elisp
  :init
  (setq org-goto-interface 'outline-path-completionp)
  (setq org-outline-path-complete-in-steps nil)

  :bind
  (("C-c a" . (lambda () (interactive) (org-agenda nil "d")))
   ("C-c c" . (lambda () (interactive) (org-capture nil "c")))
   ("C-c t" . (lambda () (interactive) (org-capture nil "t")))
   :map org-mode-map
   ("C-c s" . org-goto)
   ("C-c C-q" . counsel-org-tag))
#+END_SRC

*** Workflow

Automatically open a buffer named =*Mind Dump*= to, well, save all of my
thoughts. They're dated and saved in a directory so I can =ag= them. This is the
closest thing I will ever have to an implementation of =ag= for my thoughts.

#+BEGIN_SRC elisp
  :init
  (defvar mind-dump-directory "~/Notes/Mind Dumps"
    "Where to store dated 'mind dump' files.")

  (defun mind-dump-filename ()
    "Returns the path of today's 'mind dump' file."
    (concatenate 'string
                 (file-name-as-directory mind-dump-directory)
                 (format-time-string "%Y-%m-%d")
                 ".org"))

  :config
  (let* ((buffer (find-file-noselect (mind-dump-filename))))
    (set-buffer buffer)
    (rename-buffer "*Mind Dump*"))
#+END_SRC

*** Personal Wiki

I maintain somewhat of a "personal wiki" using Org and I like to link between
pages. This is just a convenience link type, rooted at the base of my notes
folder so that I can easily refer to other pages from subdirectories of
=notes-directory=.

#+BEGIN_SRC elisp
  :config
  (defvar notes-directory "~/Notes"
    "Where all the pages of my 'personal wiki' are stored.")

  (defun org-notes-follow (link)
    "Visits LINK, or if LINK names a subdirectory of
  `notes-directory', the 'Index.org' in LINK."
    (let ((directory-p (file-directory-p (expand-file-name link notes-directory))))
      (find-file (expand-file-name (if directory-p "Index.org" (concat link ".org"))
                                   notes-directory))))

  (org-link-set-parameters "note" :follow #'org-notes-follow)
#+END_SRC

Code for generating hierarchical category listings.

#+BEGIN_SRC elisp
  :config
  (defvar notes-directory-ignore
    '("." ".." ".git" ".gitignore" "Drill"
      "Finance" "GTD" "Interviewing" "Mind Dumps")
    "Files and directories in `notes-directory' to exclude from
  wiki interactions.")

  (defun insert-notes-hierarchy (&optional current indent)
    "Inserts an unordered Org list filled with links representing
  the hierarchy of `current'. Useful for generating index pages."
    (interactive)
    (let* ((current (or current "."))
           (indent (or indent ""))
           (path (expand-file-name current notes-directory))
           (files (remove-if #'(lambda (file) (member file notes-directory-ignore))
                             (directory-files path))))
      (dolist (file files)
        (when (not (string= file "Index.org"))
          (let* ((name (if (string= (subseq file (- (length file) 4)) ".org")
                           (subseq file 0 (- (length file) 4))
                         file))
                 (name (if (string= current ".")
                           name
                         (concat current "/" name)))
                 (path (expand-file-name name notes-directory)))
            (if (file-directory-p path)
                (let ((index-path (concat path "/Index.org")))
                  (insert (if (file-exists-p index-path)
                              (format "%s- [[note:%s/Index.org][%s]]" indent name name)
                            (format "%s- %s" indent name)))
                  (newline)
                  (insert-notes-hierarchy name (concat "  " indent)))
              (progn
                (insert (format "%s- [[note:%s][%s]]" indent name name))
                (newline))))))))
#+END_SRC

*** Capture

Low-friction of adding things to the day's "mind dump" and my GTD inbox.

#+BEGIN_SRC elisp
  :config
  (setq org-capture-templates
        `(("c" "Thought" plain (file ,(mind-dump-filename))
           "%?\n")
          ("t" "TODO" entry (file "~/Notes/GTD/Inbox.org")
           "* TODO %?\n")))
#+END_SRC

*** Agenda

Rather convoluted agenda setup to show me:
- The tasks I've marked as needing to be done today.
- The inbox items I need to process.
- My daily habits (implemented as recurring Org TODO's).
- A view of deadlines and scheduled items for the week ahead.

#+BEGIN_SRC elisp
  :init
  (setq org-agenda-files '("~/Notes/GTD/Habits.org"
                           "~/Notes/GTD/Inbox.org"
                           "~/Notes/GTD/Actionable.org"))

  (let ((entry-done
         '(lambda () (org-agenda-skip-entry-if 'todo 'done)))

        (subtree-is-habit
         '(lambda ()
            (let ((subtree-end (save-excursion (org-end-of-subtree t))))
              (if (string= (org-entry-get nil "STYLE") "habit")
                  subtree-end
                nil))))

        (subtree-is-not-habit
         '(lambda ()
            (let ((subtree-end (save-excursion (org-end-of-subtree t))))
              (if (not (string= (org-entry-get nil "STYLE") "habit"))
                  subtree-end
                nil))))

        (subtree-is-not-inbox
         '(lambda ()
            (let ((subtree-end (save-excursion (org-end-of-subtree t))))
              (if (not (search "Inbox.org" (buffer-name)))
                  subtree-end
                nil)))))

    (setq org-agenda-custom-commands
          `(("d" "Daily"
             ((tags "PRIORITY=\"A\""
                    ((org-agenda-skip-function ,entry-done)
                     (org-agenda-overriding-header "Tasks for Today:")))
              (alltodo ""
                       ((org-agenda-skip-function ,subtree-is-not-inbox)
                        (org-agenda-overriding-header "Inbox:")))
              (agenda ""
                      ((org-agenda-span 'day)
                       (org-agenda-skip-function ,subtree-is-not-habit)
                       (org-deadline-warning-days 0)
                       (org-agenda-overriding-header "Habits:")))
              (agenda ""
                      ((org-agenda-span 'week)
                       (org-agenda-skip-function ,subtree-is-habit)
                       (org-agenda-overriding-header "Week Ahead:"))))
             ((org-agenda-compact-blocks t))))))
#+END_SRC

*** Drill

Scan the directory of the current buffer's file for other items -- this is so
that I can spread my cards across multiple files and still be tested on all of
them when I run =org-drill=. Combining topic during review sessions is
recommended by Michael Nielsen in his article, [[http://augmentingcognition.com/ltm.html]["Augmenting Long-term Memory"]].

#+BEGIN_SRC elisp
  :init
  (setq org-drill-scope 'directory)
#+END_SRC

Shut up the nagging "are you studying enough!?" message if I don't get enough
items right on the first try. It's unhelpful and really just annoying.

#+BEGIN_SRC elisp
  :init
  (setq org-drill-forgetting-index 100))
#+END_SRC

*** Blog

#+BEGIN_SRC elisp
;; (use-package ox-hugo
;;   :straight nil)
#+END_SRC

** pdf-tools

doc-view= is unbearable for reading PDF's of any considerable size and
=pdf-tools= brings a number of significant improvements, so I can justify not
using the built-in solution. Even though I can run MuPDF in an [[EXWM]] buffer, the
integration in terms of searching and viewing attachments that comes with
=pdf-tools= makes for a much more pleasant experience.

#+BEGIN_SRC elisp
(use-package pdf-tools
  :config
  (pdf-loader-install))
#+END_SRC
* IRC

Only load the modules I actually use. This list deviates from the default by
including =truncate=, but omitting =autojoin=.

#+BEGIN_SRC elisp
(use-package erc
  :straight nil
  :config
  (setq erc-modules '(button completion fill
                      irccontrols list match
                      menu move-to-prompt netsplit
                      networks noncommands readonly
                      ring stamp track truncate))
  (erc-update-modules)
#+END_SRC

Begin with unimportant channels silenced by default.

#+BEGIN_SRC elisp
  :config
  (silence-channels)
#+END_SRC

Configure some personal details.

#+BEGIN_SRC elisp
  :init
  (setq erc-nick '("jakob" "tsarfox")
        erc-user-full-name "Jakob <http://jakob.space>"
        erc-quit-reason (lambda (reason)
                          (or reason (concat "Program received signal "
                                             "SIGSEGV, Segmentation fault."))))
#+END_SRC

Have the prompt display my current nick.

#+BEGIN_SRC elisp
  :init
  (setq erc-prompt (lambda () (format "%s>" (erc-current-nick))))
#+END_SRC

Center everything nicely in the buffer.

#+BEGIN_SRC elisp
  :init
  (setq erc-fill-function 'erc-fill-static
        erc-fill-column 100
        erc-fill-static-center 22)
#+END_SRC

Enable interpretation of MIRC and control sequences so I can appreciate the
occasional figlet spam.

#+BEGIN_SRC elisp
  :init
  (setq erc-interpret-controls-p t
        erc-interpret-mirc-color t)
#+END_SRC

Enable timestamps, and show them to the left of the messages.

#+BEGIN_SRC elisp
  :init
  (setq erc-hide-timestamps nil
        erc-insert-timestamp-function 'erc-insert-timestamp-left)
#+END_SRC

Although =log= is omitted from =erc-modules=, I still explicitly disable
logging. If I want to save a conversation, I'll just save the buffer.

#+BEGIN_SRC elisp
  :init
  (setq erc-enable-logging nil
        erc-save-buffer-on-part nil)
#+END_SRC

=autowaway= is also omitted from =erc-modules=, but I'm explicitly disabling it.

#+BEGIN_SRC elisp
  :init
  (setq erc-auto-set-away nil
        erc-auto-discard-away nil)
#+END_SRC

Kill buffers when I disconnect.

#+BEGIN_SRC elisp
  :init
  (setq erc-kill-buffer-on-part t
        erc-kill-queries-on-quit t
        erc-kill-server-buffer-on-quit t)
#+END_SRC

Don't get in my way by popping new windows when someone queries me, and don't
assault me with windows when I connect to my bouncer.

#+BEGIN_SRC elisp
  :init
  (setq erc-auto-query 'bury
        erc-join-buffer 'bury)
#+END_SRC

People think I'm insane because I am frowning all the time
All day long, I think of things, but nothing seems to satisfy
Think I'll lose my mind if I don't find something to pacify

#+BEGIN_SRC elisp
  :init
  (setq erc-paranoid t)
#+END_SRC

Don't bother me with stuff I don't care about.

#+BEGIN_SRC elisp
  :init
  (setq erc-track-exclude-server-buffer t
        erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE"
                                  "324" "329" "332" "333" "353" "477"))
#+END_SRC

Configure ignoring of people not contributing to the conversation.

#+BEGIN_SRC elisp
  :init
  (setq erc-lurker-hide-list '("JOIN" "PART" "QUIT")
        erc-lurker-threshold-time 3600)
#+END_SRC

Enable channel tracking.

#+BEGIN_SRC elisp
  :config
  (erc-track-minor-mode 1)
  (erc-track-mode 1)
#+END_SRC

Move to the prompt when I begin typing, since I've configured the buffer text
preceding it to be read-only.

#+BEGIN_SRC elisp
  :config
  (erc-move-to-prompt-enable)
#+END_SRC

Let =erc-fill= handle filling.

#+BEGIN_SRC elisp
  :hook
  (erc-mode . (lambda () (auto-fill-mode 0)))
#+END_SRC

Hook for automatically identifying with [[IRC][Bitlbee]].

#+BEGIN_SRC elisp
  :hook
  (erc-join . bitlbee-identify)
#+END_SRC

Sadly =:bind= is limited when it comes to defining keystrokes with prefixes, so
I've done it manually here. These are the more frequently used of the functions
in [[IRC]].

#+BEGIN_SRC elisp
  :config
  (defvar irc-map (make-sparse-keymap)
    "Prefix keymap for bindings related to IRC.")
  (bind-key "C-c i" irc-map)
  (dolist (chord '("C-c i b"
                   "C-c i c"
                   "C-c i f"
                   "C-c i i"
                   "C-c i s"
                   "C-c i q"
                   "C-c i u"))
    (bind-key chord irc-map))

  (bind-key "C-c i b" #'irc-switch-buffer)
  (bind-key "C-c i c" (lambda ()
                        (interactive)
                        (clear-irc-buffer)
                        (message "Backlog cleared.")))
  (bind-key "C-c i f" #'clear-erc-track-list)
  (bind-key "C-c i i" #'ignore-channel)
  (bind-key "C-c i s" #'irc)
  (bind-key "C-c i q" #'irc-quit)
  (bind-key "C-c i u" #'unignore-channel)
#+END_SRC

Binds that aren't part of a prefix map are fine, though.

#+BEGIN_SRC elisp
:bind (:map erc-mode-map
       ("C-c C-f" . irc-cycle-forward)
       ("C-c C-b" . irc-cycle-backward)))
#+END_SRC

Ensure a package for colorizing nicks.

#+BEGIN_SRC elisp
(use-package erc-hl-nicks
  :after erc
  :config
  (erc-hl-nicks-enable))
#+END_SRC

Ensure a package for starting an instance of Bitlbee.

#+BEGIN_SRC elisp
(use-package bitlbee
  :init
  (setq bitlbee-user-directory "~/.config/bitlbee/"))
#+END_SRC

* RSS

Preference of hygene. See [[Filesystem]].

#+BEGIN_SRC elisp
(use-package elfeed
  :init
  (setq elfeed-db-directory "~/.local/share/elfeed"))
#+END_SRC

Configure Elfeed to sync with the instance of Tiny Tiny RSS I use.

#+BEGIN_SRC elisp
(use-package elfeed-protocol
  :config
  (setq elfeed-feeds (list (list "ttrss+https://jakob@rss.tildeverse.org"
                                 :use-authinfo t)))
  (elfeed-protocol-enable))
#+END_SRC

* Programming Tools

** dumb-jump

Replace =xref= keybindings instead of using the default ones, since I'm nearly
always using =dumb-jump= instead of a proper tag indexer.

#+BEGIN_SRC elisp
(use-package dumb-jump
  :config
  (define-key dumb-jump-mode-map (kbd "C-M-g") nil)
  (define-key dumb-jump-mode-map (kbd "C-M-p") nil)
  (define-key dumb-jump-mode-map (kbd "C-M-q") nil)
  (define-key dumb-jump-mode-map (kbd "M-.") #'dumb-jump-go)
  (define-key dumb-jump-mode-map (kbd "M-,") #'dumb-jump-back)
  (dumb-jump-mode))
#+END_SRC

** company

Start suggesting completions ASAP.

#+BEGIN_SRC elisp
(use-package company
  :config
  (setq company-idle-delay 0)
  (setq company-minimum-prefix-length 3)
#+END_SRC

Use standard movement keys instead of those used for minibuffer next/previous.

#+BEGIN_SRC elisp
  :bind
  (:map company-active-map
   ("M-n" . nil)
   ("M-p" . nil)
   ("C-n" . #'company-select-next)
   ("C-p" . #'company-select-previous)))
#+END_SRC

** compile

#+BEGIN_SRC elisp
(use-package compile
  :straight nil

  :bind
  ("<f12>" . compile)
#+END_SRC

The compilation command can be set by invoking =compile= with a prefix argument,
so I don't see a need in popping a prompt every time. [[https://www.emacswiki.org/emacs/CompileCommand][(1)]].

#+BEGIN_SRC elisp
  :init
  (setq compilation-read-command nil)
#+END_SRC

Hide the compilation buffer upon successful compilation, because I typically
don't care about the output unless there were errors.

#+BEGIN_SRC elisp
  :config
  (add-hook 'compilation-finish-functions
            (lambda (buf strg)
              (let ((win  (get-buffer-window buf 'visible)))
                (when win (delete-window win))))))
#+END_SRC

** Flycheck

#+BEGIN_SRC elisp
(use-package flycheck)
#+END_SRC

** Magit

#+BEGIN_SRC elisp
(use-package magit
  :bind ("C-c g" . magit-status))
#+END_SRC

** Projectile

#+BEGIN_SRC elisp
(use-package projectile
  :demand t

  :init
  (setq projectile-completion-system 'ivy)
  (setq projectile-known-projects-file "~/.local/share/projectile-bookmarks.eld")

  :bind
  ("C-c C-x C-f" . projectile-find-file)
  ("C-c C-x C-p" . projectile-switch-project))
#+END_SRC

* Programming Languages

** Language Server Protocol

The reason I'm using =lsp-mode= in the first place is to integrate with the
packages I've set up in [[Programming Tools]], so use that instead of the provided
machinery.

#+BEGIN_SRC elisp
(use-package lsp-mode
  :init
  (setq lsp-prefer-flymake nil)
  (setq lsp-enable-xref t)
  (setq lsp-session-file "~/.cache/emacs/.lsp-session-v1")
  (setq lsp-auto-guess-root t)

  :bind
  (:map lsp-mode-map
   ("M-." . lsp-find-definition)
   ("M-," . pop-tag-mark)))

(use-package company-lsp
  :requires company
  :commands company-lsp

  :init
  (setq company-lsp-cache-candidates 'auto))
#+END_SRC


The only reason I'm using =lsp-ui= is for integration with [[Flycheck]]. The features
like lenses don't interest me.

#+BEGIN_SRC elisp
(use-package lsp-ui
  :init
  (setq lsp-ui-sideline-enable nil)
  (setq lsp-ui-peek-enable nil)
  (setq lsp-ui-doc-enable nil))
#+END_SRC

** Rust

Enable [[company]], ElDoc, and racer.

#+BEGIN_SRC elisp
(use-package racer
  :init
  (setq racer-cmd "~/.cargo/bin/racer")
  (setq racer-rust-src-path "~/Code/rust/src")

  :hook
  (racer-mode . eldoc-mode)
  (racer-mode . company-mode))

(use-package rust-mode
  :hook
  (rust-mode . racer-mode)
#+END_SRC

Run =rustfmt= automatically.

#+BEGIN_SRC elisp
  :init
  (setq rust-format-on-save t))
#+END_SRC

Enable flycheck.

#+BEGIN_SRC elisp
(use-package flycheck-rust
  :after rust-mode

  :hook
  (flycheck-mode . flycheck-rust-setup)
  (rust-mode . flycheck-mode))
#+END_SRC

** C

Generally, I adhere to the [[https://www.kernel.org/doc/html/v4.10/process/coding-style.html][Linux kernel coding style]].

#+BEGIN_SRC elisp
(use-package cc-mode
  :straight nil
  :hook
  (c-mode . (lambda () (c-set-style "linux")))
#+END_SRC

Enable [[company]], [[Flycheck]], and ElDoc, provided by =irony-mode=.

#+BEGIN_SRC elisp
  :hook
  (c-mode . company-mode)
  (c-mode . flycheck-mode)
  (c-mode . eldoc-mode))

(use-package irony
  :hook
  (c-mode . irony-mode)
  (irony-mode . irony-cdb-autosetup-compile-options))

(use-package company-irony
  :config
  (add-to-list 'company-backend 'company-irony))

(use-package flycheck-irony
  :hook
  (flycheck-mode . flycheck-irony-setup))

(use-package irony-eldoc
  :hook
  (irony-mode . irony-eldoc))
#+END_SRC

** Emacs Lisp

Enable [[company]].

#+BEGIN_SRC elisp
(use-package elisp-mode
  :straight nil
  :hook
  (lisp-interaction-mode . company-mode)
  (emacs-lisp-mode . company-mode)
#+END_SRC

Don't omit information when lists nest too deep.

#+BEGIN_SRC elisp
  :init
  (setq eval-expression-print-level nil))
#+END_SRC

Helpful is a wonderful improvement upon the vanilla =describe-.*= functions,
showing source code, keybindings, symbol properties, and more.

#+BEGIN_SRC elisp
(use-package helpful
  :bind (("C-h f" . helpful-callable)
         ("C-h v" . helpful-variable)
         ("C-h k" . helpful-key)
         ("C-h C" . helpful-command)
         ("C-c C-d" . helpful-at-point)))
#+END_SRC

** Common Lisp

SLIME is my preferred REPL for working with Common Lisp.

#+BEGIN_SRC elisp
(use-package slime
  :config
  (setq inferior-lisp-program "/usr/bin/sbcl")
  (setq slime-contribs '(slime-fancy)))
#+END_SRC

** Scheme

Configuration for using the [[https://wiki.call-cc.org/emacs#builtin-scheme-support][best Scheme implementation]].

#+BEGIN_SRC elisp
(use-package xscheme
  :straight nil
  :init
  (setq scheme-program-name "csi -:c")
#+END_SRC

Redefinition of =xscheme-default-command-line= so that '-emacs' is not passed to
=csi=, since it doesn't recognize the argument and complains about it.

#+BEGIN_SRC elisp
  :config
  (defun xscheme-default-command-line ()
    (concat scheme-program-name
        (if scheme-program-arguments
            (concat " " scheme-program-arguments)
            "")
        (if scheme-band-name
            (concat " -band " scheme-band-name)
            ""))))
#+END_SRC

** Javascript

Use a [[Language Server Protocol]] daemon.

#+BEGIN_SRC elisp
(use-package js
  :straight nil
  :requires lsp-mode
  :hook (js-mode . lsp)

  :config
  (lsp-register-client
   (make-lsp-client :new-connection (lsp-stdio-connection "~/.bin/js-ts-stdio")
                    :major-modes '(js-mode)
                    :server-id 'js-ts-stdio))
#+END_SRC

#+BEGIN_SRC elisp
  :init
  (setq-default js-indent-level 2))
#+END_SRC

* Custom Functionality

This section is for any nontrivial Elisp functions written by me.

** Utilities

A wrapper for =completing-read= that passes in an argument for DEF.

#+BEGIN_SRC elisp
(defun completing-read-with-default (prompt collection default)
  "Invoke `completing-read' with DEFAULT as the DEF argument."
  (completing-read prompt collection nil nil nil nil default))
#+END_SRC

** IRC

Convenience functions for connecting to and authenticating with my IRC bouncer.

#+BEGIN_SRC elisp
(defun read-bouncer-password ()
  "Get the password for my bouncer from authinfo"
  (let ((auth (auth-source-search :host "jakob.space" :user "jakob" :port 26969)))
    (unless auth
      (error "No auth entry for bouncer."))
    (let ((secretf (plist-get (car auth) :secret)))
      (unless secretf
        (error "No secret for bouncer's auth entry."))
      (funcall secretf))))

(defun connect-bouncer (server)
  "Connect to `SERVER' on the bouncer and rename the buffer"
  (let ((password (format "%s/%s:%s" "jakob" server (read-bouncer-password))))
    (erc-tls :server "jakob.space" :port 26969 :password password)
    (erc-with-buffer ((get-buffer "jakob.space:26969")
                      (rename-buffer server)))))
#+END_SRC

Convenience functions for connecting to and authenticating with an instance of
Bitlbee.

#+BEGIN_SRC elisp
(defun bitlbee-connect ()
  "Start bitlbee as an inferior process and connect to it."
  (bitlbee-start)
  (erc :server "localhost" :port 6667)
  (erc-with-buffer ((get-buffer "localhost:6667")
                    (rename-buffer "bitlbee"))))

(defun bitlbee-identify ()
  "If we're on the bitlbee server, send the identify command to the
   &bitlbee channel."
  (when (and (string= "localhost" erc-session-server)
             (string= "&bitlbee" (buffer-name)))
    (erc-message "PRIVMSG" (format "%s identify %s"
                                   (erc-default-target)
                                   (read-bouncer-password)))))
#+END_SRC

Interactive function for automatically connecting to a local Bitlbee instance
and all of the networks I have my bouncer connected to.

#+BEGIN_SRC elisp
(defvar irc-autoconnect-networks '("bitlbee" "crtnet" "freenode" "tildetown" "tildechat")
  "List of networks to automatically connect to when 'irc' is invoked.")

(defun irc ()
  "Automatically connect to IRC networks."
  (interactive)
  (dolist (network irc-autoconnect-networks)
    (if (string= network "bitlbee")
        (bitlbee-connect)
      (connect-bouncer network))))

(defun irc-quit ()
  "Disconnects from and kills all buffers associated with ERC,
and ends the Bitlbee process."
  (interactive)
  (bitlbee-stop)
  (let ((server-buffers (remove-if-not #'erc-server-buffer-p (erc-buffer-list))))
    (dolist (buffer server-buffers)
      (erc-with-buffer (buffer)
        (erc-quit-server (funcall erc-quit-reason nil))))))
#+END_SRC

Interactive functions for manipulating =erc-track-exclude=.

#+BEGIN_SRC elisp
(defvar irc-important-channels '("&bitlbee" "#tildetown" "#lobsters")
  "Channels that I don't want shutting up.")

(defun list-irc-channels ()
  "Returns a list of the names of the ERC channel buffers."
  (map 'list #'buffer-name (remove-if #'erc-server-buffer-p (erc-buffer-list))))

(defun silence-channels ()
  "Add all channels to `erc-track-exclude'. if they are not a
member of `irc-important-channels'."
  (interactive)
  (setq --old-track-exclude erc-track-exclude)
  (let ((channels (list-irc-channels)))
    (when (boundp 'irc-important-channels)
      (dolist (channel channels)
        (if (and (not (find channel irc-important-channels :test #'string=))
                 (not (find channel erc-track-exclude :test #'string=)))
            (push channel erc-track-exclude)))))
  (setq erc-modified-channels-alist nil)
  (erc-modified-channels-display))

(defun unsilence-channels ()
  "Reset the state of `erc-track-exclude'."
  (interactive)
  (setq erc-track-exclude
        (remove-if-not #'(lambda (channel)
                           (find channel --old-track-exclude))
                       erc-track-exclude)))

(defun ignore-channel ()
  "Use `completing-read' to ask the user for a channel to ignore."
  (interactive)
  (let* ((candidates (remove-if #'(lambda (channel)
                                    (find channel erc-track-exclude))
                                (list-irc-channels)))
         (default (if (and (eq major-mode 'erc-mode)
                           (not (member (buffer-name) erc-track-exclude)))
                      (buffer-name)))
         (channel (if default
                      (completing-read-with-default "Channel:" candidates default)
                    (completing-read "Channel: " candidates))))
    (push channel erc-track-exclude)
    (erc-modified-channels-display)))

(defun unignore-channel ()
  "Use `completing-read' to ask the user for a channel to remove
from the list of ignored channels."
  (interactive)
  (let* ((candidates erc-track-exclude)
         (default (if (and (eq major-mode 'erc-mode)
                           (member (buffer-name) erc-track-exclude))
                      (buffer-name)))
         (channel (if default
                      (completing-read-with-default "Channel:" candidates default)
                    (completing-read "Channel: " candidates))))
    (setq erc-track-exclude
          (remove-if #'(lambda (channel)
                         (string= channel buffer))
                     erc-track-exclude))))
#+END_SRC

Interactive function for switching to a channel's buffer.

#+BEGIN_SRC elisp
(defun irc-switch-buffer ()
  "Use `completing-read' to ask for a channel buffer to visit."
  (interactive)
  (let* ((candidates (list-irc-channels))
         (default (if erc-modified-channels-alist
                      (buffer-name (first (first erc-modified-channels-alist)))))
         (channel (if default
                      (completing-read-with-default "Channel: " candidates default)
                    (completing-read "Channel: " candidates))))
    (switch-to-buffer channel)))
#+END_SRC

Improvements upon manually switching channel buffers. Channels can now be cycled
through interactively.

#+BEGIN_SRC elisp
(defun bitlbee-control-buffer-p (buffer-or-name)
  "Returns whether or not BUFFER-OR-NAME is connected to the
current inferior bitlbee process."
  (let ((name (if (bufferp buffer-or-name)
                  (buffer-name buffer-or-name)
                buffer-or-name)))
  (and (char-equal (elt name 0) (string-to-char "&"))
       (equal (erc-with-buffer ((get-buffer buffer-or-name))
                (erc-server-buffer))
              (get-buffer "bitlbee")))))

(defun irc-cycle-buffer-list (starting-buffer)
  "Returns the forward order in which to cycle channel buffers,
which as of the current implementation is alphabetical. Control
buffers belonging to bitlbee are omitted."
  (let* ((buffers (sort (map 'list
                              #'(lambda (channel)
                                  (get-buffer channel))
                              (list-irc-channels))
                         #'(lambda (channel1 channel2)
                             (string< (subseq (buffer-name channel1) 1)
                                      (subseq (buffer-name channel2) 1)))))
         (split-index (position (get-buffer starting-buffer) buffers)))
    (remove-if #'(lambda (buffer) (or (equal buffer (get-buffer starting-buffer))
                                 (bitlbee-control-buffer-p buffer)))
               (if split-index
                   (concatenate 'list
                                (subseq buffers split-index)
                                (subseq buffers 0 split-index))
                 buffers))))

(defun irc-cycle-forward ()
  "Visits the next channel buffer as dictated by
`irc-cycle-buffer-list'."
  (interactive)
  (switch-to-buffer (first (irc-cycle-buffer-list (current-buffer)))))

(defun irc-cycle-backward ()
  "Visits the previous channel buffer as dictated by
`irc-cycle-buffer-list'."
  (interactive)
  (switch-to-buffer (car (last (irc-cycle-buffer-list (current-buffer))))))
#+END_SRC

Interactive function for marking a channel's backlog as read in ZNC.

#+BEGIN_SRC elisp
(defun clear-irc-buffer ()
  "Query ZNC to clear the backlog for the current buffer."
  (interactive)
  (let ((channel-to-clear (buffer-name))
        (buffer (erc-query "*status" (erc-server-buffer))))
    (erc-with-buffer (buffer)
      (erc-send-message (format "clearbuffer %s" channel-to-clear)))))
#+END_SRC

Interactive function for clearing out the list of active channels in the mode
line.

#+BEGIN_SRC elisp
(defun clear-erc-track-list ()
  (interactive)
  (setq erc-modified-channels-alist nil)
  (erc-modified-channels-display))
#+END_SRC

ERC tracking bar. Not mine. Shamelessly lifted from [[https://www.emacswiki.org/emacs/ErcBar][EmacsWiki]].

#+BEGIN_SRC elisp
(eval-after-load 'erc-track
  '(progn
     (defun erc-bar-move-back (n)
       "Moves back n message lines. Ignores wrapping, and server messages."
       (interactive "nHow many lines ? ")
       (re-search-backward "^.*<.*>" nil t n))

     (defun erc-bar-update-overlay ()
       "Update the overlay for current buffer, based on the content of
erc-modified-channels-alist. Should be executed on window change."
       (interactive)
       (let* ((info (assq (current-buffer) erc-modified-channels-alist))
          (count (cadr info)))
     (if (and info (> count erc-bar-threshold))
         (save-excursion
           (end-of-buffer)
           (when (erc-bar-move-back count)
         (let ((inhibit-field-text-motion t))
           (move-overlay erc-bar-overlay
                 (line-beginning-position)
                 (line-end-position)
                 (current-buffer)))))
       (delete-overlay erc-bar-overlay))))

     (defvar erc-bar-threshold 1
       "Display bar when there are more than erc-bar-threshold unread messages.")
     (defvar erc-bar-overlay nil
       "Overlay used to set bar")
     (setq erc-bar-overlay (make-overlay 0 0))
     (overlay-put erc-bar-overlay 'face '(:underline "red"))
     ;;put the hook before erc-modified-channels-update
     (defadvice erc-track-mode (after erc-bar-setup-hook
                      (&rest args) activate)
       ;;remove and add, so we know it's in the first place
       (remove-hook 'window-configuration-change-hook 'erc-bar-update-overlay)
       (add-hook 'window-configuration-change-hook 'erc-bar-update-overlay))
     (add-hook 'erc-send-completed-hook (lambda (str)
                      (erc-bar-update-overlay)))))
#+END_SRC

© 2015 - 2026 Jakob L. Kreuze