-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.el
More file actions
1674 lines (1485 loc) · 56.8 KB
/
Copy pathinit.el
File metadata and controls
1674 lines (1485 loc) · 56.8 KB
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
;; Initialize package sources
(use-package package
:ensure nil
:config
(setq use-package-always-ensure nil)
(setq package-install-upgrade-built-in nil)
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
("non-gnu" . "https://elpa.nongnu.org/nongnu/")
("elpa" . "https://elpa.gnu.org/packages/")))
(setq package-archive-priorities
'(("gnu-elpa" . 3)
("nongnu" . 2)
("melpa" . 1)))
; check package-review-policy only if this variable exists (available only after emacs 31)
(when (boundp 'package-review-policy)
(setq package-review-policy nil ; very manual at this point (needs automation)
package-review-diff-command '("git" "diff" "--no-index"
"--color=never"
"--diff-filter=d")))
;; Initialize all packages after package.el is loaded
(package-initialize)
(unless package-archive-contents
(package-refresh-contents)))
;;; Some standard emacs config
(use-package emacs
:ensure nil
:demand t
:init
;; Remove visible bell
(setq visible-bell nil
ring-bell-function #'ignore)
;; Enable imenu support for use-package declarations
(setopt use-package-enable-imenu-support t)
(setq mode-line-right-align-edge 'right-margin)
;; Buffer list configuration
(setq display-buffer-alist
'(
;; Python buffers now occupy 25% of the screen
("\\*Python\\*"
(display-buffer-reuse-window
display-buffer-at-bottom)
(dedicated . t)
(window-height . 0.25))
;; Silence byte compile warnings when installing new packages
("\\`\\*\\(Warnings\\|Compile-Log\\)\\*\\'"
(display-buffer-no-window)
(allow-no-window . t))
;; Compilation mode buffers occupy small fraction of the screen
((derived-mode . compilation-mode)
(display-buffer-reuse-window
display-buffer-at-bottom)
(dedicated . t)
(window-height . 0.15))
;; Typst ts compilation mode settings
((derived-mode . typst-ts-compilation-mode)
(display-buffer-reuse-mode-window
display-buffer-pop-up-window)
(window-height . fit-window-to-buffer))
;; help-mode settings
((derived-mode . help-mode)
(display-buffer-reuse-mode-window
display-buffer-pop-up-window)
(window-height . (lambda (window)
(fit-window-to-buffer window (floor (* 0.5 (frame-height)))))))
;; ibuffer settings
((derived-mode . Buffer-menu-mode)
(display-buffer-reuse-mode-window
display-buffer-pop-up-window)
(body-function . (lambda (window) (select-window window)))
(window-height . (lambda (window)
(fit-window-to-buffer window (floor (* 0.5 (frame-height)))))))
;; Eldoc specific settings
("\\*eldoc\\*"
(display-buffer-reuse-mode-window
display-buffer-pop-up-window)
(window-height . fit-window-to-buffer))
;; xref buffer specific settings
("\\*xref\\*"
(display-buffer-reuse-mode-window
display-buffer-pop-up-window)
(window-height . fit-window-to-buffer))
;; Occur specific buffer settings
("\\*Occur\\*"
;; If a buffer with the matching major-mode exists in
;; some window, then use that one. Otherwise, display
;; the buffer below the current window.
(display-buffer-reuse-mode-window
display-buffer-pop-up-window)
;; Then we have some parameters
(dedicated . t)
(body-function . (lambda (window) (select-window window)))
(window-width . 0.5)
(window-height . (lambda (window)
(fit-window-to-buffer window (floor (* 0.65 (frame-height)))))))))
;; Fonts
(set-face-attribute 'default nil :font "Hack" :height 115)
(set-face-attribute 'fixed-pitch nil :font "Hack" :height 1.0)
(set-face-attribute 'variable-pitch nil :font "Iosevka Term" :height 1.05)
;; Personal details
(setopt user-full-name "Ashish Panigrahi")
(setopt user-mail-address "public@ashishpanigrahi.com")
;; Always load newest byte code
(setopt load-prefer-newer t)
;; Display load message when starting emacs
(defun efs/display-startup-time ()
(message "Emacs loaded in %s with %d garbage collections."
(format "%.3f seconds"
(float-time
(time-subtract after-init-time before-init-time)))
gcs-done))
(add-hook 'emacs-startup-hook #'efs/display-startup-time)
;; Stolen from Protesilaos' config + my own for consult-focus-lines quitting
(defun pani/keyboard-quit-dwim ()
"Do-What-I-Mean behaviour for a general `keyboard-quit'.
The generic `keyboard-quit' does not do the expected thing when
the minibuffer is open. Whereas we want it to close the
minibuffer, even without explicitly focusing it.
The DWIM behaviour of this command is as follows:
- When the region is active, disable it.
- When a minibuffer is open, but not focused, close the minibuffer.
- When the Completions buffer is selected, close it.
- When lines are hidden with `consult-focus-lines', reveal them.
- In every other case use the regular `keyboard-quit'."
(interactive)
(cond
((region-active-p)
(keyboard-quit))
((derived-mode-p 'completion-list-mode)
(delete-completion-window))
((> (minibuffer-depth) 0)
(abort-recursive-edit))
((and (boundp 'consult--focus-lines-overlays)
consult--focus-lines-overlays)
(consult-focus-lines nil t))
(t
(keyboard-quit))))
:bind
("C-g" . pani/keyboard-quit-dwim)
:config
(setq kill-do-not-save-duplicates t)
(setq echo-keystrokes-help nil) ; Emacs 30
(setq tab-always-indent 'complete) ; tab for completion and not indenting
(setq auto-save-timeout nil)
(setq help-window-select t) ; Cursor focus goes to help window when invoked
(setq help-window-keep-selected t) ; Keep using the same window for more help buffers
(setq compilation-scroll-output t) ; scroll compilation buffer as output appears
(column-number-mode 1)
(global-visual-wrap-prefix-mode 1)
;; Have prose modes auto wrap long lines
(dolist (hook '(org-mode-hook markdown-mode-hook markdown-ts-mode-hook LaTeX-mode-hook))
(add-hook hook #'auto-fill-mode))
;; Deletes trailing whitespace upon saving a file
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;; Vim like scrolling
(setq scroll-step 1
scroll-conservatively 10000
next-screen-context-lines 5
;; move by logical lines rather than visual lines (better for macros)
line-move-visual nil)
;; Disable line numbers for some text modes
(dolist (mode '(eat-mode-hook
shell-mode-hook
dired-mode-hook
woman-mode-hook
Info-mode-hook
Man-mode-hook
eshell-mode-hook))
(add-hook mode (lambda () (display-line-numbers-mode -1))))
;; Disable certain emacs features
(mapc
(lambda (command)
(put command 'disabled t))
'(overwrite-mode iconify-frame diary))
;; Hide minor modes in the modeline
(when (boundp 'mode-line-collapse-minor-modes)
(setq mode-line-collapse-minor-modes t))
;; No ugly buttons for checkboxes
(setq widget-image-enable nil)
;; Do not use graphical dialogs
(setq use-dialog-box nil)
;; Disable tooltips
(tooltip-mode -1)
;; Disable remote file locks
(setq remote-file-name-inhibit-locks t)
;; Put autosave files in one folder
(setq backup-directory-alist `(("." . "~/.autosaves")))
(setq backup-inhibited t)
(setq auto-save-default nil)
;; Replace "yes or no" with "y or n"
(setq use-short-answers t)
;; ;; Enable `completion-preview-mode' for certain hooks
;; :hook (python-mode . completion-preview-mode)
(setq display-line-numbers-type 'relative)
;; Disable bidirectional text scanning
(setq-default bidi-display-reordering 'left-to-right
bidi-paragraph-direction 'left-to-right)
(setq bidi-inhibit-bpa t)
;; Skip fontification during input
(setq redisplay-skip-fontification-on-input t)
;; Increase process output buffer for LSP
;; Basically free performance with eglot
(setq read-process-output-max (* 4 1024 1024)) ; 4 MB
;; Prevent ffap from pinging hostnames
(setq ffap-machine-p-known 'reject)
;; Proportional window resizing (becomes apparent with multiple windows
(setq window-combination-resize t)
;; Enable line numbers only for programming and text modes
(add-hook 'prog-mode-hook #'display-line-numbers-mode)
(add-hook 'text-mode-hook #'display-line-numbers-mode)
(add-hook 'conf-mode-hook #'display-line-numbers-mode)
;; Specify line-spacing (in pixels)
(setq line-spacing nil) ;; `nil' is default value
(setq tab-bar-show 1) ; turns off `tab-bar-mode' when only 1 tab is present.
(setq tab-bar-close-button-show nil) ; removes 'x' button from the tabs.
(setq tab-bar-new-button-show nil) ; removes '+' button for new tab.
;; Specify gpg executable
(setq epg-gpg-program "gpg2")
;; ;; Do gpg pin entry from Emacs
;; (setenv "GPG_AGENT_INFO" nil)
;; Set regexp syntax to `string'
;; `read' is default but is plagued with requiring many backslashes
(setq reb-re-syntax 'string)
;; Auto-chmod scripts on save
(add-hook 'after-save-hook
#'executable-make-buffer-file-executable-if-script-p)
:bind
( :map global-map
("C-x C-d" . nil) ; never use it
("C-x C-z" . nil) ; never use it
("C-x C-c" . nil) ; avoid accidentally exiting Emacs
("C-h h" . nil) ; never show that "hello" file
("C-l" . nil) ; never use it
("C-k" . nil) ; never use it
("C-x <left>" . nil) ; unbind the `previous-buffer' command
("C-x C-p" . mode-line-other-buffer) ; switches between two buffers
)
:config
;; disable Ispell completion function
(setq text-mode-ispell-word-completion nil)
;; Hide commands in M-x which do not work in current buffer
(setq read-extended-command-predicate
#'command-completion-default-include-p))
(use-package shr
:ensure nil
:config
(setq shr-use-colors nil)
(setq shr-ignore-cache t)
;; Disable html font size overriding default fonts
(setq shr-use-fonts nil))
;;; Vim Bindings
(use-package evil
:ensure t
:demand t
:bind (:map global-map
("<escape>" . keyboard-escape-quit))
:init
;; allows for using cgn
(setq evil-search-module 'isearch)
(setq evil-want-integration t)
(setq evil-want-keybinding nil)
(setq evil-want-C-u-scroll t)
(setq evil-want-C-i-jump nil)
(setq evil-want-Y-yank-to-eol t) ;; yanks to end of line instead of whole line
;; no vim insert bindings
(setq evil-undo-system 'undo-fu)
:config
(evil-mode 1)
(define-key evil-insert-state-map (kbd "C-g") 'evil-normal-state)
(define-key evil-insert-state-map (kbd "C-h") 'evil-delete-backward-char-and-join)
(define-key evil-motion-state-map (kbd "C-u") 'evil-scroll-up) ; explicitly bind C-u
(define-key evil-motion-state-map (kbd "C-o") 'occur) ; `occur' now bound to C-o
(define-key evil-motion-state-map (kbd "C-q") 'query-replace) ; `query-replace' now bound to C-q
;; Use visual line motions even outside of visual-line-mode buffers
(evil-global-set-key 'motion "j" 'evil-next-visual-line)
(evil-global-set-key 'motion "k" 'evil-previous-visual-line)
;; Setting leader key in emacs
(evil-set-leader 'normal (kbd "SPC"))
(evil-define-key nil 'global
(kbd "<leader>b") 'consult-buffer)
(evil-define-key nil 'global
(kbd "<leader>v") 'consult-project-buffer)
;; Set `t' as a prefix key for tab manipulation commands
(define-prefix-command 'pani/t-key)
(define-key evil-normal-state-map (kbd "t") 'pani/t-key)
(define-key pani/t-key (kbd "j") 'tab-previous)
(define-key pani/t-key (kbd "k") 'tab-next)
(define-key pani/t-key (kbd "n") 'tab-new)
(define-key pani/t-key (kbd "x") 'tab-close)
(define-key pani/t-key (kbd "X") 'tab-close-other)
(evil-set-initial-state 'messages-buffer-mode 'normal)
(evil-set-initial-state 'dashboard-mode 'normal)
(evil-set-initial-state 'inferior-python-mode 'emacs))
;;; Vim Bindings Everywhere else
(use-package evil-collection
:vc (:url "https://github.com/emacs-evil/evil-collection"
:rev :newest)
:after evil
:config
(setq evil-want-integration t)
(evil-collection-init)
;; Vim-commentary without any extra package
(with-eval-after-load "evil"
(evil-define-operator my-evil-comment-or-uncomment (beg end)
"Toggle comment for the region between BEG and END."
(interactive "<r>")
(comment-or-uncomment-region beg end))
(evil-define-key 'normal 'global (kbd "gc") 'my-evil-comment-or-uncomment)))
;; Some useful config for emacs-lisp
(use-package emacs-lisp-mode
:ensure nil
:bind (:map emacs-lisp-mode-map
("C-c C-r" . eval-region)
("C-c C-b" . eval-buffer)))
(use-package undo-fu
:ensure t
:demand t
:commands (undo-fu-only-undo
undo-fu-only-redo
undo-fu-only-redo-all
undo-fu-disable-checkpoint)
:config
;; 3 times the default values
(setq undo-limit (* 3 160000))
(setq undo-strong-limit (* 3 240000)))
;; Protesilaos' ef-themes
(use-package ef-themes
:vc (:url "https://github.com/protesilaos/ef-themes"
:rev :newest)
:init
(ef-themes-take-over-modus-themes-mode 1)
:config
;; They are nil by default...
(setq modus-themes-mixed-fonts t
modus-themes-italic-constructs t
modus-themes-bold-constructs t
modus-themes-variable-pitch-ui t)
;; Sets line number color back to white
(setq modus-themes-common-palette-overrides
'((fg-line-number-active fg-main)))
;; Minibuffer completions are bold by default. This fixes it.
(setq modus-themes-completions
'((selection regular)))
(setq modus-themes-headings ; read the manual's entry or the doc string
'((0 variable-pitch regular 1.5)
(1 variable-pitch regular 1.5)
(2 variable-pitch regular 1.25)
(3 variable-pitch regular 1.25)
(4 variable-pitch regular 1.25)
(5 variable-pitch 1.2) ; absence of weight means `bold'
(6 variable-pitch 1.2)
(7 variable-pitch 1.1)
(agenda-date variable-pitch 1.1)
(agenda-structure variable-pitch light 1.4)
(t variable-pitch 1.1)))
;; Disable all other themes to avoid awkward blending:
(mapc #'disable-theme custom-enabled-themes)
(load-theme 'ef-symbiosis :no-confirm)
(set-face-attribute 'minibuffer-prompt nil :weight 'normal))
;;; Vertico
(use-package vertico
:ensure t
:init
(vertico-mode)
:bind (:map minibuffer-local-map
("C-j" . vertico-next)
("C-k" . vertico-previous)
("C-l" . next-history-element)
("C-h" . previous-history-element))
:config
(setq vertico-resize nil
vertico-count 8
vertico-cycle t)
;; Fix font for vertico group title
(set-face-attribute 'vertico-group-title nil
:height 1.0
:slant 'normal
:weight 'bold)
;; This removes the shadowed-out region when finding file from an
;; already arrived directory
(add-hook 'rfn-eshadow-update-overlay-hook #'vertico-directory-tidy))
;; Which-key (to show available commands when typing a prefix say 'C-c')
(use-package which-key
:ensure nil ; built-in
:config
(which-key-mode)
(setq which-key-idle-delay 1))
;; Orgmode specific settings
(use-package org
:ensure nil ; org is built-in
:defer t
:init
(setq org-directory (expand-file-name "~/org/"))
(setq org-imenu-depth 7)
:hook (org-mode . auto-revert-mode)
:bind (:map global-map
("C-c a" . org-agenda)
("C-c c" . org-capture)
:map org-mode-map
("C-x a" . org-archive-subtree-default)
("C-x i" . org-toggle-inline-images)
("C-c C-j" . nil)) ;; I don't use `org-goto'
:config
;; Set default pdf-viewer in org-mode
(add-to-list 'org-file-apps '("\\.pdf\\'" . "firefox \"%s\""))
(setq org-log-done 'time)
;; Collapse the log entries into a "drawer"
(setq org-log-into-drawer t)
(setq org-todo-keywords
'((sequence "TODO(t)" "PROG(p)" "WAIT(w)" "|" "DONE(d)" "CANCELLED(c)")))
;; org-indent-mode turned on by default
(setq org-startup-indented t)
;; Only show content and keep rest folded
(setq org-startup-folded 'content)
;; Emacs identifies sentences with a single space after fullstop.
(setq sentence-end-double-space nil)
;; Start calendar week from Monday
(setq calendar-week-start-day 1)
;; Unhides leading stars (default behaviour)
(setq org-hide-leading-stars nil)
;; Turn on cdlatex minor mode in all org buffers
;; See https://orgmode.org/manual/CDLaTeX-mode.html for details
(add-hook 'org-mode-hook #'turn-on-org-cdlatex)
;; Set renderer for LaTeX preview in orgmode
(setq org-preview-latex-default-process 'imagemagick)
;; Faces for TODO keywords
(setq org-todo-keyword-faces
'(("PROG" . (:foreground "orange" :weight bold))
("TODO" . (:foreground "#EA4E34" :weight bold))
("WAIT" . (:foreground "#ff64bf" :weight bold))
("CANCELLED" . (:foreground "#B50741" :weight bold))))
;; Block parent TODO to DONE if children are undone
(setq org-enforce-todo-dependencies t)
;; Hide markup elements (default behaviour is to show)
(setq org-hide-emphasis-markers t)
;; Add syntax highlighting for org documents
;; Also add native <Tab> behaviour in codeblocks
(setq org-src-fontify-natively t
org-src-tab-acts-natively t)
;; Org styling
(setq org-pretty-entities nil
org-ellipsis "…"
org-auto-align-tags t)
;; Org-indent settings
(setq org-adapt-indentation nil)
(setq org-indent-mode-turns-on-hiding-stars nil)
(setq org-indent-indentation-per-level 4)
;; Org-babel settings
(org-babel-do-load-languages
'org-babel-load-languages
'((python . t)
(emacs-lisp . t)))
;; List points now use a unicode bullet symbol instead of a generic
;; dash or asterisk
(font-lock-add-keywords 'org-mode
'(("^ *\\([-]\\) "
(0 (prog1 () (compose-region
(match-beginning 1)
(match-end 1) "•"))))))
;; Function to open a zotero link inside zotero as a pdf viewer
(defun org-zotero-open-link (path _)
(call-process "xdg-open" nil nil nil (concat "zotero:" path)))
(org-link-set-parameters "zotero" :follow #'org-zotero-open-link))
;; Org-agenda customization (based on Protesilaos Stavrou's config)
(use-package org-agenda
:ensure nil
:hook (org-agenda-mode . pani/org-agenda-font-size)
;; Don't need to go through org-agenda template for custom agenda
:bind (:map global-map
("C-c j" . pani/custom-org-agenda))
:config
;; Custom function to resize fonts in org-agenda
(defun pani/org-agenda-font-size ()
"Render org-agenda in variable-pitch at ~1.17x the global default height.
Uses a single `face-remap-set-base' so it overwrites rather than stacks,
keeping the size stable across `g'/`org-agenda-redo'."
(let ((global-height (face-attribute 'default :height nil 'default)))
(face-remap-set-base 'default
(list :inherit 'variable-pitch
:height (round (* global-height 1.17))))))
;; Basic agenda setup
(setq org-agenda-custom-commands
'(
("j" "Daily agenda and top priority tasks"
((todo "PROG"
((org-agenda-overriding-header "Tasks in progress")))
(agenda ""
((org-agenda-block-separator nil)
(org-agenda-span 1)
(org-deadline-warning-days 0)
(org-scheduled-past-days 0)
;; We don't need the `org-agenda-date-today'
;; highlight because that only has a practical
;; utility in multi-day views.
(org-agenda-day-face-function (lambda (date) 'org-agenda-date))
(org-agenda-format-date "%A, %-e %B %Y")
(org-agenda-overriding-header "\nDaily agenda")))
(agenda "" ((org-agenda-start-on-weekday nil)
(org-agenda-start-day "+1d")
(org-agenda-format-date "%A, %-e %B %Y")
(org-agenda-span 3)
(org-deadline-warning-days 0)
(org-agenda-block-separator nil)
(org-agenda-skip-function
'(org-agenda-skip-entry-if 'todo 'done))
(org-agenda-overriding-header "\nNext three days")))
(agenda "" ((org-agenda-time-grid nil)
(org-agenda-start-on-weekday nil)
(org-agenda-format-date "%A, %-e %B %Y")
;; We don't want to replicate the previous
;; section's three days, so we start counting
;; from the day after.
(org-agenda-start-day "+4d")
(org-agenda-span 14)
(org-agenda-show-all-dates nil)
(org-deadline-warning-days 0)
(org-agenda-block-separator nil)
(org-agenda-entry-types '(:deadline))
(org-agenda-skip-function
'(org-agenda-skip-entry-if 'todo 'done))
(org-agenda-overriding-header "\nUpcoming deadlines (+14d)")))
(agenda "" ((org-agenda-start-on-weekday nil)
(org-agenda-format-date "%A, %-e %B %Y")
(org-agenda-start-day "+4d")
(org-agenda-span 14)
(org-agenda-show-all-dates nil)
(org-deadline-warning-days 0)
(org-agenda-block-separator nil)
(org-agenda-entry-types '(:scheduled :timestamp))
(org-agenda-skip-function
'(org-agenda-skip-entry-if 'todo 'done))
(org-agenda-overriding-header "\nUpcoming schedule (+14d)")))))
))
(defun pani/custom-org-agenda ()
"Custom function to immediately jump to my custom org-agenda view."
(interactive)
(org-agenda nil "j"))
;; Setting org-agenda file
;; Eliminates the need for putting org-agenda file to the top everytime
(setq org-agenda-files
'("agenda.org"
"tasks.org"
"meetings.org"
"events.org"
"personal.org"
"birthdays.org"))
;; Sets TODO items to not have a prefix at the left hand side of the
;; org-agenda window (typically the filename where the TODO item was created).
(setq org-agenda-prefix-format
'((agenda . " %i %-12:c%?-12t% s")
(todo . " ")
(tags . " %i %-12:c")
(search . " %i %-12:c")))
;; Provides good color contrast for custom org-agenda
(custom-set-faces
'(org-agenda-date ((t (:foreground "#dc8add" :weight normal))))
'(org-agenda-date-weekend ((t (:weight normal))))
'(org-scheduled-today ((t (:foreground "#8997b3"))))
'(org-scheduled-previously ((t (:weight normal))))
'(org-deadline-today ((t (:weight normal))))
'(org-tag ((t (:foreground "#56b6c2" :weight light))))
)
;; Hides DONE items in org-agenda for schedules and deadlines
(setq org-agenda-skip-scheduled-if-done t)
(setq org-agenda-skip-deadline-if-done t))
;; Org-capture templates
(use-package org-capture
:ensure nil
:config
(setq org-capture-templates
'(("t" "Tasks")
("ts" "Scheduled tasks" entry
(file+headline "tasks.org" "Scheduled tasks")
"* TODO [#%^{Priority|B|A|C}] %^{Task} %^g\n SCHEDULED: %^t\n" :empty-lines-after 1)
("td" "Tasks with a deadline" entry
(file+headline "tasks.org" "Tasks with deadline")
"* TODO %^{Task} %^g\n DEADLINE: %^T\n" :empty-lines-after 1)
("w" "Wishlist" entry
(file+headline "tasks.org" "Wishlist")
"* TODO %^{Task}%? %^g\n" :empty-lines-after 1)
("m" "Meetings")
("mi" "One-to-one" entry
(file+headline "meetings.org" "One-to-one meetings")
"* MEETING with %^{With whom} at %^{Place} %^g\n SCHEDULED: %^T" :empty-lines-after 1)
("mg" "Group" entry
(file+headline "meetings.org" "Group meetings")
"* %^{Event} MEETING%? %^g\n SCHEDULED: %^T" :empty-lines-after 1)
("e" "Events" entry
(file+headline "events.org" "Events")
"* %^{Event}%? %^g\n SCHEDULED: %^t" :empty-lines-after 1)
("r" "Rendez-vous")
("rp" "Phone calls" entry
(file+headline "meetings.org" "Phone calls")
"* CALL with %^{With whom}%?\n SCHEDULED: %^t" :empty-lines-after 1)
("ri" "Rendezvous in-person" entry
(file+headline "meetings.org" "Rendezvous in-person")
"* HANGOUT with %^{With whom} at %^{Place}\n SCHEDULED: %^t" :empty-lines-after 1))))
;; Denote package by Protesilaos
;; Experimenting with it at the moment
(use-package denote
:ensure t
:hook (dired-mode . denote-dired-mode)
:bind
(("C-c n n" . denote)
("C-c n N" . denote-type)
("C-c n r" . denote-rename-file)
("C-c n l" . denote-link)
("C-c n b" . denote-backlinks)
("C-c n d" . denote-dired)
("C-c n g" . denote-grep))
:config
(setq denote-directory (expand-file-name "~/org/notes/"))
;; Automatically rename Denote buffers when opening them so that
;; instead of their long file name they have, for example, a literal
;; "[D]" followed by the file's title. Read the doc string of
;; `denote-rename-buffer-format' for how to modify this.
(denote-rename-buffer-mode 1))
;; Magit
(use-package magit
:ensure t
:bind
( :map global-map
("C-x g" . magit-status)
("M-c" . magit-clone)
:map magit-mode-map
("C-w" . nil)
("M-w" . nil)
("C-c c" . nil)
("C-c a" . nil))
:init
(setq magit-define-global-key-bindings nil)
:config
(setq git-commit-summary-max-length 70)
;; updates vc branch info in modeline instantaneously
;; probably not very good for the CPU
(setq auto-revert-check-vc-info t)
(setq git-commit-style-convention-checks '(non-empty-second-line))
(setq magit-diff-refine-hunk 'all))
(use-package markdown-mode
:ensure t
:mode ("*.md" . gfm-mode)
:hook (markdown-mode . visual-line-mode)
:init (setq markdown-command "multimarkdown")
:config
(setq markdown-fontify-code-blocks-natively t))
(use-package markdown-ts-mode
:mode ("\\.md\\'" . markdown-ts-mode)
:ensure nil
:defer t)
;; Marginalia package
(use-package marginalia
:ensure t
:init
(marginalia-mode))
;; TeX config
(use-package tex-site
:ensure auctex
:hook ((LaTeX-mode . electric-pair-mode)
(LaTeX-mode . cdlatex-mode)
(LaTeX-mode . reftex-mode)) ;; Turn on reftex by default in .tex files
:config
;; Activate nice interface between RefTeX and AUCTeX
(setq reftex-plug-into-AUCTeX t)
;; LaTeX document parsing enabled (even on save)
(setq TeX-auto-save t)
(setq TeX-parse-self t)
;; Autosave upon compilation
(setq TeX-save-query nil)
(add-hook 'LaTeX-mode-hook (lambda () (setq TeX-command-default "LaTeXmk")))
(setq font-latex-fontify-script nil)) ;; disables fontification of formatted text
(use-package tex-site
:ensure cdlatex)
(use-package orderless
:ensure t
:config
(setq completion-styles '(orderless basic))
(setq completion-category-overrides '((file (styles basic
partial-completion))))
(setq completion-pcm-leading-wildcard t))
;; World-clock customization
;;;; World clock (M-x world-clock)
(use-package time
:ensure nil
:commands (world-clock)
:config
(setq display-time-world-list t)
(setq zoneinfo-style-world-list ; M-x shell RET timedatectl list-timezones
'(("UTC" "UTC")
("Europe/Berlin" "Aachen")
("Europe/Helsinki" "Helsinki")
("Asia/Kolkata" "Chennai")
("Asia/Singapore" "Singapore")
("Asia/Tokyo" "Tokyo")))
;; All of the following variables are for Emacs 28
(setq world-clock-list t)
(setq world-clock-time-format "%R %z (%Z) %A %d %B")
(setq world-clock-buffer-name "*world-clock*") ; Placement handled by `display-buffer-alist'
(setq world-clock-timer-enable t)
(setq world-clock-timer-second 60))
(use-package consult
:ensure t
:bind (:map global-map
("C-c l f" . consult-focus-lines)
("C-c l g" . consult-grep)
("C-c l r" . consult-ripgrep)
("C-c l d" . consult-fd)
("C-c l i" . consult-imenu)
("C-c l l" . consult-line)))
;;;; Emacs server (allow emacsclient to connect to running session)
(use-package server
:ensure nil
:defer 1
:config
(setq server-client-instructions nil)
(unless (server-running-p)
(server-start)))
;;;; Dired (Directory Editor) customizations
(use-package dired
:ensure nil
:commands (dired)
:hook
((dired-mode . dired-hide-details-mode)
(dired-mode . hl-line-mode))
:config
(setq dired-recursive-copies 'always)
(setq dired-recursive-deletes 'always)
(setq dired-isearch-filenames 'dwim)
(setq dired-dwim-target t))
(use-package dired-subtree
:ensure t
:after dired
:bind
( :map dired-mode-map
("<tab>" . dired-subtree-toggle)
("TAB" . dired-subtree-toggle)
("<backtab>" . dired-subtree-remove)
("S-TAB" . dired-subtree-remove))
:config
(setq dired-subtree-use-backgrounds nil))
;; Minibuffer settings
(use-package minibuffer
:ensure nil
:bind
( :map minibuffer-local-map
("C-v" . yank)))
(use-package emacs
:ensure nil
:config
(defvar notmuch-path
(if (string=(system-name) "d22-0153")
"/usr/share/emacs/site-lisp/elpa/notmuch-0.38.3/"
"/usr/share/emacs/site-lisp/")))
;; Notmuch for email
(use-package notmuch
:load-path notmuch-path
:ensure nil
:defer t
:commands (notmuch notmuch-mua-new-mail)
:hook ((notmuch-hello-mode . variable-pitch-mode)
(notmuch-search-mode . variable-pitch-mode)
(notmuch-tree-mode . variable-pitch-mode)
(notmuch-show-mode . variable-pitch-mode))
:init
;; Search
(setq notmuch-search-oldest-first nil)
:config
; General UI
(setq notmuch-show-logo nil
notmuch-column-control 1.0
notmuch-hello-auto-refresh t
notmuch-hello-recent-searches-max 20
notmuch-hello-thousands-separator ""
notmuch-hello-sections '(notmuch-hello-insert-saved-searches)
notmuch-show-all-tags-list t)
; Search
(setq notmuch-search-result-format
'(("date" . "%12s ")
("count" . "%-7s ")
("authors" . "%-20s ")
("subject" . "%-80s ")
("tags" . "(%s)")))
(setq notmuch-tree-result-format
'(("date" . "%12s ")
("authors" . "%-20s ")
((("tree" . "%s")
("subject" . "%s"))
. " %-80s ")
("tags" . "(%s)")))
(setq notmuch-show-empty-saved-searches t)
(setq notmuch-saved-searches
(let ((common '((:name "inbox" :query "tag:inbox" :key "i")
(:name "unread" :query "tag:unread" :key "u")
(:name "drafts" :query "tag:draft" :key "d")
(:name "all email" :query "*" :key "A")))
(personal '((:name "aalto-inbox" :query "tag:aalto and not tag:sent" :key "aa")
(:name "aalto-sent" :query "tag:aalto and tag:sent" :key "as")
(:name "migadu-inbox" :query "tag:migadu and not tag:sent" :key "mm")
(:name "migadu-sent" :query "tag:migadu and tag:sent" :key "ms")
(:name "emacs-orgmode" :query "tag:orgmode" :key "o"))))
(if (string= (system-name) "d22-0153")
common
(append common personal))))
; Tags
(setq notmuch-archive-tags nil ; I don't archive email
notmuch-message-replied-tags '("+replied")
notmuch-message-forwarded-tags '("+forwarded")
notmuch-show-mark-read-tags '("-unread")
notmuch-draft-tags '("+draft")
notmuch-draft-folder "university/Drafts"
notmuch-fcc-dirs '(("ashish\\.panigrahi@aalto\\.fi" . "university/Sent")
("@ashishpanigrahi\\.com" . "migadu/Sent"))
notmuch-draft-save-plaintext 'ask)
; Email composition
(setq notmuch-mua-compose-in 'new-window)
(setq notmuch-mua-hidden-headers nil)
(setq notmuch-address-command 'internal)
(setq notmuch-address-use-company nil)
(if (string= (system-name) "d22-0153")
(setq notmuch-always-prompt-for-sender nil)
(setq notmuch-always-prompt-for-sender t))
(setq notmuch-mua-cite-function
'message-cite-original-without-signature)
(setq notmuch-mua-user-agent-function nil)
(setq notmuch-show-relative-dates t)
(setq notmuch-show-all-multipart/alternative-parts nil)
(setq notmuch-show-indent-messages-width 0)
(setq notmuch-show-indent-multipart nil)
(setq notmuch-show-part-button-default-action 'notmuch-show-view-part)
(setq notmuch-wash-wrap-lines-length 120)
(setq notmuch-unthreaded-show-out nil)
(setq notmuch-message-headers '("To" "Cc" "Subject" "Date"))
(setq notmuch-message-headers-visible t)
;; Prot customization
(let ((count most-positive-fixnum)) ; I don't like the buttonisation of long quotes
(setq notmuch-wash-citation-lines-prefix count
notmuch-wash-citation-lines-suffix count))
;; Increase variable-pitch font (similar to elfeed setup)
(defun pani/notmuch-variable-pitch ()
"Render notmuch buffers in variable-pitch, scaled 1.15x."
(face-remap-add-relative 'default '(:inherit variable-pitch :height 1.15))
(face-remap-add-relative 'fixed-pitch 'variable-pitch))
(define-advice notmuch-read-query (:around (orig-fun &rest args) pani/notmuch-vertico)
"Make `notmuch-read-query' use `completing-read' so Vertico drives completion.
notmuch reads its query with `read-from-minibuffer' and binds TAB to
`minibuffer-complete'; Vertico only advises `completing-read', so it never
engages and you get the default *Completions* buffer. Intercept notmuch's
`read-from-minibuffer' call and hand off to `completing-read' (reusing
notmuch's own dynamic table), restoring the real `read-from-minibuffer' around
that call so `completing-read' doesn't recurse back into us. SPC self-inserts
in `vertico-map', so multi-term queries still work."
(let ((real-rfm (symbol-function 'read-from-minibuffer)))
(cl-letf (((symbol-function 'read-from-minibuffer)
(lambda (prompt &optional initial-contents _keymap _read hist default &rest _)
(cl-letf (((symbol-function 'read-from-minibuffer) real-rfm))
(completing-read prompt minibuffer-completion-table
nil nil initial-contents hist default)))))
(apply orig-fun args))))
(defun pani/notmuch-inbox ()
"Jump straight to notmuch inbox."
(interactive)
(notmuch-search "tag:inbox"))
(defun pani/notmuch-migadu ()
"Jump straight to personal (migadu) inbox."
(interactive)
(notmuch-search "tag:migadu"))
(defun pani/notmuch-mua-empty-subject-check ()
"Prompt for confirmation before sending a message with empty subject."
(when (and (null (message-field-value "Subject"))
(not (y-or-n-p "Subject is empty, send anyway? ")))
(error "Sending message cancelled: empty subject.")))
:hook ((message-send . notmuch-mua-attachment-check)
(message-send . pani/notmuch-mua-empty-subject-check))
:bind
( :map global-map
("C-c m m" . notmuch)
("C-c m i" . pani/notmuch-inbox)
("C-c m p" . pani/notmuch-migadu)
("C-x m" . notmuch-mua-new-mail) ; override `compose-mail'
:map notmuch-search-mode-map
("a" . nil) ; not archiving so better to disable it