-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.el
4765 lines (4068 loc) · 177 KB
/
init.el
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
;;; init.el --- Elephant454's init.el
;;; Commentary:
;;; Code:
;; global variables
(require 'cl-lib)
(setq
inhibit-startup-screen t
;; Here are some settings for backing up files. Research this more,
;; using
;; http://stackoverflow.com/questions/151945/how-do-i-control-how-emacs-makes-backup-files
;; as a starting point
backup-directory-alist `(("." . "~/.emacs_backups"))
backup-by-copying t
delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t
;; shows the current column number at the point in the modeline (the
;; equivalent "line-number-mode" is enabled by default
column-number-mode t
;; This command makes it so that C-v and M-v (which act like PageUp and
;; PageDown) move to the very top of the buffer and very bottom of the buffer
;; when no more scrolling can happen, I think... I'm not sure.
scroll-error-top-bottom t
;; I don't end sentences with two spaces, so Emacs shouldn't expect to see
;; them. This is used for "M-a" and "M-e" for jumping forward and back
;; sentences. It's important to set this, because filling functions (like
;; `paragraph-fill') modify their behavior based on this value. Look up the
;; info page on "Sentences".
sentence-end-double-space nil
;; Allow for correct printing for "circular lists", which are lists that have
;; their tail point to their head (using something like `(nconc my-list
;; my-list)')
print-circle t
;; set the default web browser to firefox
;;browse-url-browser-function 'browse-url-generic
;;browse-url-generic-program "firefox"
;; https://www.reddit.com/r/emacs/comments/6yn8lo/what_do_you_use_eww_for/
;; TODO: Look more into using this for opening different websites in different
;; ways
;; Look into using this with Stack Overflow, specifically
;; Grabbing XKCDs could be done more cleanly, probably 😅
;; TODO: It would be super great to be able to use this with md4rd and
;; github-explorer
browse-url-secondary-browser-function #'browse-url-generic
browse-url-generic-program "qutebrowser"
browse-url-handlers '((".*xkcd.com/[0-9]*" .
(lambda (url rest) (get-xkcd-from-url url)))
;; If we do a universal argument before opening the link,
;; open it in EWW. Otherwise, open in EMMS.
(".*youtube.com/watch\\?v=.*" .
(lambda (url rest)
(if current-prefix-arg
(eww-browse-url url)
(emms-play-url url))))
(".*youtu.be/.*" .
(lambda (url rest)
(if current-prefix-arg
(eww-browse-url url)
(emms-play-url url))))
;; Videos for Reddit with EMMS
(".*v.redd.it/.*" .
(lambda (url rest)
(if current-prefix-arg
(eww-browse-url url)
(emms-play-url url))))
;; Reddit comment threads in reddigg
(".*reddit.com/r/.*/comments/.*" .
(lambda (url rest)
(if current-prefix-arg
(eww-browse-url url)
(reddigg-view-comments
(cadr (split-string url "reddit.com"))))))
;; StackExchange in sx
(".*stackoverflow.com/questions/.*" .
(lambda (url rest) (sx-open-link url)))
("." . eww-browse-url))
browse-url-browser-function #'eww-browse-url
;; TODO: This is supposed to allow me to click links inside of eww and have
;; them use browse-url-handlers, but it's not working for whatever reason
eww-use-browse-url ".*"
;; start debugging when something signals an error
debug-on-error t
)
;; defaults for buffer local variables
(setq-default
indent-tabs-mode nil ; use spaces, not tabs
tab-width 4 ; use four spaces
c-basic-offset 4 ; yes, also for c
c-default-style "linux" ; don't indent brackets
fill-column 80) ; make auto-fill-mode break lines at 80 characters
;; modes
(electric-indent-mode 1) ; indent automatically
(electric-pair-mode 1) ; automatically match closing parentheses, braces,
; quotes, etc.
(show-paren-mode 1) ; highlight paired parentheses
(setq show-paren-delay 0) ; no delay for highlighting parentheses
(scroll-bar-mode 0) ; remove the scroll bar
(menu-bar-mode 0) ; remove the menu bar (File, Edit, etc.)
(tool-bar-mode 0) ; remove the tool bar (New, Open, etc.)
(global-auto-revert-mode) ; auto-revert changes for any changes on disk
(setq global-auto-revert-non-file-buffers t)
;; Disable popping up the warning buffer while doing async native comp
(custom-set-variables '(warning-suppress-types '((comp))))
;; Get rid of the titlebar CSD for Phosh
(defun e454iel-remove-csd (frame)
"Get rid of the Gnome titlebar on FRAME by toggling fullscreen on and off."
(toggle-frame-fullscreen)
(toggle-frame-fullscreen))
(add-hook 'after-make-frame-functions
#'e454iel-remove-csd)
;; Don't suspend emacs with "C-z"
(global-unset-key (kbd "C-z"))
;; Don't kill the whole line if I accidentally mash C-S
(global-unset-key (kbd "<C-S-backspace>"))
;; Install the Straight.el package manager from the bootstrap
(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))
(straight-use-package 'use-package)
(use-package use-package
;; set all calls to use-package to use Straight as the package manager
:config (progn
(setq straight-use-package-by-default t)
;; TODO: This seems to break on Emacs 29 for some reason?
;;(use-package use-package-ensure-system-package)
))
;; Make sure our keyring doesn't get out of date
(use-package gnu-elpa-keyring-update)
;; Install the Garbage Collector Magic Hack and set some garbage collection
;; settings
(use-package gcmh
:disabled
:config
(progn
;; https://elmord.org/blog/?entry=20190913-emacs-gc
;; http://bling.github.io/blog/2016/01/18/why-are-you-changing-gc-cons-threshold/
(gcmh-mode 1)
;; Set it to 8 gigabytes
(setq gcmh-high-cons-threshold (* 1024 1024 1024 8))
;; Maybe Try 100 megabytes instead
;;(setq gcmh-high-cons-threshold (* 1024 1024 100))
(setq garbage-collection-messages t)))
;; Create the "emacs-config" directory for storing miscellaneous Emacs
;; configuration files
(defvar e454iel-emacs-config-directory)
(setq e454iel-emacs-config-directory (concat user-emacs-directory "config/"))
(unless (file-exists-p e454iel-emacs-config-directory)
(make-directory e454iel-emacs-config-directory))
;; load secret settings (location, passwords, etc)
(add-to-list 'load-path (concat user-emacs-directory "config/"))
(load "secret.el" t)
;; load custom-file (file where all options set by customize are stored)
(setq custom-file (concat user-emacs-directory "config/" "custom-file.el"))
;;(load "custom-file.el" t)
;; Describe a bunch of classes of devices I own
(defvar e454iel-desktop-p
(cl-find (system-name)
(list
"7752.Arch.Matthew"
"7752.Guix.Matthew"
"Desktop.Guix.Maddie")
:test #'string-equal))
(defvar e454iel-laptop-p
(cl-find (system-name)
(list "Laptop-Manjaro-Maddie"
"7548.Arch.Matthew"
"7548.Guix.Matthew")
:test #'string-equal))
(defvar e454iel-phone-p
(cl-find (system-name)
(list "mobian"
;; TODO: This could either be a phone or a tablet, so a more
;; sophisticated check is needed
;;"danctnix"
)
:test #'string-equal))
(defvar e454iel-tablet-p
(let* ((kernel-version-name (string-trim (shell-command-to-string "uname -r")))
(kernel-version-string-pieces (split-string kernel-version-name "-"))
(kernel-version-string-pieces-length (length kernel-version-string-pieces)))
(if (and
(> kernel-version-string-pieces-length 3)
(string= "pinetab2" (cadddr kernel-version-string-pieces)))
t
nil)))
(defvar e454iel-touch-screen-p
(or e454iel-phone-p e454iel-tablet-p))
(defvar e454iel-small-screen-p
(or e454iel-phone-p e454iel-tablet-p))
(defvar e454iel-portable-p
(or e454iel-phone-p e454iel-tablet-p e454iel-laptop-p))
;; Decide if this is a home computer
(defvar e454iel-home-computer-p
(or e454iel-desktop-p
e454iel-laptop-p
e454iel-phone-p
e454iel-tablet-p))
;; themes
;; Mark these as variables that I'm going to use properly. Give them docstrings
;; and default values later. I might want to use defcustom for these later,
;; especially if I put all of the font/theme functionality in a really minimal
;; package later on.
(defvar e454iel-theme-pairs)
(defvar e454iel-current-theme-pairs)
(defvar e454iel-use-day-theme)
(defvar e454iel-apply-to-stumpwm)
;; disable the current Emacs 24 theme before enabling a new one. This
;; is from
;; http://stackoverflow.com/questions/9900232/changing-color-themes-emacs-24-order-matters/15595000#15595000
;; http://emacs.stackexchange.com/questions/3112/how-to-reset-color-theme
;;
;; look more into mapping functions (mapcar, mapc, dolist, etc.)
(defadvice load-theme
(before theme-dont-propagate activate)
(mapc #'disable-theme custom-enabled-themes))
;; I should set up pairs of night themes and day themes. One keybinding cycles
;; between pairs and another keybinding switches between day and night.
(defun listify (x)
"If `X' is not a list, put it in a list."
(if (listp x) x (list x)))
(defun append-to-lists (lists &optional beginning end)
"Append `BEGINNING' and / or `END' to each list in `LISTS'.
Lists in `LISTS' that are not lists will be listified by `listify'."
(mapcar
(lambda (list)
(append (listify beginning) (listify list) (listify end)))
lists))
(defmacro singlet (varpair &rest body)
"single value let expression. bind the second value of `varpair'
to the first value of `varpair' and evaluate `body' with this
value bound."
;; This tells Emacs that I want it to indent by one space the same way that a
;; regular let statement does
(declare (indent 1))
`(let ((,(car varpair) ,(cadr varpair)))
,@body))
(defmacro use-package-list (&rest packages)
"Run use-package on each of the `PACKAGES'."
(cons 'progn (append-to-lists packages 'use-package)))
(use-package-list
(soft-morning-theme :defer)
(omtose-phellack-theme :defer)
(color-theme-sanityinc-tomorrow :defer)
(light-soap-theme :defer)
(silkworm-theme :defer)
(foggy-night-theme :defer)
(apropospriate-theme :defer)
(gotham-theme :defer)
(purple-haze-theme :defer)
(gruvbox-theme :defer)
(doom-themes
:defer
:config (progn
(doom-themes-visual-bell-config)
(doom-themes-org-config)))
(material-theme :defer)
(spacemacs-theme :defer)
(dracula-theme :defer)
(kaolin-themes :defer)
(srcery-theme :defer)
(birds-of-paradise-plus-theme :defer)
(warm-night-theme :defer)
(tron-legacy-theme :defer)
(shanty-themes :defer)
(ef-themes :defer)
(weyland-yutani-theme :defer)
)
;; TODO: There has to be some sort of better way of doing this. 😅 The autoloads
;; weren't generated right, so the only way to get the
;; birds-of-paradise-plus-theme to load correctly is to add it to the
;; custom-theme-load-path here.
(add-to-list 'custom-theme-load-path
(expand-file-name
"~/.emacs.d/elpa/birds-of-paradise-plus-theme-0.1.1/"))
;; cons pairs of themes, with the car being the day variant and the cdr being
;; the night variant
(setq e454iel-theme-pairs '((soft-morning . omtose-softer)
(silkworm . foggy-night)
(gruvbox-light-soft . gruvbox-dark-hard)
(kaolin-mono-light . kaolin-mono-dark)
(doom-one . doom-one)
(doom-fairy-floss . doom-laserwave)
(doom-opera-light . doom-opera)
(birds-of-paradise-plus . doom-dracula)
(doom-dracula . purple-haze)
(material-light . material)
(sanityinc-tomorrow-day . sanityinc-tomorrow-eighties)
(apropospriate-light . apropospriate-dark)
(spacemacs-light . spacemacs-dark)
(srcery . srcery)
(gotham . gotham)
(purple-haze . purple-haze)
(kaolin-breeze . kaolin-blossom)
(ef-summer . ef-rosa)))
(setq e454iel-current-theme-pairs e454iel-theme-pairs)
(setq e454iel-use-day-theme t)
(setq e454iel-apply-to-stumpwm nil)
(defun e454iel-toggle-use-day-theme()
"Switch between using the day theme and the night theme."
(interactive)
(setq e454iel-use-day-theme (not e454iel-use-day-theme))
(e454iel-load-theme))
(defun e454iel-cycle-theme-pairs ()
"Cycle through pairs of themes."
(interactive)
(setq e454iel-current-theme-pairs
(if (cdr e454iel-current-theme-pairs)
(cdr e454iel-current-theme-pairs)
;; else
e454iel-theme-pairs))
(e454iel-load-theme))
(defun e454iel-load-theme ()
"Load either the day or the night variant of the current theme pair. Make sure
that all themes that might be loaded by this function are safe, as it loads them
without confirmation."
(let ((theme-to-apply
(if e454iel-use-day-theme
(caar e454iel-current-theme-pairs) ; the theme-to-apply is
; the day theme
(cdar e454iel-current-theme-pairs)))) ; the theme-to-apply is
; the night theme
(load-theme theme-to-apply t)
(if e454iel-apply-to-stumpwm
(e454iel-eval-with-stumpwm "(stumpwm::apply-emacs-colors)"))
theme-to-apply))
;; This looks good. This should be the underlying way of changing it when you
;; know an exact name, and then I should make an ivy interface for picking one
;; conveniently
(defun e454iel-jump-to-theme (theme-to-jump-to)
"Jump to `THEME-TO-JUMP-TO' in `e454iel-theme-pairs' and apply it."
(let ((result
(cl-member-if
(lambda (theme-pair) nil nil
(cond
((equal (car theme-pair) theme-to-jump-to)
(progn (setq e454iel-use-day-theme t) t))
((equal (cdr theme-pair) theme-to-jump-to)
(progn (setq e454iel-use-day-theme nil) t))
(t nil)))
e454iel-theme-pairs)))
(if result
(progn (setq e454iel-current-theme-pairs result)
(e454iel-load-theme)))))
;;(e454iel-load-theme)
(defun e454iel-disable-all-theme-pairs ()
"Run `disable-theme' on every theme in `e454iel-theme-pairs'."
(mapc
(lambda (x)
(disable-theme (car x))
(disable-theme (cdr x)))
e454iel-theme-pairs))
;; load default theme
(e454iel-jump-to-theme 'ef-rosa)
;; fonts
;; Add fallback black and white rendering of emojis
;;(set-fontset-font t 'unicode (font-spec :name "OpenMoji" :style "Color") nil 'prepend)
;;(set-fontset-font t 'unicode "Symbola" nil 'append)
;; Add spacing between the lines to make text easier to read
(defvar e454iel-default-line-spacing)
(defvar e454iel-extra-line-spacing)
(setq e454iel-default-line-spacing 4)
(setq e454iel-extra-line-spacing (if e454iel-touch-screen-p 12 24))
(setq-default line-spacing e454iel-default-line-spacing)
;; TODO: Set up handling of phone vs desktop fonts in a way that is less likely
;; to suffer from side effect related problems
;; TODO: Create docstrings for these
(defvar e454iel-font-pairs)
(defvar e454iel-phone-font-pairs)
(defvar e454iel-tablet-font-pairs)
(defvar e454iel-current-font-pairs)
(defvar e454iel-font-scale)
(defvar e454iel-use-dyslexic-font nil)
;; TODO: Add error handling if I don't have an installed font, so I just skip
;; over it. Look at Tecosaur's config for an example
(setq e454iel-font-pairs '(("Inconsolata" . 14)
("Dina" . 14)
("Tamzen" . 14)
("Hermit" . 14)
("monofur" . 16)
("Fantasque Sans Mono" . 16)
("Source Code Pro" . 14)
("Camingo Code" . 14)
("Monoid" . 12)
("Iosevka Term Slab Extended" . 14)
("Cozette" . 8)
))
(setq e454iel-phone-font-pairs
'(("Fantasque Sans Mono" . 6)
("Hermit" . 5)
))
(if e454iel-phone-p
(setq e454iel-font-pairs e454iel-phone-font-pairs))
(setq e454iel-tablet-font-pairs
'(("Fantasque Sans Mono" . 14)
("Hermit" . 13)
))
(if e454iel-tablet-p
(setq e454iel-font-pairs e454iel-tablet-font-pairs))
(setq e454iel-current-font-pairs e454iel-font-pairs)
(setq e454iel-font-scale 0)
;;(defun e454iel-cycle-fonts ()
;; (interactive)
;; (add-to-list 'e454iel-fonts e454iel-current-font t)
;; (setq e454iel-current-font (pop e454iel-fonts))
;; (e454iel-load-font))
(defun e454iel-cycle-fonts ()
"Cycle through pairs of themes."
(interactive)
(setq e454iel-current-font-pairs (cdr e454iel-current-font-pairs))
(if (not e454iel-current-font-pairs)
(setq e454iel-current-font-pairs e454iel-font-pairs))
(e454iel-load-font))
(defun e454iel-increase-font-size ()
(interactive)
(setq e454iel-font-scale (+ 1 e454iel-font-scale))
(e454iel-load-font))
(defun e454iel-decrease-font-size ()
(interactive)
(setq e454iel-font-scale (+ -1 e454iel-font-scale))
(e454iel-load-font))
;;(defun elephant454initel-load-font ()
;;(set-default-font elephant454initel-current-font)
;;(car (split-string (elt (font-info (find-font elephant454initel-current-font)) 1) ":")))
(defun e454iel-toggle-use-dyslexic-font ()
"Switch between using the currently selected font and the opendyslexic font.
This makes for easier reading of larger, denser bodies of text."
(interactive)
(setq e454iel-use-dyslexic-font (not e454iel-use-dyslexic-font))
(e454iel-load-font))
(defun e454iel-toggle-use-extra-line-spacing ()
"Toggle between using `e454iel-default-line-spacing' and `e454iel-extra-line-spacing' in the current buffer."
(interactive)
;; If line-spacing equals default, it is set to extra. Otherwise (whether it
;; equals extra or any other value), it is set to default
(if (= line-spacing e454iel-default-line-spacing)
(setq-local line-spacing e454iel-extra-line-spacing)
;; else
(setq-local line-spacing e454iel-default-line-spacing)))
(defun e454iel-load-font ()
(let ((font-string
(concat
;; Use the dyslexic font if it is toggled on, otherwise fallback to the
;; font pair
(if e454iel-use-dyslexic-font
"opendyslexicmono"
(caar e454iel-current-font-pairs))
"-"
(number-to-string
(+ e454iel-font-scale (cdar e454iel-current-font-pairs))))))
(set-frame-font font-string nil t)
(if e454iel-apply-to-stumpwm
(e454iel-eval-with-stumpwm "(stumpwm::apply-emacs-font)"))
font-string))
(defun e454iel-jump-to-font (font-to-jump-to)
"Jump to `FONT-TO-JUMP-TO' in `e454iel-font-pairs' and apply it."
(interactive (list
(completing-read
"Which font do you want to jump to?: "
e454iel-font-pairs)))
(let ((result
(cl-member-if
(lambda (font-pair) nil nil
(equal (car font-pair) font-to-jump-to))
e454iel-font-pairs)))
(if result
(progn (setq e454iel-current-font-pairs result)
(e454iel-load-font)))))
;;(elephant454initel-load-font)
;; Check out "spacemacs/core/core-spacemacs.el:121"
(message "Setting the font..."
(e454iel-jump-to-font "Fantasque Sans Mono"))
;; for all of the modal Vim keybinding goodness
(use-package evil
:demand
:init
(progn
;;(custom-set-variables '(evil-undo-system 'undo-tree))
;; I need this according to evil if I want undo in non-file buffers
;;(add-hook 'evil-local-mode-hook 'turn-on-undo-tree-mode)
;; Required by evil-collection
(setq evil-want-keybinding nil))
:config (progn
(evil-mode t)
(setq evil-want-minibuffer t)
(use-package evil-escape
:config
(progn
(setq evil-escape-unordered-key-sequence t)
(setq evil-escape-delay (if e454iel-touch-screen-p 0.3 0.1))
(evil-escape-mode t)))
(use-package fringe-helper
:config (use-package evil-fringe-mark
:config (global-evil-fringe-mark-mode t)))
;; A collection of Evil keybindings for various packages
(use-package evil-collection)))
(use-package general
:demand t
:config
(progn
(global-unset-key (kbd "<C-SPC>"))
(global-unset-key (kbd "<C-,>"))
(general-define-key
;; Does it make sense for this to apply to insert/emacs states?
:keymaps '(normal insert emacs motion)
"<C-left>" 'previous-buffer
"<C-right>" 'next-buffer
;; These are the mouse "back" and "forward" buttons respectively
"<mouse-8>" 'previous-buffer
"<mouse-9>" 'next-buffer)
(general-create-definer e454iel-main-menu
:keymaps '(normal insert motion emacs)
:prefix "SPC"
:non-normal-prefix "C-SPC"
:prefix-command 'e454iel-main-menu-prefix)
(general-create-definer e454iel-major-mode-menu
:states '(normal insert motion emacs)
:prefix ","
:non-normal-prefix "C-,")
(e454iel-main-menu
;;"" 'nil
;; double tap Space for M-x
"<SPC>" '(execute-extended-command :which-key "Main Menu")
"u" 'universal-argument
;; evaluate a snippet of emacs lisp
":" 'eval-expression
"l" 'eval-expression
;; modify windows using vim-like keybindings
"w" '(evil-window-map :which-key "Window")
;; buffer commands
"b" '(:ignore t :which-key "Buffer") ; label
"bb" 'switch-to-buffer ; switch buffers
"bd" 'kill-this-buffer ; delete current buffer
"bp" 'popwin:display-buffer ; display a buffer using popwin
;; I might want to look into how immortal-scratch-buffer handles this
"bs" '(lambda() (interactive) (switch-to-buffer "*scratch*"))
"bh" 'previous-buffer
"bl" 'next-buffer
;; TODO: Make it so I can use space in ibuffer. There's no reason why I
;; should be able to.
"bi" 'ibuffer
"br" 'rename-buffer
;; file commands
"f" '(:ignore t :which-key "File") ; label
"ff" 'find-file ; open a dialog to open a file
"f C-f" 'sudo-edit
"fe" 'ediff
;; file bookmark commands
"fd" '(lambda() (interactive) (find-file
(file-truename
e454iel-documents-dir)))
"fy" 'kill-buffer-file-name
"fs" 'save-buffer
;; Manipulating text commands
"m" '(:ignore t :which-key "Manipulate Text")
"mi" '(:ignore t :which-key "Insert")
"mic" 'insert-char
"mc" '(lambda () (interactive)
(if mark-active
(call-interactively 'count-words-region)
(call-interactively 'count-words)))
;; Shells
"s" '(:ignore t :which-key "Shells")
"ss" 'shell ; open a shell
"se" 'eshell
"si" 'ielm
"sa" 'ansi-term
"sp" 'run-python
"sg" 'geiser
"sl" 'slime
"sv" 'vterm
;; open this configuration file (why is the
;; lambda and interactive necessary?)
;; Maybe it's because it's expecting a single
;; function, and lambda is defining an
;; anonymous one here.
;; Interactive I'm not really sure about.
;; Check the info page?
;; file-truename is so that we get the real
;; name of the file after following symbolic
;; links.
"i" '(lambda() (interactive) (find-file
(file-truename
"~/.emacs.d/init.el")))
;; settings/toggles
"t" '(:ignore t :which-key "Toggles/Settings")
;; themes
"tt" '(:ignore t :which-key "Themes")
"tts" 'load-theme
"ttn" 'e454iel-cycle-theme-pairs
"ttt" 'e454iel-toggle-use-day-theme
;; fonts
"tf" '(:ignore t :which-key "Fonts")
"tfs" 'e454iel-jump-to-font
"tfn" 'e454iel-cycle-fonts
"tfi" 'e454iel-increase-font-size
"tfd" 'e454iel-decrease-font-size
"tft" 'e454iel-toggle-use-dyslexic-font
"tl" 'e454iel-toggle-use-extra-line-spacing
;; misc toggles
"ta" 'auto-fill-mode
"tr" '(lambda() (interactive)
(if (yes-or-no-p "Really restart Emacs? ") (restart-emacs)))
"td" '(:ignore t :which-key "Debug")
"tde" 'toggle-debug-on-error
"tdq" 'toggle-debug-on-quit
"a" '(:ignore t :which-key "Applications")
"ai" '(:ignore t :which-key "Internet")
"ap" 'epkg-list-packages
"aP" (lambda() (interactive) (find-file
(file-truename
"~/.emacs.d/straight/repos/melpa/")))
"ag" '(:ignore t :which-key "Games")
"am" '(:ignore t :which-key "Music")
"ac" '(:ignore t :which-key "Chat")
"aci" '(:ignore t :which-key "IRC")
"h" '(help-command :which-key "Help")
"<left>" 'previous-buffer
"<right>" 'next-buffer
)))
;; Completion framework and completion framework accessories
;; TODO: Do I want to use vertico instead? How do they compare? Is there a
;; SystemCrafters video on this?
;; TODO: Make sure to read the Selectrum Complementary Extensions
;; (https://github.com/raxod502/selectrum#complementary-extensions)
;; https://www.emacswiki.org/emacs/Icicles
;; https://github.com/oantolin/embark/
;; https://github.com/minad/consult#embark-integration
;; https://github.com/minad/consult#available-commands
;; https://github.com/minad/consult
;; TODO: Read the full README (and the available Wikis) for every package I use
;; (and maybe also the related packages) (selectrum, vertico, consult,
;; orderless, CtrlF, AMX, icicles, embark, marginalia, corfu, cape)
(use-package vertico
:config (progn
(evil-collection-init 'vertico)
(vertico-mode)
(use-package consult
:config
(progn
(use-package consult-eglot)
;; TODO: If I switch most of my checkers to Flycheck, this will
;; be a lot more useful
(use-package consult-flycheck)
;; TODO: Why isn't this available?
;; https://github.com/karthink/consult-dir
;;(use-package consult-dir)
)
:general
;; TODO: Look into modifying some hook or some variable or
;; something so that evil's "n" and "N" commands correspond to
;; what I search with consult-line
([remap evil-search-forward] #'consult-line
[remap isearch-forward] #'consult-line)
)
(use-package orderless
:config
(progn
(setq completion-styles '(orderless))
(savehist-mode)
))
(use-package marginalia
:config
(progn
(marginalia-mode)))
:general
(general-define-key
:states 'normal
:keymaps 'vertico-map
"j" 'vertico-next
"k" 'vertico-previous
"<return>" 'vertico-exit)
))
(use-package corfu
:config (progn
;; Enable cycling for `corfu-next/previous'
(setq corfu-cycle t)
;; Enable auto completion
(setq corfu-auto t)
(setq corfu-auto-delay 0.2)
;; Quit at completion boundary
(setq corfu-quit-at-boundary t)
;; Quit if there is no match
(setq corfu-quit-no-match t)
;; Disable current candidate preview
(setq corfu-preview-current t)
;; Disable candidate preselection
(setq corfu-preselect-first t)
;; Disable documentation in the echo area
(setq corfu-echo-documentation t)
;; Use scroll margin
(setq corfu-scroll-margin 5)
;; Don't TAB cycle
(setq completion-cycle-threshold nil)
;; Enable indentation+completion using the TAB key.
(setq tab-always-indent 'complete)
(setq evil-collection-corfu-maps 'magic-return)
(evil-collection-init 'corfu)
(use-package cape
:config
(progn
(add-to-list 'completion-at-point-functions #'cape-dabbrev)
(add-to-list 'completion-at-point-functions #'cape-history)
(add-to-list 'completion-at-point-functions #'cape-keyword)
;;(add-to-list 'completion-at-point-functions #'cape-symbol)
(add-to-list 'completion-at-point-functions #'cape-abbrev)
;;(add-to-list 'completion-at-point-functions #'cape-ispell)
;;(add-to-list 'completion-at-point-functions #'cape-dict)
;;(add-to-list 'completion-at-point-functions #'cape-line)
;;(add-to-list 'completion-at-point-functions #'cape-rfc1345)
))
;; Allow Corfu to be used in the minibuffer
(progn
(defun corfu-enable-always-in-minibuffer ()
"Enable Corfu in the minibuffer if Vertico/Mct are not active."
(unless (or (bound-and-true-p mct--active)
(bound-and-true-p vertico--input)
(eq (current-local-map) read-passwd-map))
;; (setq-local corfu-auto nil) ;; Enable/disable auto completion
(setq-local corfu-echo-delay nil ;; Disable automatic echo and popup
corfu-popupinfo-delay nil)
(corfu-mode 1)))
(add-hook 'minibuffer-setup-hook #'corfu-enable-always-in-minibuffer 1))
;; TODO: Is this safe?
(general-define-key
:keymaps 'minibuffer-mode-map
"TAB" 'indent-for-tab-command)
(global-corfu-mode)
)
)
(use-package mini-frame
:disabled
:config
(progn
(setq mini-frame-show-parameters
`((top . 0.4)
(width . 0.7)
(left . 0.5)
;;(font . ,(concat
;; (caar e454iel-current-font-pairs)
;; "-"
;; (format "%s" (+ (cdar e454iel-current-font-pairs) e454iel-font-scale 2))))
))
(push 'consult-line mini-frame-ignore-commands)
(mini-frame-mode)))
(use-package ivy
:disabled
:config (progn
(ivy-mode t)
(use-package counsel
:config
(counsel-mode t)
;; TODO: Check if enabling counsel mode makes this code redundant
;;(general-define-key
;; :keymaps 'help-map
;; "b" 'counsel-descbinds)
)
(use-package counsel-tramp)
(use-package swiper
:config (general-define-key
:keymaps '(normal insert motion emacs)
:prefix "/"
:non-normal-prefix "C-s"
"" 'swiper))))
;; this shows possible key combinations in a pop-up (like when I do C-x, C-c,
;; etc.)
(use-package which-key
:config (which-key-mode t))
(use-package info
:config (progn
;; TODO: Does this package still exist?
;;(use-package info-rename-buffer-mode
;; :config (add-hook 'Info-mode-hook 'info-rename-buffer-mode))
(evil-collection-init 'info)
;; Unbinds SPC
(general-define-key
:states '(normal motion)
:keymaps 'Info-mode-map
"<SPC>" 'e454iel-main-menu-prefix)
;; Automatic renaming of buffers based on topic in order to allow multiple
;; simultaneous Info buffers
(use-package info-rename-buffer
:config (info-rename-buffer-mode))
;; Spawn new uniquely-named Info buffers by typing in a topic from
;; completing-read (this package may be redundant, but I /do/ really
;; like using completing-read for picking a topic)
(use-package info-buffer
:general ([remap info] #'info-buffer))))
(use-package all-the-icons
;; TODO: There needs to be some way of telling whether or not these icons
;; have been downloaded. I only want to install on the first run.
;;:config (all-the-icons-install-fonts)
:config
(progn
;; According to the readme for all-the-icons-ibuffer, this reduces
;; sluggishness when there are multiple icons on screen at the same
;; time
(setq inhibit-compacting-font-caches t)))
(use-package ibuffer
:config (progn
(evil-collection-init 'ibuffer)
(use-package all-the-icons-ibuffer
;; TODO: There ought to be a cleaner way to turn this on only when
;; ibuffer is opened
:init (all-the-icons-ibuffer-mode 1))
(general-define-key
;;:states '(normal motion)
:keymaps 'ibuffer-mode-map
"<SPC>" 'e454iel-main-menu-prefix)))
(use-package grep
:config (general-define-key
:states '(normal motion)
:keymaps 'grep-mode-map
"<SPC>" 'e454iel-main-menu-prefix))
(use-package dired
:straight (dired :type built-in)
:init (use-package dired-x
:straight (dired-x :type built-in))
:config (progn
;; When we have two dired windows open, operations like "Copy" or
;; "Rename" default to the directory of the other open window
(setq dired-dwim-target t)
(evil-collection-init 'dired)
(general-define-key
:states 'normal