-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.el
3104 lines (2796 loc) · 103 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
;;; -*- lexical-binding: t; no-byte-compile: t -*-
(progn ; startup
(defvar before-user-init-time (current-time)
"Value of `current-time' when Emacs begins loading `user-init-file'.")
;; (switch-to-buffer "*Messages*")
(message "Loading Emacs...done (%fs)"
(float-time (time-subtract before-user-init-time
before-init-time)))
(setq user-init-file (or load-file-name buffer-file-name))
(setq user-emacs-directory (file-name-directory user-init-file))
(message "Loading %s..." user-init-file)
)
(progn
(setq inhibit-startup-buffer-menu t)
(setq inhibit-startup-screen t)
(setq inhibit-startup-echo-area-message "locutus")
(setq initial-buffer-choice t)
;; (setq initial-scratch-message "")
;; This improves performance for some fonts
(setq inhibit-compacting-font-cache t)
;; emacs.stackexchange/how-to-disable-emacs-bidi
(setq-default bidi-paragraph-direction 'left-to-right)
(setq bidi-inhibit-bpa t
long-line-threshold 1000
large-hscroll-threshold 1000
syntax-wholeline-max 1000)
(setq use-dialog-box nil)
(setq confirm-kill-emacs 'y-or-n-p)
(put 'downcase-region 'disabled nil)
(put 'upcase-region 'disabled nil)
)
(global-auto-revert-mode)
(use-package borg
:init
(add-to-list 'load-path
(expand-file-name "lib/borg" user-emacs-directory))
:config
(borg-initialize)
(switch-to-buffer "*Messages*")
)
(use-package auto-compile
:config
(setq auto-compile-display-buffer nil
auto-compile-mode-line-counter t
auto-compile-source-recreate-deletes-dest t
auto-compile-toggle-deletes-nonlib-dest t
auto-compile-update-autoloads t
warning-suppress-log-types '((comp))
)
)
(use-package epkg
:defer t
:bind
([remap describe-package] . epkg-describe-package)
:init
(setq epkg-repository
(expand-file-name "var/epkgs/" user-emacs-directory))
(setq epkg-database-connector 'sqlite-builtin ) ; requires emacs >=29
)
(use-package custom
:no-require t
:config
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(setf custom-safe-themes t) ;Treat all themes as safe
(when (file-exists-p custom-file)
(load custom-file))
)
(use-package server
:commands (server-running-p)
:config (or (server-running-p) (server-mode)))
(use-package gcmh
:init
(setq gcmh-high-cons-threshold 536870912) ;; 512mb
:config
(gcmh-mode 1)
)
(use-package no-littering)
(use-package dash
:config (global-dash-fontify-mode))
(use-package eieio)
(use-package diff-mode
:defer t
:config
(when (>= emacs-major-version 27)
(set-face-attribute 'diff-refine-changed nil :extend t)
(set-face-attribute 'diff-refine-removed nil :extend t)
(set-face-attribute 'diff-refine-added nil :extend t)))
(use-package dired
:defer t
:config (setq dired-listing-switches "-alh"))
(use-package eldoc
:when (version< "25" emacs-version)
:config (global-eldoc-mode))
(use-package help
:defer t
:config (temp-buffer-resize-mode))
(use-package helpful
:bind
([remap describe-key] . helpful-key)
([remap describe-command] . helpful-command)
([remap describe-variable] . helpful-variable)
([remap describe-function] . helpful-callable)
("C-h F" . describe-face)
("C-h K" . describe-keymap)
:config
;; (defun my/helpful--syntax-highlight (string)
;; (propertize string 'family 'fixed-pitch))
;; (advice-add 'helpful--syntax-highlight :filter-return #'my/helpful--syntax-highlight)
)
(use-package info+
:defer t
:config
)
(use-package info-colors
:config
(add-hook 'Info-selection-hook 'info-colors-fontify-node)
(add-hook 'Info-mode-hook 'olivetti-mode)
(add-hook 'Info-mode-hook 'mixed-pitch-mode)
)
(progn ; `isearch'
(setq isearch-allow-scroll t))
(use-package lisp-mode
:config
(add-hook 'emacs-lisp-mode-hook 'outline-minor-mode)
(add-hook 'emacs-lisp-mode-hook 'reveal-mode)
(defun indent-spaces-mode ()
(setq indent-tabs-mode nil))
(add-hook 'lisp-interaction-mode-hook 'indent-spaces-mode))
(use-package man
:defer t
:config (setq Man-width 80))
(use-package prog-mode
:config
(global-prettify-symbols-mode)
(defun indicate-buffer-boundaries-left ()
(setq indicate-buffer-boundaries 'left))
(add-hook 'prog-mode-hook 'indicate-buffer-boundaries-left)
)
(use-package recentf
:demand t
:config (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?x?:"))
;; Persist history over Emacs restarts. Vertico sorts by history position.
(use-package savehist
:init
(savehist-mode))
;; A few more useful configurations...
(use-package emacs
:init
;; Add prompt indicator to `completing-read-multiple'.
;; We display [CRM<separator>], e.g., [CRM,] if the separator is a comma.
(defun crm-indicator (args)
(cons (format "[CRM%s] %s"
(replace-regexp-in-string
"\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" ""
crm-separator)
(car args))
(cdr args)))
(advice-add #'completing-read-multiple :filter-args #'crm-indicator)
;; Do not allow the cursor in the minibuffer prompt
(setq minibuffer-prompt-properties
'(read-only t cursor-intangible t face minibuffer-prompt))
(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)
;; Emacs 28: Hide commands in M-x which do not work in the current mode.
;; Vertico commands are hidden in normal buffers.
;; (setq read-extended-command-predicate
;; #'command-completion-default-include-p)
;; Enable recursive minibuffers
(setq enable-recursive-minibuffers t))
(use-package simple
:config (column-number-mode))
(use-package smerge-mode
:defer t
:config
(when (>= emacs-major-version 27)
(set-face-attribute 'smerge-refined-removed nil :extend t)
(set-face-attribute 'smerge-refined-added nil :extend t)))
(progn ; `text-mode'
(add-hook 'text-mode-hook 'indicate-buffer-boundaries-left))
(use-package tramp
:config
(add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:"))
(add-to-list 'tramp-default-proxies-alist '("localhost" nil nil))
(add-to-list 'tramp-default-proxies-alist
(list (regexp-quote (system-name)) nil nil))
(setq vc-ignore-dir-regexp
(format "\\(%s\\)\\|\\(%s\\)"
vc-ignore-dir-regexp
tramp-file-name-regexp)))
(use-package tramp-sh
:config (cl-pushnew 'tramp-own-remote-path tramp-remote-path))
(use-package pixel-scroll
:config
(setq scroll-conservatively 97)
(setq scroll-preserve-screen-position 1)
(setq mouse-wheel-progressive-speed nil)
;; The following piece of code is stolen from
;; https://emacs-china.org/t/topic/25114/5
(pixel-scroll-precision-mode 1)
(setq pixel-scroll-precision-interpolate-page t)
(defun +pixel-scroll-interpolate-down (&optional lines)
(interactive)
(if lines
(pixel-scroll-precision-interpolate (* -1 lines (pixel-line-height)))
(pixel-scroll-interpolate-down)))
(defun +pixel-scroll-interpolate-up (&optional lines)
(interactive)
(if lines
(pixel-scroll-precision-interpolate (* lines
(pixel-line-height))))
(pixel-scroll-interpolate-up))
(defalias 'scroll-up-command '+pixel-scroll-interpolate-down)
(defalias 'scroll-down-command '+pixel-scroll-interpolate-up)
)
(progn ; startup
(message "Loading core units...done (%fs)"
(float-time (time-subtract (current-time) before-user-init-time))))
;; [[file:config.org::*General.el][General.el:1]]
;; Make ESC quit prompts
;; (global-set-key ([kbd] "<escape>") 'keyboard-escape-quit)
(use-package general)
;; General.el:1 ends here
;; [[file:config.org::*Meow.el][Meow.el:1]]
(use-package meow
:custom-face
(meow-cheatsheet-command ((t (:height 180 :inherit fixed-pitch))))
:config
;cate the behavior of vi's
(defun my-meow-append ()
"Move to the end of selection, switch to INSERT state."
(interactive)
(if meow--temp-normal
(progn
(message "Quit temporary normal mode")
(meow--switch-state 'motion))
(if (not (region-active-p))
(when (and (not (use-region-p))
(< (point) (point-max)))
(forward-char 1))
(meow--direction-forward)
(meow--cancel-selection))
(meow--switch-state 'insert)))
(advice-add 'meow-append :override #'my-meow-append)
(defun my-meow-open-below ()
"Open a newline below and switch to INSERT state."
(interactive)
(if meow--temp-normal
(progn
(message "Quit temporary normal mode")
(meow--switch-state 'motion))
(meow--switch-state 'insert)
;(goto-char (line-end-position))
(move-end-of-line 1)
(meow--execute-kbd-macro "RET")))
(advice-add 'meow-open-below :override #'my-meow-open-below)
(setq meow-keypad-self-insert-undefined nil)
(setq meow-selection-command-fallback '(
(meow-grab . meow-right-expand)
(meow-change . meow-change-char)
(meow-kill . meow-delete)
(meow-cancel-selection . keyboard-quit)
(meow-pop-selection . meow-pop-grab)
(meow-beacon-change . meow-beacon-change-char)
(meow-replace . meow-yank)
(meow-reverse . negative-argument)
))
(setq meow-cheatsheet-layout meow-cheatsheet-layout-qwerty)
(meow-global-mode)
)
;; Meow.el:1 ends here
;; [[file:config.org::*Mode leader][Mode leader:1]]
(defvar my/mode-leader "C-<escape>")
(defmacro my/key (&optional key)
`(general-key
(if ,key
(concat ,my/mode-leader " " ,key)
,my/mode-leader)))
(general-create-definer my/mode-leader-def
:prefix my/mode-leader
:wk-full-keys nil
)
;; Mode leader:1 ends here
;; [[file:config.org::*Meow-normal][Meow-normal:1]]
(meow-normal-define-key
'("<escape>" . meow-cancel-selection)
'("SPC" . my/leader-prefix-cmd) ;; defined latter
'("1" . meow-expand-1) '("2" . meow-expand-2)
'("3" . meow-expand-3) '("4" . meow-expand-4)
'("5" . meow-expand-5) '("6" . meow-expand-6)
'("7" . meow-expand-7) '("8" . meow-expand-8)
'("9" . meow-expand-9) '("0" . meow-expand-0)
'("*" . tempel-insert) '("+" . tempel-expand)
'("q" . meow-quit) '("Q" . meow-quit)
;'("w" . meow-window) '("W" . meow-window)
'("e" . embark-dwim) '("E" . embark-act)
;'("r" . meow-) '("R" . meow-e)
'("t" . meow-till) '("T" . meow-till-expand)
'("a" . begin-of-line) '("a" . meow-beginning-of-thing)
'("s" . meow) '("s" . meow-bounds-of-thing)
'("d" . meow) '("d" . meow-inner-of-thing)
'("f" . end-of-line) '("f" . meow-end-of-thing)
'("g" . meow-right-expand) '("G" . meow-grab)
'("z" . meow-undo) '("Z" . meow-undo-in-selection)
'("x" . meow-kill) '("X" . meow-clipboard-kill)
'("c" . meow-clipboard-save)
'("v" . meow-replace) '("V" . meow-yank-pop)
'("C-v" . meow-clipboard-yank)
'("b". meow-block) '("B" . meow-to-block)
'("y" . meow-visit)
'("u" . meow-change) '("U" . meow-reverse)
'("i" . meow-insert) '("I" . meow-open-above)
'("o" . meow-append) '("O" . meow-open-below)
'("p" . meow-pop-selection)
'("[" . meow-beginning-of-thing) '("]" . meow-end-of-thing)
'("h" . meow-join) '("H" . meow-join)
'("j" . meow-left) '("J" . meow-left-expand)
'("k" . meow-prev) '("K" . meow-prev-expand)
'("l" . meow-next) '("L" . meow-next-expand)
'(";" . meow-right) '(":" . meow-right-expand)
'("'" . meow-line) '("\"" . meow-line)
'("C-j" . "C-<escape> C-j")
'("C-k" . "C-<escape> C-k")
'("C-l" . "C-<escape> C-l")
'("C-;" . "C-<escape> C-;")
'("n" . meow-search) '("N" . meow-pop-search)
'("m" . meow-mark-word) '("M" . meow-mark-symbol)
'("," . meow-back-word) '("<" . meow-back-symbol)
'("." . meow-next-word) '(">" . meow-next-symbol)
'("/" . meow-reverse)
'("\"" . fingertip-wrap-double-quote)
'("(" . fingertip-wrap-round)
'("[" . fingertip-wrap-bracket)
'("{" . fingertip-wrap-curly)
)
;; Meow-normal:1 ends here
;; [[file:config.org::*Meow-motion][Meow-motion:1]]
(meow-motion-overwrite-define-key
'("j" . meow-left)
'("k" . meow-prev)
'("l" . meow-next)
'(";" . meow-right)
'("SPC" . my/leader-prefix-cmd) ;; defined latter
'("<escape>" . ignore)
)
;; Meow-motion:1 ends here
;; [[file:config.org::*Meow-keypad][Meow-keypad:1]]
(meow-leader-define-key
;; Use SPC (0-9) for digit arguments.
'("1" . meow-digit-argument) '("2" . meow-digit-argument)
'("3" . meow-digit-argument) '("4" . meow-digit-argument)
'("5" . meow-digit-argument) '("6" . meow-digit-argument)
'("7" . meow-digit-argument) '("8" . meow-digit-argument)
'("9" . meow-digit-argument) '("0" . meow-digit-argument)
'("/" . meow-keypad-describe-key) '("?" . meow-cheatsheet)
;;'("SPC" . config/leader-prefix-cmd)
)
;; Meow-keypad:1 ends here
;; [[file:config.org::*Meow-insert][Meow-insert:1]]
(general-def
:keymaps '(global-map)
"C-v" '(clipboard-yank :wk "paste")
"C-SPC" '(toggle-input-method :wk "input method")
"<f12>" 'org-capture
"C-j" (my/key "C-j")
"C-;" (my/key "C-;")
"C-k" (my/key "C-k")
"C-l" (my/key "C-l")
;"C-/" '(yank :wk "comment-dwim")
)
(general-def
:keymaps '(meow-normal-state-keymap meow-motion-state-keymap)
"\\" (my/key)
"M-j" '(windmove-left :wk " Win")
"M-k" '(windmove-up :wk " Win")
"M-l" '(windmove-down :wk " Win")
"M-;" '(windmove-right :wk " Win")
"M-\'" '(delete-window :wk " Win")
"M-," '(sort-tab-select-prev-tab :wk " Tab")
"M-." '(sort-tab-select-next-tab :wk " Tab")
"M-/" '(sort-tab-close-current-tab :wk " Tab")
)
;; Meow-insert:1 ends here
;; [[file:config.org::*Global leader][Global leader:1]]
(general-create-definer my/leader
:prefix-command 'my/leader-prefix-cmd
:prefix-map 'my/leader-prefix-map
:wk-full-keys nil
"DEL" '(which-key-undo :wk "undo-key")
)
;; Global leader:1 ends here
;; [[file:config.org::*Global leader][Global leader:2]]
(my/leader
"SPC" (my/key)
"/" '(comment-dwim :wk "comment")
"c" '(nil :wk "consult")
"d" '(dirvish-side :wk "dirvish-side ")
"D" '(dirvish :wk "dirvish")
"r" '(nil :wk "run")
"s" '(save-buffer :wk "save")
"t" '(nil :wk "toggle")
"w" '(nil :wk "workspace")
"x" '(consult-mode-command :wk "execute")
"z" '(vundo :wk "visual undo")
)
;; Global leader:2 ends here
;; [[file:config.org::*Global leader][Global leader:3]]
(my/leader :infix "r"
"b" '(nil :wk "borg")
"e" '(elfeed :wk " elfeed")
"t" '(telega :wk " telega")
"p" '(profiler-start :wk " profiler")
"P" '(profiler-stop :wk " profiler stop")
)
;; Global leader:3 ends here
;; [[file:config.org::*Global leader][Global leader:4]]
;; Borg
(my/leader :infix "rb"
"a" '(borg-assimilate :wk " assimilate ")
"b" '(borg-build :wk " build")
"c" '(borg-clone :wk " clone")
"d" '(borg-remove :wk " delete")
"r" '(borg-activate :wk " run")
)
;; Global leader:4 ends here
;; [[file:config.org::*Global leader][Global leader:5]]
(my/leader :infix "c"
"l" '(consult-line :wk "line")
"L" '(consult-line-multi :wk "line multi")
"o" '(consult-outline :wk "outline")
"i" '(consult-imenu :wk "imenu")
"I" '(consult-imenu-multi :wk "imenu multi")
"r" '(consult-ripgrep :wk "ripgrep")
"m" '(consult-mark :wk "mark")
"x" '(consult-mode-command :wk "execute")
)
;; Global leader:5 ends here
;; [[file:config.org::*Global leader][Global leader:6]]
(my/leader :infix "w" ;; workspaces
"\\" '(tab-new :wk "tab ")
"|" '(tab-close :wk "tab ")
"[" '(tab-previous :wk "tab ")
"]" '(tab-next :wk "tab ")
"/" '(consult-buffer :wk "buffer ")
"f" '(find-file :wk "file ")
"r" '(revert-buffer-quick :wk "revert")
"J" '(split-window-right :wk "split ")
"K" '(split-window-below :wk "split ")
"L" '(split-window-above :wk "split ")
":" '(split-window-left :wk "split ")
)
;; Global leader:6 ends here
;; [[file:config.org::*Global leader][Global leader:7]]
;; toggle
(my/leader :infix "t"
"o" '(olivetti-mode :wk " olivetti")
"l" '(nil :wk " line Number ")
)
(my/leader :infix "tl"
"DEL" '(which-key-undo :wk " Undo key ")
"n" '(config/toggle-line-number-nil :wk " Nil ")
"a" '(config/toggle-line-number-absolute :wk " Absolute ")
"r" '(config/toggle-line-number-relative :wk " Relative ")
"v" '(config/toggle-line-number-visual :wk " Visual ")
"h" '(hl-line-mode :wk " Hl-line")
)
;; Global leader:7 ends here
;; [[file:config.org::*Global leader][Global leader:8]]
;; Git
(my/leader :infix "g"
"" '(nil :wk "git")
"g" '(magit :wk " magit")
)
;; Global leader:8 ends here
;; [[file:config.org::*Global leader][Global leader:9]]
;; windows, buffers and tabs(workspaces)
;; these are copied from emacs source code
(defun split-window-left (&optional size window-to-split)
(interactive `(,(when current-prefix-arg
(prefix-numeric-value current-prefix-arg))
,(selected-window)))
(let (new-window)
(when (and size (< size 0) (< (- size) window-min-width))
;; `split-window' would not signal an error here.
(error "Size of new window too small"))
(setq new-window (split-window window-to-split size 'left))
;; Always copy quit-restore parameter in interactive use.
(let ((quit-restore (window-parameter window-to-split 'quit-restore)))
(when quit-restore
(set-window-parameter new-window 'quit-restore quit-restore)))
new-window))
(defun split-window-above (&optional size window-to-split)
(interactive `(,(when current-prefix-arg
(prefix-numeric-value current-prefix-arg))
,(selected-window)))
(let ((old-point (window-point))
moved-by-window-height moved new-window bottom)
(when (and size (< size 0) (< (- size) window-min-height))
;; `split-window' would not signal an error here.
(error "Size of new window too small"))
(setq new-window (split-window window-to-split size 'above))
(when (and (null split-window-keep-point)
(or (null window-to-split)
(eq window-to-split (selected-window))))
(with-current-buffer (window-buffer window-to-split)
(save-excursion
(goto-char (window-start))
(setq moved (vertical-motion (window-height)))
(set-window-start new-window (point))
(when (> (point) (window-point new-window))
(set-window-point new-window (point)))
(when (= moved (window-height))
(setq moved-by-window-height t)
(vertical-motion -1))
(setq bottom (point)))
(and moved-by-window-height
(<= bottom (point))
(set-window-point window-to-split (1- bottom)))
(and moved-by-window-height
(<= (window-start new-window) old-point)
(set-window-point new-window old-point)
(select-window new-window))))
;; Always copy quit-restore parameter in interactive use.
(let ((quit-restore (window-parameter window-to-split 'quit-restore)))
(when quit-restore
(set-window-parameter new-window 'quit-restore quit-restore)))
new-window))
;; Global leader:9 ends here
;; [[file:config.org::*Transient][Transient:1]]
(use-package transient-posframe
:config
(setq transient-posframe-min-height 1)
(setq transient-posframe-poshandler
'posframe-poshandler-frame-bottom-right-corner)
(transient-posframe-mode)
)
;; Transient:1 ends here
;; [[file:config.org::*Which-key.el][Which-key.el:1]]
(use-package which-key
:init
;; contents
(setq which-key-sort-order 'which-key-key-order)
(setq which-key-sort-uppercase-first nil)
;; delays
(setq which-key-idle-delay 0.01) ; the first idle
(setq which-key-idle-secondary-delay 0.01) ; set to 0 will cause some problems
(setq which-key-show-early-on-C-h t)
;; arrangements
(setq which-key-max-display-columns nil)
(setq which-key-max-description-length 25) ;
(setq which-key-allow-imprecise-window-fit t) ; reduce delay
(setq which-key-show-transient-maps t)
(setq which-key-frame-max-height 60)
;; window
(setq which-key-popup-type 'side-window)
(setq which-key-side-window-location 'right)
;; characters
(setq which-key-prefix-prefix " ")
(setq which-key-separator " ") ; yeah I don't like the arrow
;; (dolist (replace
;; '((("SPC" . nil) . ("" . nil))
;; (("TAB" . nil) . ("" . nil))
;; (("RET" . nil) . ("" . nil))
;; (("DEL" . nil) . ("" . nil))
;; ))
;; (add-to-list 'which-key-replacement-alist replace))
:config
(set-face-attribute 'which-key-key-face nil :inherit 'fixed-pitch)
(which-key-mode 1)
)
;; Which-key.el:1 ends here
;; [[file:config.org::*Which-key.el][Which-key.el:2]]
(use-package which-key-posframe
:after which-key
:config
(setq which-key-posframe-poshandler
'posframe-poshandler-frame-bottom-right-corner)
(setq which-key-max-display-columns 1)
(setq which-key-min-display-lines 1)
(which-key-posframe-mode)
)
;; Which-key.el:2 ends here
;; [[file:config.org::*Rime.el][Rime.el:1]]
(use-package rime
:custom
(rime-emacs-module-header-root "~/.nix-profile/include")
(rime-librime-root "~/.nix-profile")
(rime-share-data-dir "~/.config/fcitx/rime")
:config
(setq default-input-method "rime"
rime-show-candidate 'posframe)
(setq rime-disable-predicates
'(meow-normal-mode-p
meow-motion-mode-p
rime-predicate-after-alphabet-char-p
rime-predicate-prog-in-code-p))
(setq pgtk-use-im-context-on-new-connection nil)
)
;; Rime.el:1 ends here
;; [[file:config.org::*Mixed-pitch-mode][Mixed-pitch-mode:1]]
(use-package mixed-pitch
:custom
'(mixed-pitch-fixed-pitch-faces
'(diff-added diff-context diff-file-header diff-function diff-header diff-hunk-header diff-removed
font-latex-math-face font-latex-sedate-face font-latex-warning-face font-latex-sectioning-5-face font-lock-builtin-face font-lock-comment-delimiter-face font-lock-constant-face font-lock-doc-face font-lock-function-name-face font-lock-keyword-face font-lock-negation-char-face font-lock-preprocessor-face font-lock-regexp-grouping-backslash font-lock-regexp-grouping-construct font-lock-string-face font-lock-type-face font-lock-variable-name-face line-number line-number-current-line line-number-major-tick line-number-minor-tick markdown-code-face markdown-gfm-checkbox-face markdown-inline-code-face markdown-language-info-face markdown-language-keyword-face markdown-math-face message-header-name message-header-to message-header-cc message-header-newsgroups message-header-xheader message-header-subject message-header-other mu4e-header-key-face mu4e-header-value-face mu4e-link-face mu4e-contact-face mu4e-compose-separator-face mu4e-compose-header-face
org-document-info-keyword org-code org-indent org-latex-and-related org-checkbox org-formula org-special-keyword org-table org-verbatim widget-field org-modern-label))
'(mixed-pitch-set-height nil)
:config
(setq mixed-pitch-set-height t)
(set-face-attribute
'default nil
:family "IBM Plex Mono Text"
;; :family "Sarasa Gothic SC Nerd Font"
;; :family "IBM Plex Serif"
:height 150)
(set-face-attribute
'fixed-pitch nil
:family "IBM Plex Mono Text"
;; :family "RobotoMono Nerd Font Mono"
;; :family "CommitMono Nerd Font Mono"
;; :family "Sarasa Fixed SC"
;; :family "Monaspace Neon"
:height 1.0)
(set-face-attribute 'fixed-pitch-serif nil
;; :family "Sarasa Gothic SC Nerd Font"
:family "IBM Plex Mono Text"
;; :family "IBM Plex Serif"
:height 1.0)
(set-face-attribute 'variable-pitch nil
;; :family "Sarasa Gothic SC Nerd Font"
:family "IBM Plex Serif"
:height 1.0)
(set-face-attribute 'link nil :underline t :bold nil)
;; patches nerd font
(set-fontset-font t 'han "Source Han Serif SC")
(set-fontset-font t 'symbol "Noto Sans Symbols")
(set-fontset-font t 'nil "Noto Emoji")
(set-fontset-font t 'nil "Weather Icons")
(set-fontset-font t 'nil "Material Icons")
(set-fontset-font t 'nil "github-octicons")
(set-fontset-font t 'nil "file-icons")
(set-fontset-font t 'nil "FontAwesome")
(set-fontset-font t 'nil "Symbols Nerd Font Mono")
)
;; Mixed-pitch-mode:1 ends here
;; [[file:config.org::*Zooming In/Out][Zooming In/Out:1]]
(global-set-key (kbd "C-=") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease)
(global-set-key (kbd "<C-wheel-down>") 'text-scale-decrease)
(global-set-key (kbd "<C-wheel-up>") 'text-scale-increase)
;; Zooming In/Out:1 ends here
;; [[file:config.org::*Line Space][Line Space:1]]
(defun my/toggle-line-spacing ()
"Toggle line spacing between no extra space to extra half line height.
URL `http://xahlee.info/emacs/emacs/emacs_toggle_line_spacing.html'
Version 2017-06-02"
(interactive)
(if line-spacing
(setq line-spacing nil)
(setq line-spacing 0.5))
(redraw-frame (selected-frame)))
;; Line Space:1 ends here
;; [[file:config.org::*All-the-icons][All-the-icons:1]]
(use-package all-the-icons
:if (display-graphic-p))
;(use-package all-the-icons-dired
; :hook (dired-mode . (lambda () (all-the-icons-dired-mode t))))
;; All-the-icons:1 ends here
;; [[file:config.org::*All-the-icons-completion][All-the-icons-completion:1]]
(use-package all-the-icons-completion
:after (marginalia all-the-icons)
:hook (marginalia-mode . all-the-icons-completion-marginalia-setup)
:init
(all-the-icons-completion-mode))
;; All-the-icons-completion:1 ends here
;; [[file:config.org::*Nerd-icons][Nerd-icons:1]]
(use-package nerd-icons
;; :custom
;; The Nerd Font you want to use in GUI
;; "Symbols Nerd Font Mono" is the default and is recommended
;; but you can use any other Nerd Font if you want
;; (nerd-icons-font-family "Symbols Nerd Font Mono")
)
;; Nerd-icons:1 ends here
;; [[file:config.org::*Solaire mode][Solaire mode:1]]
(use-package solaire-mode
:defer t
:init (solaire-global-mode)
:config
(add-hook 'org-src-mode-hook 'turn-off-solaire-mode)
)
;; Solaire mode:1 ends here
;; [[file:config.org::*Posframe][Posframe:1]]
(use-package posframe
:config
(defun posframe-poshandler-frame-upper-center! (info)
"Posframe's position handler.
This poshandler function let center of posframe align to
vertically upper 1/6, horizontally center
of frame."
(cons (/ (max 0 (- (plist-get info :parent-frame-width)
(plist-get info :posframe-width))) 2)
(/ (plist-get info :parent-frame-height) 6)))
(defun posframe-poshandler-window-upper-center! (info)
"Posframe's position handler.
This poshandler function let center of posframe align to
vertically upper 1/6, horizontally center
of window."
(let* ((window-left (plist-get info :parent-window-left))
(window-top (plist-get info :parent-window-top))
(window-width (plist-get info :parent-window-width))
(window-height (plist-get info :parent-window-height))
(posframe-width (plist-get info :posframe-width)))
(cons (max 0 (+ window-left (/ (- window-width posframe-width) 2)))
(+ window-top (/ window-height 6))))
)
)
;; Posframe:1 ends here
;; [[file:config.org::*Transparency][Transparency:1]]
(defun my/set-transparency (value)
"Sets the transparency of the frame window. 0=transparent/100=opaque"
(interactive "nTransparency Value 0 - 100 opaque:")
(set-frame-parameter nil 'alpha-background value))
;; Transparency:1 ends here
;; [[file:config.org::*Olivetti][Olivetti:1]]
(use-package olivetti
:defer nil
:hook (org-mode . olivetti-mode)
(Custom-mode . olivetti-mode)
(help-mode . olivetti-mode)
;(dashboard-mode . olivetti-mode)
(dashboard-mode . variable-pitch-mode)
(olivetti-mode . visual-line-mode)
:init
(setq-default fill-column 100)
:config
;If nil (the default), use the value of fill-column + 2.
(setq olivetti-body-width nil olivetti-style 'fancy)
;; (set-face-attribute 'olivetti-fringe nil :background "#171B24")
(defun config/window-center (width)
(interactive)
(setq fill-column width)
(olivetti-mode)
)
;; (config/leader
;; "tc" '(olivetti-mode :wk " Center")
;; )
)
;; Olivetti:1 ends here
;; [[file:config.org::*Visual-fill-column][Visual-fill-column:1]]
(setq-default visual-fill-column-center-text t)
;; Visual-fill-column:1 ends here
;; [[file:config.org::*Vertico][Vertico:1]]
(use-package vertico
:init
;; Different scroll margin
(setq vertico-scroll-margin 1)
;; Show more candidates
(setq vertico-count 20)
;; Grow the Vertico minibuffer
;; (setq vertico-resize 'grow-only)
;; Optionally enable cycling for `vertico-next' and `vertico-previous'.
(setq vertico-cycle t)
;; use Vertico as an in-buffer completion UI
(setq completion-in-region-function 'consult-completion-in-region)
(vertico-mode 1)
:config
(general-def
:keymaps '(vertico-map)
"C-l" 'vertico-next
"C-k" 'vertico-previous
"C-j" 'vertico-directory-delete-word
"C-;" 'vertico-directory-enter
"C-," 'vertico-previous-group
"C-." 'vertico-next-group
"A-l" 'vertico-next
"A-k" 'vertico-previous
"A-j" 'vertico-directory-delete-word
"A-;" 'vertico-directory-enter
"A-," 'vertico-previous-group
"A-." 'vertico-next-group
"RET" 'vertico-directory-enter
"DEL" 'vertico-directory-delete-char
"M-DEL" 'vertico-directory-delete-word
)
)
;; Vertico:1 ends here
;; [[file:config.org::*Vertico-directory][Vertico-directory:1]]
(use-package vertico-directory
:after vertico
;; More convenient directory navigation commands
:bind (:map vertico-map
)
;; Tidy shadowed file names
:hook (rfn-eshadow-update-overlay . vertico-directory-tidy))
;; Vertico-directory:1 ends here
;; [[file:config.org::*Vertico-multiform][Vertico-multiform:1]]
(use-package vertico-multiform
:after vertico
:config (vertico-multiform-mode)
)
;; Vertico-multiform:1 ends here
;; [[file:config.org::*Vertico-posframe][Vertico-posframe:1]]
(use-package vertico-posframe
;:disabled
:after vertico-multiform
:init
(setq vertico-posframe-poshandler
'posframe-poshandler-frame-top-center)
(setq vertico-count 15
vertico-posframe-border-width 3
vertico-posframe-width 140
)
(setq vertico-posframe-parameters
'((left-fringe . 20)
(right-fringe . 20)))
(setq vertico-multiform-commands
'(
(execute-extended-command ; M-x
(vertico-posframe-poshandler . posframe-poshandler-frame-top-center)
(vertico-posframe-width . 120))
(meow-visit
(vertico-posframe-poshandler . posframe-poshandler-window-top-right-corner)
(vertico-posframe-width . 50))
(meow-yank-pop; M-x
(vertico-posframe-poshandler . posframe-poshandler-point-window-center)
(vertico-posframe-width . 50))
(find-file
(vertico-count . 25)
(vertico-posframe-width . 100)
(vertico-posframe-poshandler . posframe-poshandler-window-upper-center!))
(consult-buffer
(vertico-count . 25)
(vertico-posframe-width . 100)
(vertico-posframe-poshandler . posframe-poshandler-window-upper-center!))
(switch-to-buffer
(vertico-count . 25)
(vertico-posframe-width . 100)
(vertico-posframe-poshandler . posframe-poshandler-window-upper-center!))
(org-insert-link; C-c C-l
(vertico-posframe-poshandler . posframe-poshandler-point-top-left-corner)
(vertico-posframe-width . 70))
(tempel-insert
(vertico-posframe-poshandler . posframe-poshandler-point-top-left-corner)
(vertico-posframe-width . 70))
(consult-imenu
(vertico-count . 40)
(vertico-posframe-poshandler . posframe-poshandler-window-top-right-corner)
(vertico-posframe-width . 80))
(consult-outline
(vertico-count . 30)
(vertico-posframe-poshandler . posframe-poshandler-window-top-right-corner)
(vertico-posframe-width . 40))
(consult-line
(vertico-count . 30)
(vertico-posframe-poshandler . posframe-poshandler-frame-top-right-corner)
(vertico-posframe-width . 60))
(t
(vertico-posframe-poshandler . posframe-poshandler-frame-top-center)
(vertico-posframe-width . 120))
))
:config
(vertico-multiform-mode 1)
(vertico-posframe-mode 1)
)
;; Vertico-posframe:1 ends here
;; [[file:config.org::*Orderless][Orderless:1]]
(use-package orderless
:init
(setq completion-styles '(orderless))
(setq orderless-component-separator
#'orderless-escapable-split-on-space)
(setq orderless-matching-styles
'(orderless-initialism orderless-prefixes orderless-regexp))
)
;; Orderless:1 ends here
;; [[file:config.org::*Savehist][Savehist:1]]
;; Persist history over Emacs restarts. Vertico sorts by history position.
(use-package savehist
:init
(savehist-mode))
;; Savehist:1 ends here
;; [[file:config.org::*Savehist][Savehist:2]]
;; A few more useful configurations...
(use-package emacs
:init
;; Add prompt indicator to `completing-read-multiple'.