-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathinit.el
2771 lines (2410 loc) · 89.3 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 --- user-init-file -*- lexical-binding: t; -*-
(add-to-list 'load-path (locate-user-emacs-file "misc"))
(setq load-prefer-newer t)
;; Apply recommendation from modus Info manual:
(setq face-near-same-color-threshold 45000)
(setq scroll-step 1)
;; I don't use package.el to install packages but I still want to
;; configure autoloads and info manuals:
(package-activate-all)
(progn ; `borg'
(add-to-list 'load-path (expand-file-name "lib/borg" user-emacs-directory))
(require 'borg)
(borg-initialize))
(progn ; `use-package'
(setq use-package-always-defer t)
(setq use-package-enable-imenu-support t)
(setq use-package-minimum-reported-time 0)
(setq use-package-verbose t)
(setq use-package-compute-statistics nil)
(require 'use-package))
(progn ; paragraphs
(set-default 'sentence-end-double-space nil))
(use-package comp
:init
(progn
(setq native-comp-async-report-warnings-errors nil)))
(use-package auto-compile
:demand t
:init
(progn
(setq auto-compile-display-buffer nil)
(setq auto-compile-source-recreate-deletes-dest t)
(setq auto-compile-toggle-deletes-nonlib-dest t)
(setq auto-compile-update-autoloads t))
:hook (auto-compile-inhibit-compile . auto-compile-inhibit-compile-detached-git-head)
:config
(progn
(auto-compile-on-load-mode)
(auto-compile-on-save-mode)
(auto-compile-use-mode-line-set nil nil)))
(use-package no-littering
:demand t
:config
(progn
;; no-littering sets the value of `copilot-install-dir' to
;; something in ~/.emacs.d/var but I want the default value from
;; the `copilot' package instead. This is because the default
;; value comes from Nix and points to the installation directory
;; of "copilot-node-server". Because `copilot' isn't loaded yet,
;; we just delete the variable:
(makunbound 'copilot-install-dir)))
(progn ; `startup'
(setq inhibit-startup-screen t)
(setq initial-buffer-choice t)
(setq initial-major-mode 'text-mode)
(setq initial-scratch-message nil)
(setq user-mail-address "[email protected]"))
(progn ; `files'
(setq make-backup-files nil)
(setq version-control 'never))
(progn ; `filelock'
(setq create-lockfiles nil))
(progn ; `window'
(defun my/kill-this-buffer ()
"Kill current buffer.
Better version of `kill-this-buffer' whose docstring says it is
unreliable."
(interactive)
(kill-buffer (current-buffer)))
(bind-key "C-x k" #'my/kill-this-buffer)
(defun my/toggle-window-split ()
"Swap between horizontal and vertical separation when 2 frames
are visible."
(interactive)
(if (= (count-windows) 2)
(let* ((this-win-buffer (window-buffer))
(next-win-buffer (window-buffer (next-window)))
(this-win-edges (window-edges (selected-window)))
(next-win-edges (window-edges (next-window)))
(this-win-2nd (not (and (<= (car this-win-edges)
(car next-win-edges))
(<= (cadr this-win-edges)
(cadr next-win-edges)))))
(splitter
(if (= (car this-win-edges)
(car (window-edges (next-window))))
'split-window-horizontally
'split-window-vertically)))
(delete-other-windows)
(let ((first-win (selected-window)))
(funcall splitter)
(if this-win-2nd (other-window 1))
(set-window-buffer (selected-window) this-win-buffer)
(set-window-buffer (next-window) next-win-buffer)
(select-window first-win)
(if this-win-2nd (other-window 1))))))
(define-key ctl-x-4-map "t" #'my/toggle-window-split))
(progn ; `map-ynp'
;; Make all "yes or no" prompts show "y or n" instead
(setq read-answer-short t)
(setq use-short-answers t))
(progn ; `editfns'
(put 'narrow-to-region 'disabled nil))
(progn ; `subr'
;; recommended by
;; (info "(embark) How does Embark call the actions?")
(setq y-or-n-p-use-read-key t))
(progn ; `buffer'
(defvar-local my/mode-line-buffer-status
'(buffer-file-name (:eval (cond
((not (mode-line-window-selected-p)) "")
(buffer-read-only (format "🔒 "))
((buffer-modified-p) "💾 ")
(t ""))))
"Return buffer's status: read-only or modified.
Only display something if the buffer is attached to a file and is
either read only or modified.")
(put 'my/mode-line-buffer-status 'risky-local-variable t)
(defvar-local my/mode-line-remote
'(:eval (if (stringp default-directory)
(file-remote-p default-directory)
""))
"Return the host if current buffer is remote, an empty string otherwise.")
(put 'my/mode-line-remote 'risky-local-variable t)
(defun my/mode-line-buffer-identification-face ()
"Return face for `my/mode-line-buffer-identification'."
(when (mode-line-window-selected-p)
'mode-line-buffer-id))
(defvar-local my/mode-line-buffer-identification
'(:eval (propertize (buffer-name)
'face (my/mode-line-buffer-identification-face))))
(put 'my/mode-line-buffer-identification 'risky-local-variable t)
(defvar-local my/mode-line-position
'(:eval (when (mode-line-window-selected-p)
mode-line-position)))
(put 'my/mode-line-position 'risky-local-variable t)
(defvar-local my/mode-line-modes
'(:eval (when (mode-line-window-selected-p)
mode-line-modes)))
(put 'my/mode-line-modes 'risky-local-variable t)
(defvar-local my/mode-line-misc-info
'(:eval (when (mode-line-window-selected-p)
mode-line-misc-info)))
(put 'my/mode-line-misc-info 'risky-local-variable t)
;; Change buffer status to my own function to simplify output:
(setq-default mode-line-format
'("%e" ;; error message about full memory
" "
my/mode-line-buffer-status
my/mode-line-remote
my/mode-line-buffer-identification
" "
my/mode-line-position
" "
my/mode-line-modes
my/mode-line-misc-info)))
(use-package which-func
:defer 5
:config
(progn
(which-function-mode)))
(use-package register
:config
(set-register ?t "!-tests.js !.spec.component.js !_spec.ui.js !_spec.e2e.js"))
(use-package custom
:demand t
:config
(progn
(setq custom-file (no-littering-expand-etc-file-name "custom.el"))
(when (file-exists-p custom-file)
(load custom-file))))
(use-package edebug
:init
(setq edebug-print-length 5000))
(use-package executable
:hook (after-save . executable-make-buffer-file-executable-if-script-p))
(use-package frame
:config
(progn
(defun my/setup-frame (&optional frame)
"Configure look of FRAME.
If FRAME is nil, configure current frame. If non-nil, make FRAME
current."
(when frame (select-frame frame))
(setq frame-title-format "Emacs")
(modify-all-frames-parameters
'((cursor-type bar . 5))))
(my/setup-frame)))
(use-package face-remap
:bind (("C-x C-+" . global-text-scale-adjust)
("C-x C--" . global-text-scale-adjust)
("C-x C-=" . global-text-scale-adjust)
("C-x C-0" . global-text-scale-adjust)))
(use-package window
:bind (("C-x o" . nil))
:init
(progn
(setq switch-to-buffer-obey-display-actions t)
(defun my/window-balance-windows (&rest args)
"Same as `balance-windows' but ignores arguments."
(balance-windows))
(seq-doseq (fn (list #'split-window #'delete-window))
(advice-add fn :after #'my/window-balance-windows))))
(use-package ace-window
:demand t
:bind ("M-o" . ace-window)
:init
(progn
;; home row in a Colemak layout
(setq aw-keys '(?a ?r ?s ?t ?n ?e ?i ?o))
(setq aw-background nil))
:config
(progn
(ace-window-display-mode)
;; reduce the height of ace-window letters so they blend nicely
;; within their buffers without moving pixels around:
(set-face-attribute 'aw-leading-char-face nil :height 1.0)))
(use-package ffap
:config
(progn
(defun my/ffap-menu-ask (&rest args)
"Used to override ffap-menu-ask and not show the *Completions* buffer.
This is recommended by Vertico's README."
(cl-letf (((symbol-function #'minibuffer-completion-help)
#'ignore))
(apply args)))
(with-eval-after-load "vertico"
(advice-add #'ffap-menu-ask :around #'my/ffap-menu-ask))))
(use-package isearch
:init
(progn
(setq isearch-allow-motion t)
(setq isearch-lazy-count t)))
(use-package casual-isearch
:demand t
:after isearch
:bind (:map isearch-mode-map ("C-o" . casual-isearch-tmenu)))
(use-package dabbrev
:bind (("M-/" . nil)
("C-M-/" . nil))
:init
(progn
(setq dabbrev-case-fold-search t)
(setq dabbrev-case-replace nil))
:config
(progn
;; recommended by corfu:
(add-to-list 'dabbrev-ignored-buffer-modes 'doc-view-mode)
(add-to-list 'dabbrev-ignored-buffer-modes 'pdf-view-mode)
(add-to-list 'dabbrev-ignored-buffer-modes 'tags-table-mode)))
(use-package diff
:bind (
:map diff-mode-map
;; This key is for changing the active window:
("M-o" . nil)))
(use-package modus-themes
:demand t
:init
(progn
(setq modus-themes-bold-constructs t)
(setq modus-themes-org-blocks 'greyscale)
(setq modus-themes-italic-constructs t)
(setq modus-themes-headings
'((1 . (1.6))
(2 . (background 1.5))
(3 . (background bold 1.2))
(4 . (1.1))
(t . ())))
(load-theme 'modus-operandi))
:config
(progn
(with-eval-after-load 'pdf-tools
;; Configure PDF page colors. The code below comes from Modus
;; Info manual (Backdrop for pdf-tools (DIY)).
(defun my/pdf-tools-backdrop (&rest _)
(modus-themes-with-colors
(face-remap-add-relative
'default
`(:background ,bg-dim))))
(add-hook 'pdf-tools-enabled-hook #'my/pdf-tools-backdrop)
;; Configure faces for combobulate that is not yet supported by
;; modus:
(modus-themes-with-colors
(custom-set-faces
`(combobulate-active-indicator-face ((,c :foreground ,fg-main)))
`(combobulate-dimmed-indicator-face ((,c :inherit shadow)))
`(combobulate-error-indicator-face ((,c :inherit error)))
`(combobulate-query-highlight-fiery-flames-face ((,c :inherit
modus-themes-intense-red)))
`(combobulate-query-highlight-gleaming-gold-face ((,c :inherit
modus-themes-intense-yellow)))
`(combobulate-query-highlight-majestic-mercury-face ((,c :inherit
modus-themes-intense-cyan)))
`(combobulate-query-highlight-mysterious-mauve-face ((,c :inherit
modus-themes-intense-magenta)))
`(combobulate-query-highlight-radiant-rind-face ((,c :inherit
modus-themes-subtle-red)))
`(combobulate-query-highlight-regal-ripples-face ((,c :inherit
modus-themes-intense-blue)))
`(combobulate-query-highlight-serene-shade-face ((,c :inherit
modus-themes-subtle-green)))
`(combobulate-query-highlight-silver-shadows-face ((,c :background ,bg-active
:foreground ,fg-main)))
`(combobulate-query-highlight-vibrant-veggie-face ((,c :inherit
modus-themes-intense-green)))
`(combobulate-query-query-anonymous-face ((,c :inherit modus-themes-bold
:foreground ,fg-alt)))
`(combobulate-query-query-builtin-face ((,c :inherit font-lock-builtin-face)))
`(combobulate-query-query-constant-face ((,c :inherit font-lock-constant-face)))
`(combobulate-query-query-doc-markup-face ((,c :inherit
font-lock-doc-markup-face)))
`(combobulate-query-query-keyword-face ((,c :inherit font-lock-keyword-face)))
`(combobulate-query-query-predicate-builtin-face ((,c :inherit bold)))
`(combobulate-query-query-string-face ((,c :inherit font-lock-string-face)))
`(combobulate-refactor-choice-face ((,c :inherit modus-themes-slant :foreground
,info)))
`(combobulate-refactor-cursor-face ((,c :foreground ,cursor)))
`(combobulate-refactor-field-face ((,c :background ,bg-inactive :foreground
,fg-main :extend nil)))
`(combobulate-refactor-highlight-face ((,c :inherit highlight)))
`(combobulate-refactor-inactive-choice-face ((,c :inherit modus-themes-slant
:foreground ,fg-dim)))
`(combobulate-refactor-inactive-field-face ((,c :background ,bg-dim :foreground
,fg-dim :extend nil)))
`(combobulate-refactor-label-face ((,c :inherit modus-themes-search-replace)))
`(combobulate-tree-branch-face ((,c :inherit shadow)))
`(combobulate-tree-highlighted-node-face ((,c :inherit success)))
`(combobulate-tree-normal-node-face ((,c :foreground ,fg-main)))
`(combobulate-tree-pulse-node-face ((,c :background ,bg-blue-intense :extend t))))))))
(use-package tramp
:config
(progn
(add-to-list 'tramp-remote-path "/run/current-system/profile/bin")))
(use-package simple
:demand t
:bind (("M-j" . my/join-line)
("C-x a" . beginning-of-buffer)
("M-<" . nil)
("C-x e" . end-of-buffer)
("M->" . nil)
([remap yank-pop] . yank-from-kill-ring)
("C-_" . nil) ;; force me to use C-/ to undo
("C-. s" . scratch-buffer)
:map process-menu-mode-map
("k" . process-menu-delete-process))
:init
(progn
(setq delete-active-region nil)
(setq eval-expression-print-length 20)
(setq eval-expression-print-level 10)
(setq next-error-message-highlight 'keep)
(setq set-mark-command-repeat-pop t)
(setq line-number-mode nil))
:config
(progn
(defun my/join-line ()
"Join current line and the next."
(interactive)
(join-line -1))
;; http://mbork.pl/2022-05-23_Copying_code_snippets
(defun my/copy-snippet-deindented (begin end)
"Copy region, untabifying and removing indentation."
(interactive "r")
(require 'org-macs)
(let ((orig-tab-width tab-width)
(region (buffer-substring-no-properties begin end)))
(with-temp-buffer
(setq tab-width orig-tab-width)
(insert region)
(untabify (point-min) (point-max))
(org-do-remove-indentation)
(kill-new (buffer-string)))))
(column-number-mode -1)
;; Hide commands in M-x which do not work in the current mode.
(setq read-extended-command-predicate
#'command-completion-default-include-p)))
(use-package replace
:bind (
:map occur-mode-map
("C-x C-q" . occur-edit-mode)))
(use-package so-long
:demand t
:config
(progn
(global-so-long-mode)))
(use-package server
:init
(progn
(setq server-client-instructions nil))
:config
(progn
(unless (or (daemonp) (server-running-p))
(server-start))))
(use-package elisp-mode
:hook ((emacs-lisp-mode . my/elisp-mode-reduce-mode-name)
(emacs-lisp-mode . my/eldoc-shows-more-information))
:config
(progn
(defun my/elisp-mode-reduce-mode-name ()
(setq-local mode-name "Elisp"))
(defun my/eldoc-shows-more-information ()
(remove-hook 'eldoc-documentation-functions #'elisp-eldoc-var-docstring t)
(add-hook 'eldoc-documentation-functions #'elisp-eldoc-var-docstring-with-value nil t))))
(use-package minibuffer
:bind (("M-/" . completion-at-point))
:init
(progn
(setq read-file-name-completion-ignore-case t)
(setq completions-detailed t))
:config
(progn
(dolist (regexp '("File .* removed from the recentf list"))
(add-to-list 'inhibit-message-regexps regexp nil #'string=))
(add-to-list 'set-message-functions #'set-multi-message)
(add-to-list 'set-message-functions #'inhibit-message)))
(use-package saveplace
:demand t
:config
(progn
(save-place-mode)))
(use-package tooltip
:config
(progn
;; Use echo area for help texts instead of a pop-up window:
(tooltip-mode -1)))
(use-package winner
:demand t
:config
(progn
(winner-mode)))
(use-package apropos
:hook (apropos-mode . outline-minor-mode))
(use-package buffer-mode
:bind (("C-S-<up>" . buf-move-up)
("C-S-<down>" . buf-move-down)
("C-S-<left>" . buf-move-left)
("C-S-<right>" . buf-move-right)))
(use-package time
:init
(progn
(setq display-time-24hr-format t)))
(use-package nsm ;; network security
:init
(progn
(setq network-security-level 'high)
(setq nsm-save-host-names t)))
(use-package imenu
:init
(progn
(setq imenu-auto-rescan t)
(setq imenu-max-item-length 200)))
(use-package url-vars
:init
(progn
(setq url-privacy-level 'high)))
(use-package autorevert
:demand t
;; Activate auto-revert for dired buffers which are not included in
;; `global-auto-revert-mode':
:hook (dired-mode . auto-revert-mode)
:init
(progn
;; Don't show messages when auto revert happens:
(setq auto-revert-verbose nil))
:config
(progn
(global-auto-revert-mode)))
(use-package package
:after package-lint
:config
(progn
;; the following is useful for package-lint
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/"))
(package-initialize)
(unless (file-directory-p package-user-dir)
;; only contact elpa repositories if we don't have anything yet
(package-refresh-contents))))
(use-package proced
:init
(progn
(setq proced-filter 'all)
(setq proced-enable-color-flag t)))
(use-package emacsbug
:init
(progn
(setq report-emacs-bug-no-explanations t)))
(use-package debbugs-gnu
:init
(progn
(setq debbugs-gnu-trunk-directory "~/Documents/projects/emacs/emacs-src-26")))
(use-package goto-addr
:bind (
:map goto-address-highlight-keymap
("C-c C-o" . goto-address-at-point))
:hook (((prog-mode magit-process-mode) . goto-address-mode))
:config
(progn
;; Recommended by modus-themes (2.7.0 release notes):
(setq goto-address-mail-face 'link)
(setq goto-address-mail-mouse-face 'highlight)))
(use-package bug-reference
:bind ((
:map bug-reference-map
("C-c C-o" . bug-reference-push-button))))
(use-package info
:bind (
:map Info-mode-map
("C-c C-o" . Info-follow-nearest-node)))
(use-package man
:init
(progn
(setq Man-notify-method 'aggressive)))
(use-package info-variable-pitch
:hook ((Info-mode . info-variable-pitch-mode)))
(use-package olivetti
:hook (((Info-mode help-mode helpful-mode eww-mode) . olivetti-mode))
:init
(progn
(setq olivetti-body-width 84)))
(use-package smime
:config
;; https://src.fedoraproject.org/rpms/emacs/blob/f27/f/default.el
(setq smime-CA-directory "/etc/ssl/certs"))
(use-package display-line-numbers
:hook ((prog-mode text-mode) . my/display-line-numbers)
:config
(progn
(defun my/display-line-numbers ()
(when buffer-file-name
(display-line-numbers-mode)))))
(use-package hl-line
:demand t
:config
(progn
(global-hl-line-mode)))
(use-package lin
:demand t
:after hl-line
:config
(progn
(lin-global-mode)))
(use-package vundo
:bind ("C-x u" . vundo)
:hook ((vundo-mode . my/vundo-setup))
:init
(progn
(setq vundo-window-max-height 5))
:config
(progn
(setq vundo-glyph-alist vundo-unicode-symbols)
(defun my/vundo-setup ()
"Remove mode-line and header-line."
(setq mode-line-format nil)
(setq header-line-format nil))))
(use-package ibuffer
:bind (
:map ibuffer-mode-map
("k". ibuffer-do-my/ibuffer-do-kill-marked))
:config
(progn
(define-ibuffer-op my/ibuffer-do-kill-marked ()
"Kill marked buffers as with `kill-this-buffer'."
(:opstring "killed"
:active-opstring "kill"
:dangerous t
:complex t
:modifier-p t)
(if (kill-buffer buf)
'kill
nil))))
(use-package dired
:bind (
:map dired-mode-map
("C-a" . my/dired-move-beginning-of-line)
("k" . dired-do-delete)
("D" . nil))
:hook (dired-mode . dired-hide-details-mode)
:init
(progn
(setq dired-auto-revert-buffer t)
(setq dired-dwim-target t)
(setq dired-listing-switches "-alh")
(setq dired-recursive-deletes 'always)
(setq dired-mouse-drag-files t)
(defun my/dired-move-beginning-of-line ()
(interactive)
(let ((point (point)))
(dired-move-to-filename)
(when (= point (point))
(move-beginning-of-line nil))))))
(use-package casual-dired
:after dired
:bind (
:map dired-mode-map
("?" . casual-dired-tmenu)
("s" . casual-dired-sort-by-tmenu)))
(use-package casual-re-builder
:after re-builder
:bind (:map
reb-mode-map ("C-o" . casual-re-builder-tmenu)
:map
reb-lisp-mode-map ("C-o" . casual-re-builder-tmenu)))
(use-package all-the-icons-dired
:hook (dired-mode . all-the-icons-dired-mode))
(use-package gnus-dired
:hook (dired-mode . turn-on-gnus-dired-mode))
(use-package runner
:demand t
:after dired
:init
(progn
(setq runner-run-in-background t)))
(use-package dired-x
:after dired
:bind (:map dired-mode-map
(")" . dired-omit-mode))
:hook (dired-mode . dired-omit-mode)
:init
(progn
(setq dired-omit-verbose nil))
:config
(progn
(setq dired-omit-files (rx-to-string `(or (and bol ".tern-port" eol)
(regexp ,dired-omit-files))))))
(use-package dired-imenu
:demand t
:after dired)
(use-package dired-rsync
:config
(progn
(defun my/dired-rsync-update-modeline (&optional err ind)
(let ((job-count (length (dired-rsync--get-active-buffers))))
(cond
;; error has occurred
(err (alert (format "%d job failed: %s" job-count err)
:severity 'urgent
:title "dired-rsync"))
((zerop job-count) (alert "done"
:severity 'normal
:title "dired-rsync")))))
(advice-add #'dired-rsync--update-modeline :after #'my/dired-rsync-update-modeline)))
(use-package recentf
:demand t
:init
(progn
(setq recentf-auto-cleanup 300)
(setq recentf-exclude '("~$" "\\.log$"))
(setq recentf-max-saved-items 1000)
;; recommended by consult in `consult--source-recent-file':
(setq recentf-filename-handlers nil))
:config
(progn
(recentf-mode)))
(use-package magit
:bind ((
:map magit-mode-map
("M-w" . magit-copy-section-value)))
:init
(progn
(setq magit-show-long-lines-warning nil)
(setq magit-diff-refine-hunk t)
(setq magit-branch-prefer-remote-upstream '("master"))
(setq magit-branch-adjust-remote-upstream-alist '(("origin/master" "master")
("origin/main" "main")))
(setq magit-module-sections-nested nil)
(setq magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1)
(setq magit-no-confirm '(amend-published trash delete-unmerged-branch))
(setq magit-revision-insert-related-refs nil)
(setq magit-revision-show-gravatars t)
(setq magit-clone-set-remote.pushDefault t))
:config
(progn
;; Enable magit-clean
(put 'magit-clean 'disabled nil)
;; Add modules in magit status buffer:
(magit-add-section-hook 'magit-status-sections-hook
'magit-insert-modules
'magit-insert-unpulled-from-upstream)
;; Only show the module sections I'm interested in
(with-eval-after-load "magit-submodule"
(remove-hook 'magit-module-sections-hook 'magit-insert-modules-overview)
(remove-hook 'magit-module-sections-hook 'magit-insert-modules-unpulled-from-pushremote)
(remove-hook 'magit-module-sections-hook 'magit-insert-modules-unpushed-to-upstream)
(remove-hook 'magit-module-sections-hook 'magit-insert-modules-unpushed-to-pushremote))
(transient-replace-suffix 'magit-commit 'magit-commit-autofixup
'("x" "Absorb changes" magit-commit-absorb))
(dir-locals-set-class-variables 'my/magit-huge-git-repository
'((magit-status-mode
.
((eval . (magit-disable-section-inserter 'magit-insert-tags-header))
(eval . (magit-disable-section-inserter 'magit-insert-untracked-files))
(eval . (magit-disable-section-inserter 'magit-insert-modules))))))
(let ((huge-repos
'("~/Documents/projects/nix/nixpkgs-master"
"~/Documents/projects/nix-system/nixpkgs/")))
(dolist (repo huge-repos)
(dir-locals-set-directory-class
(expand-file-name repo)
'my/magit-huge-git-repository)))))
(use-package magit-diff
:bind (
:map magit-diff-section-map
;; disable binding that I use for begining of buffer
("C-x a" . nil)))
(use-package magit-extras
:demand (project magit))
(use-package magit-tbdiff
:demand t
:after magit)
(use-package forge
:demand t
:after magit
:hook (forge-post-submit-callback . my/forge-start-timer-for-draft-pullreq)
:config
(progn
(setq-default forge-buffer-draft-p t)
(defun my/forge-start-timer-for-draft-pullreq (pullreq &rest _)
"Start a `tmr' timer if PULLREQ is draft."
(when (map-elt pullreq 'draft)
(when-let* ((url (map-elt pullreq 'url))
(minutes (cond
((string-match-p "foretagsplatsen/monitor" url) 15)
((string-match-p "foretagsplatsen/frontend" url) 20)
(t 10))))
(require 'tmr)
(tmr minutes (format "Check draft %s" url) t))))))
(use-package forge-topic
:init
(progn
(setq forge-topic-list-limit '(60 . -1))))
(use-package vc-hooks
:init
(progn
(setq vc-follow-symlinks nil)))
(use-package ediff-wind
:init
(progn
(setq ediff-split-window-function 'split-window-horizontally)
(setq ediff-window-setup-function 'ediff-setup-windows-plain)))
(use-package jinx
:hook ((emacs-startup . global-jinx-mode)
(jinx-mode . my/jinx-add-ispell-localwords))
:bind ([remap ispell-word] . jinx-correct)
:init
(progn
(setq jinx-languages "en_US fr_FR"))
:config
(progn
(add-to-list 'jinx-include-faces
(list 'ledger-mode 'ledger-font-comment-face))
(add-to-list 'jinx-include-faces
(list 'js2-mode 'js2-jsdoc-value 'js2-jsdoc-type))
;; https://github.com/minad/jinx/wiki
(defun my/jinx-ispell-localwords ()
"Return a string of ispell's local words.
Those are the words following `ispell-words-keyword' (usually
\"LocalWords\") in the current buffer."
(require 'ispell)
(save-excursion
(goto-char (point-min))
(cl-loop while (search-forward ispell-words-keyword nil t)
collect (string-trim (buffer-substring-no-properties (point) (line-end-position))) into result
finally return (mapconcat #'identity result " "))))
;; https://github.com/minad/jinx/wiki
(defun my/jinx-add-ispell-localwords ()
"Add ispell's local words to `jinx-local-words'."
(let ((ispell-localwords (my/jinx-ispell-localwords)))
(setq jinx-local-words (concat jinx-local-words ispell-localwords))
(setq jinx--session-words (append jinx--session-words (split-string ispell-localwords)))))
;; https://github.com/minad/jinx/wiki
(defun my/jinx-save-as-ispell-localword (save key word)
"Save WORD using ispell's `ispell-words-keyword'.
If SAVE is non-nil save, otherwise format candidate given action KEY."
(if save
(progn
(require 'ispell)
(ispell-add-per-file-word-list word)
(add-to-list 'jinx--session-words word)
(setq jinx-local-words
(string-join
(sort (delete-dups
(cons word (split-string jinx-local-words)))
#'string<)
" ")))
(list key word "File")))
(require 'map)
(map-put! jinx--save-keys ?* #'my/jinx-save-as-ispell-localword)))
(use-package eldoc
:init
(progn
;; https://www.masteringemacs.org/article/seamlessly-merge-multiple-documentation-sources-eldoc
(add-to-list 'display-buffer-alist
'("^\\*eldoc for" display-buffer-at-bottom
(window-height . 4)))
(setq eldoc-documentation-strategy 'eldoc-documentation-compose-eagerly))
:config
(progn
;; https://www.masteringemacs.org/article/seamlessly-merge-multiple-documentation-sources-eldoc
(eldoc-add-command-completions "paredit-")
(eldoc-add-command-completions "combobulate-")))
(use-package flymake
:bind (
;; Use the same bindings as flycheck:
:map flymake-mode-map
("C-c ! n" . flymake-goto-next-error)
("C-c ! p" . flymake-goto-prev-error)
("C-c ! l" . flymake-show-buffer-diagnostics)
("C-c ! v" . flymake-switch-to-log-buffer))
:init
(progn
(defun my/flymake-modeline ()
"Compute a modeline format containing flymake's current status."
(let* ((running-backends (flymake-running-backends))
(reporting-backends (flymake-reporting-backends))
(computing-backends (cl-set-difference running-backends reporting-backends)))
(cond
((zerop (hash-table-count flymake--state)) "(?)")
(computing-backends "(Wait)")
((and (flymake-disabled-backends) (null running-backends)) "(Disabled)")
(t (if (flymake-diagnostics)
(list "("
flymake-mode-line-error-counter
flymake-mode-line-warning-counter
flymake-mode-line-note-counter
")")
"")))))
(setq flymake-suppress-zero-counters t)
(setq flymake-mode-line-format '(:eval (my/flymake-modeline)))))
(use-package flymake-proc
:config
(progn
;; flymake-proc adds this legacy backend automatically but (1) I
;; don't seem to use it and (2) it triggers warnings in *Flymake
;; log*.
(remove-hook 'flymake-diagnostic-functions #'flymake-proc-legacy-flymake)))
(use-package ledger-mode
:hook (ledger-mode . my/configure-ledger-mode)
:mode "\\.hledger\\'"
:bind (
:map ledger-mode-map
("C-c C-r" . ledger-report)
("C-c C-c" . my/ledger-lint)
("M-q" . my/ledger-reindent)
;; To get outline-minor-mode in ledger buffers:
("TAB" . org-cycle)
:map ledger-report-mode-map
("C-c C-r" . ledger-report))
:init
(progn
(setq ledger-reports
(mapcar
(lambda (pair)
(list (car pair)
(format "%s %s"
"%(binary) -f %(ledger-file)"
(cdr pair))))
'(("Account statement" . "register --ignore-assertions --auto ^%(account)")
("Income statement" . "balance --ignore-assertions --auto --tree --period %(month) --invert ^income ^expense")
("Balance sheet" . "balance --ignore-assertions --auto --tree ^asset ^debt \"^equity:\"")
("Budget" . "balance --ignore-assertions --auto --tree --empty ^budget not:unbudgeted"))))
;; For hledger
(progn