-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
2097 lines (1859 loc) · 139 KB
/
index.html
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
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2024-09-22 Sun 23:42 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>My Literate Emacs Configuration</title>
<meta name="author" content="Animesh Sahu" />
<meta name="generator" content="Org Mode" />
<style type="text/css">
<!--/*--><![CDATA[/*><!--*/
*,
*::before,
*::after {
box-sizing: border-box;
}
html {
line-height: 1.35;
-webkit-text-size-adjust: 100%;
}
body {
margin: 0;
font-family:
system-ui,
-apple-system,
'Segoe UI',
Roboto,
Helvetica,
Arial,
sans-serif,
'Apple Color Emoji',
'Segoe UI Emoji';
}
hr {
height: 0;
color: inherit;
}
b,
strong {
font-weight: bolder;
}
code,
kbd,
samp,
pre {
font-family:
ui-monospace,
SFMono-Regular,
Consolas,
'Liberation Mono',
Menlo,
monospace;
font-size: 1em;
}
small {
font-size: 80%;
}
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
table {
text-indent: 0;
border-color: inherit;
}
summary {
display: list-item;
}
:root {
--bc-tb: #1A2F54;
--bc-block: #008ED1;
--clr: #333333;
--clr-tb-hd: #85CEEB;
--clr-code: #85CEEB;
--bg: #FFFFFF;
--bg-code: #335EA8;
--bg-tb-hd: #335EA8;
--bg-block: #FFFFE0;
--clr-link: #D0372D;
--clr-title: #333333;
--clr-todo: #008000;
--bg-todo: initial;
--clr-done: #8D8D84;
--bg-done: initial;
--ts-clr: #0000FF;
--mg: 20px;
--w-toc: 300px;
--bg-keyword: initial;
--clr-keyword: #0000FF;
--bg-constant: initial;
--clr-constant: #D0372D;
--bg-comment: initial;
--clr-comment: #8D8D84;
--bg-comment-delimiter: initial;
--clr-comment-delimiter: #8D8D84;
--bg-function: initial;
--clr-function: #006699;
--bg-variable: initial;
--clr-variable: #BA36A5;
--bg-preprocessor: initial;
--clr-preprocessor: #808080;
--bg-doc: initial;
--clr-doc: #036A07;
--bg-builtin: initial;
--clr-builtin: #006FE0;
--bg-string: initial;
--clr-string: #008000;
}
html {
font-family: Sans;
}
body {
background: #999;
display: flex;
flex-direction: column;
align-items: center;
}
body[data-theme='light'] {
background: var(--bg);
color: var(--clr);
}
body[data-theme='dark'] {
background: var(--bg);
color: var(--clr);
--bc-tb: #eeeeec;
--bc-block: initial;
--clr: #eeeeec;
--clr-code: #2e3436;
--clr-tb-hd: #2e3436;
--bg: #2e3436;
--bg-tb-hd: #d3d7cf;
--bg-code: #d3d7cf;
--bg-block: initial;
--clr-link: #e9b2e3;
--clr-title: #eeeeec;
--clr-todo: #e9b96e;
--bg-todo: initial;
--clr-done: #73d216;
--bg-done: initial;
--ts-clr: #b4fa70;
--mg: 20px;
--w-toc: 300px;
--bg-keyword: initial;
--clr-keyword: #b4fa70;
--bg-constant: initial;
--clr-constant: #e9b2e3;
--bg-comment: initial;
--clr-comment: #73d216;
--bg-comment-delimiter: initial;
--clr-comment-delimiter: initial;
--bg-function: initial;
--clr-function: #fce94f;
--bg-variable: initial;
--clr-variable: #fcaf3e;
--bg-preprocessor: initial;
--clr-preprocessor: initial;
--bg-doc: initial;
--clr-doc: initial;
--bg-builtin: initial;
--clr-builtin: #e090d7;
--bg-string: initial;
--clr-string: #e9b96e;
}
@media only screen and (max-width: 768px) {
#content {
width: 100%;
padding-left: 10px;
padding-right: 10px;
}
}
@media only screen and (min-width: 768px) {
#content {
width: 768px;
}
}
@media only screen and (min-width: 1024px) {
body {
align-items: flex-end;
}
#content {
width: calc(100vw - var(--w-toc) - var(--mg) * 4);
margin-right: var(--mg);
}
}
h1 {
color: var(--clr-title);
text-align: center;
}
h2, h3, h4, h5, h6, h7 {
font-family: Sans Serif;
}
h2 {
line-height: 2.5em;
}
h2::before {
content: "◉ ";
}
h3::before {
content: "✸ ";
}
h4::before {
content: "▷ ";
}
code {
color: var(--clr-code);
background: var(--bg-code);
border-radius: 2px;
padding-left: 5px;
padding-right: 5px;
}
pre {
padding: 20px;
border: 1px solid var(--bc-block);
background: var(--bg-block);
font-size: 0.9rem;
overflow-x: scroll;
}
pre::-webkit-scrollbar {
display: none;
}
pre {
-ms-overflow-style: none;
scrollbar-width: none;
}
.todo {
color: var(--clr-todo);
background: var(--bg-todo);
}
.done {
color: var(--clr-done);
background: var(--bg-done);
}
.timestamp-wrapper {
font-size: 0.8rem;
color: var(--clr-ts);
}
table {
width: 100%;
border: 2px solid var(--bc-tb);
}
thead {
color: var(--clr-tb-hd);
background: var(--bg-tb-hd);
}
td, th {
border: thin solid var(--bc-tb);
}
li {
line-height: 2rem;
}
a {
text-decoration: none;
color: var(--clr-link);
}
a:hover {
text-decoration: underline;
}
#table-of-contents > h2 {
display: none;
}
#table-of-contents {
border: thin solid var(--bc-block);
background: var(--bg-block);
}
#toggle-toc {
display: none;
}
.toc-show {
display: block!important;
}
@media only screen and (max-width: 768px) {
#toggle-toc {
position: fixed;
top: 0;
right: 0;
cursor: pointer;
padding-left: 10px;
padding-right: 10px;
font-size: 2em;
line-height: 2em;
display: block;
}
#table-of-contents {
background: var(--bg);
display: none;
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
overflow-y: scroll;
}
#table-of-contents a {
color: var(--clr);
}
}
@media only screen and (min-width: 1024px) {
#table-of-contents {
font-size: 0.8rem;
position: fixed;
left: var(--mg);
top: var(--mg);
bottom: var(--mg);
width: var(--w-toc);
overflow-y: scroll;
}
}
#table-of-contents::-webkit-scrollbar {
display: none;
}
#table-of-contents {
-ms-overflow-style: none;
scrollbar-width: none;
}
.MathJax_Display {
font-size: 1.25em;
}
#toggle-theme {
border-width: 0;
line-height: 4em;
padding-left: 1em;
padding-right: 1em;
background: var(--bg-block);
color: var(--clr-code);
}
#toggle-theme:hover {
cursor: pointer;
}
img {
width: 100%;
}
@media only screen and (max-width: 768px) {
#toggle-theme {
width: 100%;
text-align: center;
}
}
@media only screen and (min-width: 768px) {
#toggle-theme {
position: absolute;
top: var(--mg);
right: var(--mg);
border-radius: 5px;
}
}
.theme-transition {
transition: all 0.5s;
}
.status {
width: 100%;
}
@media only screen and (max-width: 768px) {
ul {
padding-left: .5em;
margin-left: 0;
}
li {
padding-left: 0;
margin-left: 0;
}
}
/*]]>*/-->
</style>
</head>
<body>
<div id="preamble" class="status">
<div id="toggle-theme">dark theme</div><div id="toggle-toc">☰</div>
</div>
<div id="content" class="content">
<h1 class="title">My Literate Emacs Configuration</h1>
<div id="table-of-contents" role="doc-toc">
<h2>Table of Contents</h2>
<div id="text-table-of-contents" role="doc-toc">
<ul>
<li><a href="#org0000007">1. Preliminaries</a>
<ul>
<li><a href="#org0000001">1.1. Preface</a></li>
<li><a href="#org0000004">1.2. Introduction</a></li>
</ul>
</li>
<li><a href="#org0000013">2. Getting Started</a>
<ul>
<li><a href="#org000000a">2.1. Installation</a></li>
<li><a href="#org000000d">2.2. Basic Keybinds</a></li>
<li><a href="#org0000010">2.3. Tutorials</a></li>
</ul>
</li>
<li><a href="#org0000031">3. Emacs Configuration</a>
<ul>
<li><a href="#org0000016">3.1. Early-Init and Init</a></li>
<li><a href="#org0000019">3.2. Better Defaults (Almost Mandatory)</a></li>
<li><a href="#org000001c">3.3. Better Org-Mode Defaults</a></li>
<li><a href="#org000001f">3.4. Base Packages</a></li>
<li><a href="#org0000022">3.5. Set Fonts</a></li>
<li><a href="#org000002e">3.6. Set Keybinds</a>
<ul>
<li><a href="#org0000025">3.6.1. Normal Keybinds</a></li>
<li><a href="#org0000028">3.6.2. Leader Keybinds</a></li>
<li><a href="#org000002b">3.6.3. Miscellaneous</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#org0000043">4. Productivity Enhancers</a>
<ul>
<li><a href="#org0000034">4.1. Undo History</a></li>
<li><a href="#org0000037">4.2. Key & Minibuffer completions</a></li>
<li><a href="#org000003a">4.3. Hop (Jump Anywhere on Buffer)</a></li>
<li><a href="#org000003d">4.4. Zoxide</a></li>
<li><a href="#org0000040">4.5. AutoCompletion & Snippets</a></li>
</ul>
</li>
<li><a href="#org000004c">5. Programming</a>
<ul>
<li><a href="#org0000046">5.1. Highlighting</a></li>
<li><a href="#org0000049">5.2. Project Management</a></li>
</ul>
</li>
<li><a href="#org000005e">6. Add-ons</a>
<ul>
<li><a href="#org000004f">6.1. Remote Execution</a></li>
<li><a href="#org0000052">6.2. Embark</a></li>
<li><a href="#org0000055">6.3. Marginalia</a></li>
<li><a href="#org0000058">6.4. Better Help</a></li>
<li><a href="#org000005b">6.5. Chdir Support</a></li>
</ul>
</li>
<li><a href="#org000006d">7. Look & Feel</a>
<ul>
<li><a href="#org0000061">7.1. Theme</a></li>
<li><a href="#org0000064">7.2. ModeLine</a></li>
<li><a href="#org0000067">7.3. Org Export</a></li>
<li><a href="#org000006a">7.4. Highlight Todo</a></li>
</ul>
</li>
<li><a href="#org0000085">8. Miscellaneous</a>
<ul>
<li><a href="#org0000070">8.1. Notes</a></li>
<li><a href="#org0000073">8.2. Don't reset the cursor to the middle when scrolling</a></li>
<li><a href="#org0000076">8.3. Highlight Trailing Whitespace</a></li>
<li><a href="#org0000079">8.4. Window Split Vertical-Horizontal Toggle</a></li>
<li><a href="#org000007c">8.5. Change backup and lock file dump path</a></li>
<li><a href="#org000007f">8.6. open-at-point that opens respecting OS's default app for the link</a></li>
<li><a href="#org0000082">8.7. File closing prompt with evil-quit without saving won't show "Type C-h for help." in case wrong key is pressed.</a></li>
</ul>
</li>
<li><a href="#org0000088">9. Resources References</a></li>
<li><a href="#org0000091">10. Unverified Code</a>
<ul>
<li><a href="#org000008b">10.1. Completions & Jumping</a></li>
<li><a href="#org000008e">10.2. Consult (tmp)</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div id="outline-container-org0000007" class="outline-2">
<h2 id="org0000007"><span class="section-number-2">1.</span> Preliminaries</h2>
<div class="outline-text-2" id="text-1">
</div>
<div id="outline-container-org0000001" class="outline-3">
<h3 id="org0000001"><span class="section-number-3">1.1.</span> Preface</h3>
<div class="outline-text-3" id="text-1-1">
<p>
I was first introduced to Emacs by a friend at my college. I had been resistant to a lot of things in my life, like the
4-finger claw for playing mobile games, 10-finger touch typing on laptops, learning vim keybindings, and this time,
Emacs. I can only count how many times these things have saved me from a time-bubble burst. These seemingly obscure and
optional(-looking) things have indeed proven to be a few of the most influential aspects of my life.
</p>
<p>
<a href="https://www.csee.umbc.edu/resources/computer-science-help-center/resources-for-new-students/an-introduction-to-emacs">Emacs</a> holds a special place at the nucleus of my technological toolkit. All my workflows simplify down, because of its
indcredible ingrained & integrable plugin ecosystem. You can't imagine any other software working so well for a variety
of use cases, sometimes even better than their recommended options. It has elevated my workflow as a programmer to a
whole new level.
</p>
<div id="org0000000" class="figure">
<p><img src="./ss.jpg" alt="ss.jpg" />
</p>
</div>
</div>
</div>
<div id="outline-container-org0000004" class="outline-3">
<h3 id="org0000004"><span class="section-number-3">1.2.</span> Introduction</h3>
<div class="outline-text-3" id="text-1-2">
<p>
This file, even though looking like a documentation or a book is indeed my emacs configuration!
(And also my ever updating notes while I'm learning emacs).
</p>
<p>
This is possible because of the org-babel plugin (inbuilt in Emacs as of now) that allows Emacs to contain code-blocks
within the org-mode documents. And this style of writing code within natural language is known as Literate Programming.
</p>
<p>
You can view my configuration at:
</p>
<ul class="org-ul">
<li><a href="https://animeshz.github.io/.emacs.d/">Website</a></li>
<li><a href="https://github.com/Animeshz/.emacs.d">GitHub</a></li>
</ul>
</div>
</div>
</div>
<div id="outline-container-org0000013" class="outline-2">
<h2 id="org0000013"><span class="section-number-2">2.</span> Getting Started</h2>
<div class="outline-text-2" id="text-2">
</div>
<div id="outline-container-org000000a" class="outline-3">
<h3 id="org000000a"><span class="section-number-3">2.1.</span> Installation</h3>
<div class="outline-text-3" id="text-2-1">
<p>
Install as you wish, I prefer using nix + home-manager for installation.
</p>
<div class="org-src-container">
<pre class="src src-nix">{ pkgs }:
{
<span style="color: #b6b635;">programs.emacs</span> = {
<span style="color: #b6b635;">enable</span> = <span style="color: #7f7dca;">true</span>;
<span style="color: #b6b635;">package</span> = pkgs.emacs29;
<span style="color: #b6b635;">extraPackages</span> = epkgs: <span style="color: #598bc1;">with</span> epkgs; <span style="color: #598bc1;">with</span> pkgs; [
custom.emacs-pcre
custom.emacs-chdir
];
};
}
</pre>
</div>
<p>
I export emacs-pcre and emacs-chdir as custom packages on my <a href="https://github.com/Animeshz/linux-desktop">nix config</a>.
</p>
</div>
</div>
<div id="outline-container-org000000d" class="outline-3">
<h3 id="org000000d"><span class="section-number-3">2.2.</span> Basic Keybinds</h3>
<div class="outline-text-3" id="text-2-2">
<p>
I like to remember a few keybinds so in-case my config had any error, I could still use emacs with these fallback
keybinds. And these keybinds are in general good enough for my hands as well hence I mostly don't change them.
</p>
<ul class="org-ul">
<li>C = Ctrl</li>
<li>M = Alt</li>
<li>S = Shift</li>
</ul>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Scope</th>
<th scope="col" class="org-left">Keybind</th>
<th scope="col" class="org-left">Action</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left">global</td>
<td class="org-left">M-x</td>
<td class="org-left">View Available Commands</td>
</tr>
<tr>
<td class="org-left"> </td>
<td class="org-left">C-x C-f</td>
<td class="org-left">Find File</td>
</tr>
<tr>
<td class="org-left"> </td>
<td class="org-left">C-h [f / v / k]</td>
<td class="org-left">Help on [functions / variables / key-chords]</td>
</tr>
<tr>
<td class="org-left"> </td>
<td class="org-left">C-x [2 / 3 / 0 / 1]</td>
<td class="org-left">Window Split [Down / Right / Close / Close All Except This]</td>
</tr>
<tr>
<td class="org-left"> </td>
<td class="org-left">C-x o / C-w C-w (Evil)</td>
<td class="org-left">Switch Window Split</td>
</tr>
<tr>
<td class="org-left">org-mode</td>
<td class="org-left">C-c C-c</td>
<td class="org-left">Run CodeBlock or Format Table</td>
</tr>
<tr>
<td class="org-left"> </td>
<td class="org-left">C-c C-l</td>
<td class="org-left">Insert Link</td>
</tr>
<tr>
<td class="org-left"> </td>
<td class="org-left">C-c C-,</td>
<td class="org-left">Insert Snippets</td>
</tr>
<tr>
<td class="org-left">minibuffer</td>
<td class="org-left">C-y</td>
<td class="org-left">Paste</td>
</tr>
</tbody>
</table>
<p>
<code>M-<number></code> is a shorthand for <code>C-u <number></code>, and is used to pass first argument <code>number</code> in interactive commands
via M-x or keybind.
</p>
</div>
</div>
<div id="outline-container-org0000010" class="outline-3">
<h3 id="org0000010"><span class="section-number-3">2.3.</span> Tutorials</h3>
<div class="outline-text-3" id="text-2-3">
<p>
I like to recommend <a href="https://www.youtube.com/watch?v=B6jfrrwR10k">this video</a> if you want to get familiarized with emacs! This packs a lot of information with
effective presentations instead of most videos which talk way too much and delivers barely anything useful.
</p>
<p>
<a href="https://www.youtube.com/playlist?list=PLlHHtPGox8K6bcuruX10Evf4AYGzYQKiz">This playlist</a> is good for getting quick short videos for further learning emacs on your own pace.
</p>
</div>
</div>
</div>
<div id="outline-container-org0000031" class="outline-2">
<h2 id="org0000031"><span class="section-number-2">3.</span> Emacs Configuration</h2>
<div class="outline-text-2" id="text-3">
</div>
<div id="outline-container-org0000016" class="outline-3">
<h3 id="org0000016"><span class="section-number-3">3.1.</span> Early-Init and Init</h3>
<div class="outline-text-3" id="text-3-1">
<p>
The <a href="./early-init.el">early-init.el</a> and <a href="./init.el">init.el</a> files are the first two files emacs read when starting up.
</p>
<p>
I kept them separated from this main configuration because the former do very naive stuffs
(such as basic ui changes and performance optimization), and the latter contains bootstrap code for Elpaca the package
manager which is a prerequisite for most of this config and also it loads this config in the end.
</p>
</div>
</div>
<div id="outline-container-org0000019" class="outline-3">
<h3 id="org0000019"><span class="section-number-3">3.2.</span> Better Defaults (Almost Mandatory)</h3>
<div class="outline-text-3" id="text-3-2">
<p>
Emacs requires some essential tweaks to become somewhat usable.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp"><span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">;;; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">This file is generated from config.org | -*- lexical-binding: t; -*-</span>
<span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">;; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">Enable minibuffer history, prioritizes M-x & vim commands with most recent commands issued</span>
(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">setq</span> history-length 100)
(savehist-mode 1)
<span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">;; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">Enable recording recent files & window configuration for going back and forth</span>
(recentf-mode 1) <span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">SPC-f-r</span>
(winner-mode 1) <span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">C-c [left / right]</span>
<span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">;; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">Set relative lines</span>
(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">setq</span> display-line-numbers-type 'relative)
(global-display-line-numbers-mode t)
<span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">;; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">Configure automatic line breaks and word-wrap (just in case)</span>
(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">setq-default</span> fill-column 120 <span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">SPC-c</span>
auto-fill-function 'do-auto-fill)
(global-visual-line-mode t) <span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">SPC-w</span>
<span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">;; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">I prefer indentation with spaces</span>
(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">setq-default</span> tab-width 4
indent-tabs-mode nil)
<span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">;; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">Make scratch buffer text-mode</span>
(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">setq-default</span> initial-scratch-message nil
initial-major-mode 'text-mode)
<span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">;; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">Replace yes/no with y/n</span>
(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">setq</span> use-short-answers t)
<span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">;; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">Don't break hardlinks</span>
(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">setq</span> backup-by-copying t)
<span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">;; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">Count current and total count of isearch</span>
(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">setq</span> isearch-lazy-count t)
<span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">;; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">Modeline, if the custom one didn't work</span>
(column-number-mode 1)
<span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">;; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">Auto detect/guess/infer indentation levels</span>
(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">use-package</span> <span style="color: var(--clr-constant); background-color: var(--bg-constant);">dtrt-indent</span>
<span style="color: var(--clr-builtin); background-color: var(--bg-builtin);">:hook</span> (prog-mode . dtrt-indent-mode))
</pre>
</div>
</div>
</div>
<div id="outline-container-org000001c" class="outline-3">
<h3 id="org000001c"><span class="section-number-3">3.3.</span> Better Org-Mode Defaults</h3>
<div class="outline-text-3" id="text-3-3">
<p>
Same goes for <code>org-mode</code>.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp"><span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">;; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">Allow these languages for code evaluation in org-mode documents</span>
(org-babel-do-load-languages 'org-babel-load-languages
'((emacs-lisp . t) (shell . t) (python . t) (ruby . t) (C . t) (js . t))) <span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">C-c C-c</span>
(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">setq</span> org-confirm-babel-evaluate nil)
<span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">;; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">Give org html export a deterministic id so it doesn't pollute git history</span>
(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">defun</span> <span style="color: var(--function-clr-name); background-color: var(--function-bg-name);">my/org-deterministic-reference</span> (references)
(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">cl-loop</span> for new from (length references) until (not (rassq new references))
finally return new))
(advice-add #'org-export-new-reference <span style="color: var(--clr-builtin); background-color: var(--bg-builtin);">:override</span> #'my/org-deterministic-reference)
</pre>
</div>
</div>
</div>
<div id="outline-container-org000001f" class="outline-3">
<h3 id="org000001f"><span class="section-number-3">3.4.</span> Base Packages</h3>
<div class="outline-text-3" id="text-3-4">
<p>
These core packages are the scaffold upon which the entire configuration below is assembled.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp"><span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">;; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">Used to set keybinds</span>
(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">use-package</span> <span style="color: var(--clr-constant); background-color: var(--bg-constant);">general</span>
<span style="color: var(--clr-builtin); background-color: var(--bg-builtin);">:config</span>
(general-override-mode)
(general-auto-unbind-keys))
<span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">;; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">Emulates vim keybinds & modal editing</span>
(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">use-package</span> <span style="color: var(--clr-constant); background-color: var(--bg-constant);">evil</span>
<span style="color: var(--clr-builtin); background-color: var(--bg-builtin);">:init</span>
(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">setq</span> evil-v$-excludes-newline t <span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">$ in visual doesn't include \n</span>
evil-kill-on-visual-paste nil <span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">pasting in visual mode won't copy replaced text to clipboard</span>
evil-auto-indent nil <span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">o and O doesn't add indents</span>
evil-cross-lines t <span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">h and l to move to newline</span>
<span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">;; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">evil-respect-visual-line-mode t ; physical line as $ anchor instead of \n, caveat: dj dk doesn't work as intended</span>
evil-shift-width tab-width <span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);"><< and >></span>
evil-want-keybinding nil <span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">required by =evil-collection=</span>
evil-split-window-below t
evil-vsplit-window-right t)
<span style="color: var(--clr-builtin); background-color: var(--bg-builtin);">:config</span>
(evil-mode 1))
<span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">;; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">Extend support of vim keybindings on to various other packages</span>
(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">use-package</span> <span style="color: var(--clr-constant); background-color: var(--bg-constant);">evil-collection</span>
<span style="color: var(--clr-builtin); background-color: var(--bg-builtin);">:after</span> evil
<span style="color: var(--clr-builtin); background-color: var(--bg-builtin);">:config</span>
(evil-collection-init))
(elpaca-wait)
</pre>
</div>
<p>
The <code>evil</code> package provides Vim's Modal Editing in Emacs. I have notes on <a href="https://animeshz.github.io/site/notes/20-29--DevEnvironment/21--Linux/21.03-Cli-Utilities.html#n-vim">the only Vim keybind you need to know</a> on my
site.
</p>
</div>
</div>
<div id="outline-container-org0000022" class="outline-3">
<h3 id="org0000022"><span class="section-number-3">3.5.</span> Set Fonts</h3>
<div class="outline-text-3" id="text-3-5">
<p>
Set global font, whichever is available in the <code>preferred-fonts</code>.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">defvar</span> <span style="color: var(--clr-variable); background-color: var(--bg-variable);">preferred-fonts</span>
(list <span style="color: var(--clr-string); background-color: var(--bg-string);">"CaskaydiaCove Nerd Font Mono"</span> <span style="color: var(--clr-string); background-color: var(--bg-string);">"Fira Code Mono"</span> <span style="color: var(--clr-string); background-color: var(--bg-string);">"Jetbrains Mono"</span>))
(custom-set-faces
'(default ((t (<span style="color: var(--clr-builtin); background-color: var(--bg-builtin);">:family</span> (cl-find-if font-info preferred-fonts) <span style="color: var(--clr-builtin); background-color: var(--bg-builtin);">:height</span> 120)))))
</pre>
</div>
<p>
I didn't set <code>variable-pitch</code> and <code>fixed-pitch</code> faces separately and forced Mono font everywhere, although that's also
an option.
</p>
</div>
</div>
<div id="outline-container-org000002e" class="outline-3">
<h3 id="org000002e"><span class="section-number-3">3.6.</span> Set Keybinds</h3>
<div class="outline-text-3" id="text-3-6">
<p>
General keybinds which are not specific to any package.
</p>
<p>
With evil we have 2 things, evil states (namely normal, motion, visutal, etc) and mode-map. In emacs, everything we edit
(the buffer) has a major mode (e.g. prog-mode) and multiple minor modes (e.g. winner-mode, rust-mode) enabled through
file extension or hooks, each of these modes have a mode-map associated in order to set keybinds in buffers with those
modes enabled. Read more about them <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Modes.html">here</a>.
</p>
</div>
<div id="outline-container-org0000025" class="outline-4">
<h4 id="org0000025"><span class="section-number-4">3.6.1.</span> Normal Keybinds</h4>
<div class="outline-text-4" id="text-3-6-1">
<p>
Keybinds without prefix.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">general-def</span> '(normal motion visual operator)
<span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">;; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">Adjust font size</span>
<span style="color: var(--clr-string); background-color: var(--bg-string);">"C-+"</span> #'text-scale-increase
<span style="color: var(--clr-string); background-color: var(--bg-string);">"C-_"</span> #'text-scale-decrease
<span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">;; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">Move lines without moving cursor</span>
<span style="color: var(--clr-string); background-color: var(--bg-string);">","</span> #'evil-scroll-line-down
<span style="color: var(--clr-string); background-color: var(--bg-string);">"."</span> #'evil-scroll-line-up
<span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">;; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">Indent region (same keybind as vscode lol)</span>
<span style="color: var(--clr-string); background-color: var(--bg-string);">"C-S-i"</span> (<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">lambda</span> () (<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">interactive</span>) (indent-region (point-min) (point-max)))
<span style="color: var(--clr-string); background-color: var(--bg-string);">"<escape>"</span> #'keyboard-escape-quit)
</pre>
</div>
</div>
</div>
<div id="outline-container-org0000028" class="outline-4">
<h4 id="org0000028"><span class="section-number-4">3.6.2.</span> Leader Keybinds</h4>
<div class="outline-text-4" id="text-3-6-2">
<p>
Keybinds with <code>SPC</code> prefix.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">general-create-definer</span> leader-key
<span style="color: var(--clr-builtin); background-color: var(--bg-builtin);">:states</span> '(normal motion visual operator emacs)
<span style="color: var(--clr-builtin); background-color: var(--bg-builtin);">:keymaps</span> 'override
<span style="color: var(--clr-builtin); background-color: var(--bg-builtin);">:prefix</span> <span style="color: var(--clr-string); background-color: var(--bg-string);">"SPC"</span>)
(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">leader-key</span>
<span style="color: var(--clr-string); background-color: var(--bg-string);">"ff"</span> #'find-file
<span style="color: var(--clr-string); background-color: var(--bg-string);">"fr"</span> #'recentf-open
<span style="color: var(--clr-string); background-color: var(--bg-string);">"tw"</span> #'delete-trailing-whitespace
<span style="color: var(--clr-string); background-color: var(--bg-string);">"ev"</span> #'eval-region
<span style="color: var(--clr-string); background-color: var(--bg-string);">"x"</span> #'kill-this-buffer
<span style="color: var(--clr-string); background-color: var(--bg-string);">"r"</span> #'revert-buffer
<span style="color: var(--clr-string); background-color: var(--bg-string);">"c"</span> #'display-fill-column-indicator-mode
<span style="color: var(--clr-string); background-color: var(--bg-string);">"s"</span> #'switch-to-buffer
<span style="color: var(--clr-string); background-color: var(--bg-string);">"d"</span> #'bookmark-jump
<span style="color: var(--clr-string); background-color: var(--bg-string);">"w"</span> #'visual-line-mode <span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">toggle word-wrap</span>
<span style="color: var(--clr-string); background-color: var(--bg-string);">"/"</span> #'comment-dwim)
</pre>
</div>
</div>
</div>
<div id="outline-container-org000002b" class="outline-4">
<h4 id="org000002b"><span class="section-number-4">3.6.3.</span> Miscellaneous</h4>
<div class="outline-text-4" id="text-3-6-3">
<p>
Ergonomic UX on insert-like modes,
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">general-unbind</span> <span style="color: var(--clr-string); background-color: var(--bg-string);">"C-<backspace>"</span>)
(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">general-def</span> 'insert
<span style="color: var(--clr-string); background-color: var(--bg-string);">"<tab>"</span> #'tab-to-tab-stop
<span style="color: var(--clr-string); background-color: var(--bg-string);">"C-<backspace>"</span> #'evil-delete-backward-word
<span style="color: var(--clr-string); background-color: var(--bg-string);">"C-S-v"</span> #'evil-paste-before-cursor-after)
(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">general-def</span> '(isearch-mode-map)
<span style="color: var(--clr-string); background-color: var(--bg-string);">"<down>"</span> #'isearch-ring-advance
<span style="color: var(--clr-string); background-color: var(--bg-string);">"<up>"</span> #'isearch-ring-retreat
<span style="color: var(--clr-string); background-color: var(--bg-string);">"C-S-v"</span> #'isearch-yank-kill)
(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">general-def</span> '(minibuffer-mode-map)
<span style="color: var(--clr-string); background-color: var(--bg-string);">"C-<backspace>"</span> #'evil-delete-backward-word
<span style="color: var(--clr-string); background-color: var(--bg-string);">"C-S-v"</span> #'yank)
</pre>
</div>
<p>
Some org mode enhancements
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp"><span style="color: var(--clr-comment-delimiter); background-color: var(--bg-comment-delimiter);">;; </span><span style="color: var(--clr-comment); background-color: var(--bg-comment);">Toggle folding org headings with tab/ret</span>
(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">general-def</span> 'normal org-mode-map
<span style="color: var(--clr-string); background-color: var(--bg-string);">"<tab>"</span> #'evil-toggle-fold
<span style="color: var(--clr-string); background-color: var(--bg-string);">"<RET>"</span> (<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">lambda</span> ()
(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">interactive</span>)
(<span style="color: var(--clr-keyword); background-color: var(--bg-keyword);">cond</span>
((org-at-heading-p) (evil-toggle-fold))
((org-in-regexp org-link-any-re) (org-open-at-point))
(t (evil-ret)))))
</pre>
</div>
</div>
</div>
</div>
</div>