-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinit.el
2062 lines (1782 loc) · 62.5 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; -*-
;; init file tips:
;; http://a-nickels-worth.blogspot.com/2007/11/effective-emacs.html
;; http://sites.google.com/site/steveyegge2/effective-emacs
;; https://github.com/jwiegley/dot-emacs/blob/master/init.el
;; https://github.com/cqql/dotfiles/blob/master/home/.emacs.d/init.org
(require 'cl-lib)
(setq lexical-binding t)
(if init-file-debug
(setq use-package-verbose t
use-package-expand-minimally nil
use-package-compute-statistics t
debug-on-error t
async-debug t)
(setq use-package-verbose nil
use-package-expand-minimally t))
;;; path setup
(defcustom filter-bad-contacts
#'identity
"This is used to filter the bad contacts that mu4e is
accumulating.")
(defun set-gpg-as-ssh ()
(setenv "SSH_AUTH_SOCK" (shell-command-to-string "gpgconf --list-dirs agent-ssh-socket")))
(defcustom my/path-aliases
(list :emacs "~/.emacs.d"
:srs "~/.emacs.d"
:work "~/.emacs.d"
:agenda "~/.emacs.d")
"Location of my paths for ease of usage. Customize for each
environment if needed.")
(defun my/path (dir &optional subpath)
"Build a path name. See https://github.com/arecker/emacs.d"
(let ((dir (file-name-as-directory
(cl-getf my/path-aliases dir
(format "~/%s" dir))))
(subpath (or subpath "")))
(concat dir subpath)))
(defcustom main-agenda (my/path :emacs "agenda.org")
"This is used to store quickly todo items without refiling")
(add-to-list 'load-path (my/path :emacs "lib"))
;; IDK why this is needed.
(add-to-list 'load-path "/usr/share/emacs/site-lisp/mu4e")
(use-package gcal-sync)
(defun my/get-gcal (username diary-file)
"From a .authinfo file, uses `USERNAME' to get the secret URL
password for a gcal sync and calls `gcal-sync-calendars-to-diary'
with those, storing the result in a `DIARY-FILE'"
(let ((auth (car (auth-source-search :host username))))
(gcal-sync-calendars-to-diary
`((,(plist-get auth :user)
,(let ((s (plist-get auth :secret)))
(if (functionp s)
(funcall s)
s))))
diary-file)))
;;; things that I don't know how to do with use-package
(setq system-time-locale "en_US.UTF-8")
;; (setq system-time-locale "pt_BR.UTF-8")
(fset 'yes-or-no-p 'y-or-n-p)
(setq inhibit-startup-screen t
pop-up-frames nil
standard-indent 2
auto-save-no-message t)
(setq-default indent-tabs-mode nil
fill-column 72)
;; Maps swaps [ for ( and vice versa. I use parens much more than square
;; brackets.
(keyboard-translate ?\( ?\[)
(keyboard-translate ?\[ ?\()
(keyboard-translate ?\) ?\])
(keyboard-translate ?\] ?\))
(define-key key-translation-map (kbd "<menu>") (kbd "ESC"))
;;; packages
;;; straight installation
;;; https://github.com/raxod502/straight.el#getting-started
(defvar bootstrap-version)
(setq straight-repository-branch "develop")
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package-mode 1)
(straight-use-package 'use-package)
;;; use-package config way
;; install use-package
;; see http://cachestocaches.com/2015/8/getting-started-use-package/
;; and http://cestlaz.github.io/posts/using-emacs-1-setup/
(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives '("nongnu" . "https://elpa.nongnu.org/nongnu/") t)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
(unless package--initialized (package-initialize t))
(eval-when-compile
(require 'use-package))
(straight-use-package 'org)
;;; https://github.com/raxod502/radian/blob/develop/emacs/radian.el
(defmacro use-feature (name &rest args)
"Like `use-package', but with `straight-use-package-by-default' disabled.
NAME and ARGS are as in `use-package'."
(declare (indent defun))
`(use-package ,name
:straight nil
,@args))
;;; org auxiliary functions
(defun myorg/numeric-entry-or-zero (pom entry-name)
(let ((entry (org-entry-get pom entry-name)))
(if entry (string-to-number entry) 0)))
(require 'calc-ext)
(defun myorg/cmp-wsjf-property (entry-a entry-b)
"Compare two `org-mode' agenda entries by their WSJF.
If a is before b, return -1. If a is after b, return 1. If they
are equal return t."
(let* ((getter (lambda (entry)
(round (myorg/numeric-entry-or-zero
(get-text-property 0 'org-marker entry)
"wsjf"))))
(wsjf-a (funcall getter entry-a))
(wsjf-b (funcall getter entry-b))
(cmp (math-compare wsjf-a wsjf-b)))
(if (zerop cmp)
nil
cmp)))
(cl-defun myorg/add-wsjf-to-scope (&optional (scope 'agenda))
"Tries to add a `wsjf' property to all items in SCOPE. Agenda is the default"
(interactive)
(org-map-entries
(lambda ()
(condition-case err
(org-set-property
"wsjf"
(format "%.2f"
(/ (+ (myorg/numeric-entry-or-zero nil "bv")
(myorg/numeric-entry-or-zero nil "tc")
(myorg/numeric-entry-or-zero nil "rr-oe"))
(myorg/numeric-entry-or-zero nil "eff"))))
(error (message "%s" (error-message-string err))
t)))
nil
scope))
(use-package bookmark
:config
(setq bookmark-use-annotations nil
bookmark-save-flag t))
(use-package shr
:config
(setq shr-max-width (- fill-column 10)))
(use-package comp
;; https://www.reddit.com/r/emacs/comments/qf7o8t/orgofferlinksinentry_is_incompatible_with/
;; org agenda links not working.
:config
(setq native-comp-jit-compilation-deny-list '("org\\.el")))
(use-package diary-lib
:config
(add-hook 'diary-list-entries-hook 'diary-include-other-diary-files)
(add-hook 'diary-mark-entries-hook 'diary-mark-included-diary-files)
(add-hook 'diary-list-entries-hook 'diary-sort-entries t))
(cl-defun random-schedule (&key (n 21) extra-prop extra-log)
(when (<= n 0)
(error "Please provide a non negative quantity."))
(format "* TODO %%^{Title}
SCHEDULED: %%(org-insert-time-stamp nil nil nil nil nil \" .+%sd\")
:PROPERTIES:%s
:BV:
:TC:
:RR-OE:
:EFF:
:END:
:LOGBOOK:
- State \"TODO\" from \"\" %%U \\\\
%%^{Initial log} %%?%s
:END:"
(1+ (random n))
(if extra-prop
(concat "\n" extra-prop)
"")
(if extra-log
(concat "\n" extra-log)
"")))
(use-package ox-gfm
:straight t
:after ox)
(use-package ox-moderncv
:straight '(:host gitlab :repo "eduardo-bellani/org-cv")
:init (require 'ox-moderncv))
(use-package taskjuggler-mode)
(use-package org
:bind (("C-c l" . 'org-store-link)
("C-c c" . 'org-capture)
("C-c a" . 'org-agenda)
("C-c b" . 'org-iswitchb))
:straight t
:preface
(setq org-export-backends '(blackfriday hugo org moderncv md gfm beamer ascii html latex odt))
:config
(require 'oc-biblatex)
(setq org-refile-file-path (my/path :emacs "refile.org")
org-refile-allow-creating-parent-nodes 'confirm
org-agenda-cmp-user-defined 'myorg/cmp-wsjf-property
org-agenda-sorting-strategy
'((agenda habit-down user-defined-down time-up priority-down category-keep)
(todo priority-down category-keep)
(tags priority-down category-keep)
(search category-keep))
org-babel-inline-result-wrap "%s"
org-image-actual-width nil
org-habit-graph-column 60
org-habit-following-days 0
org-habit-preceding-days 14
org-refile-use-outline-path 'file
org-outline-path-complete-in-steps nil
org-tag-alist '((:startgroup)
("noexport" . ?n)
("export" . ?e)
(:endgroup))
org-refile-targets
`((nil :maxlevel . 9)
(org-agenda-files :maxlevel . 2)
(,(my/path :srs "deck.org") :maxlevel . 2)
(,(my/path :work "meetings.org") :maxlevel . 2))
org-capture-templates
`(("e" "Email [mu4e]" entry (file main-agenda)
,(format
"* TODO %%a
SCHEDULED: %%(org-insert-time-stamp nil nil nil nil nil \" .+%sd\")
:PROPERTIES:
:BV:
:TC:
:RR-OE:
:EFF:
:END:
:LOGBOOK:
- State \"TODO\" from \"\" %%U \\\\
from %%:from %%?
:END:" (1+ (random 21))))
("t" "todo" entry
(file main-agenda)
(function (lambda () (random-schedule))))
("w" "work reminder" entry
(file main-agenda)
,(concat "* TODO %^{Title}\n"
"SCHEDULED: <%%(memq (calendar-day-of-week date) '(1 2 3 4 5))>%?\n"
":PROPERTIES:\n"
":work_reminder: t\n"
":BV:\n"
":TC:\n"
":RR-OE:\n"
":EFF:\n"
":END:\n"
":LOGBOOK:\n"
"- Initial note taken on %U \\\n"
"%^{Initial note}\n"
":END:\n"))
("m" "meeting log" entry
(file+olp+datetree ,(my/path :work "meetings.org") "Regular")
,(concat "* %^{Title}\n"
"** Context\n"
"%^{Context}\n"
"** Goal\n"
"%^{Goal}\n"
"** Agenda\n"
"%^{Agenda}\n"
"** Ata\n"
"%^{Minutes})\n")
:time-prompt t)
("l" "daly meeting log" entry
(file+olp+datetree ,(my/path :work "meetings.org") "Daily")
,(concat "** Context\n"
"%^{Context}\n"
"** Goal\n"
"%^{Situation}\n"
"** Next steps\n"
"%^{Next steps}\n"))
("1" "1-1 meeting log" entry
(file ,(my/path :work "1-1.org"))
,(concat "* %^u\n"
"** Agenda\n"
"%^{Agenda}\n"
"** Commitments\n"
"%^{Commitments}\n"))
("d" "Drill card with answer" entry
(file ,(my/path :srs "deck.org"))
,(concat "* Item :drill:\n"
"%^{Question}\n"
"** Answer\n"
"%^{Answer}\n"))
("z" "Drill" entry
(file ,(my/path :srs "deck.org"))
,(concat "* Item :drill:\n"
"%?\n"))
("x" "Drill cloze 2" entry
(file ,(my/path :srs "deck.org"))
,(concat "* Item :drill:\n"
":PROPERTIES:\n"
":drill_card_type: hide2cloze\n"
":END:\n"
"%?\n")))
org-todo-keywords
'((sequence "TODO(t@/!)" "|" "DONE(d@/!)")
(sequence "WAITING(w@/!)" "|" "CANCELLED(c@/!)")
(sequence "REPEAT(r@/!)"))
org-imenu-depth 6
org-src-fontify-natively t
;; disable confirmation of evaluation of code. CAREFUL WHEN EVALUATING
;; FOREIGN ORG FILES!
org-confirm-babel-evaluate nil
org-use-sub-superscripts '{}
org-export-with-sub-superscripts '{}
org-babel-default-header-args
(cons '(:noweb . "yes")
(assq-delete-all :noweb org-babel-default-header-args))
org-babel-default-header-args
(cons '(:tangle . "yes")
(assq-delete-all :tangle org-babel-default-header-args))
org-babel-default-header-args
(cons '(:comments . "link")
(assq-delete-all :comments org-babel-default-header-args))
org-duration-format '((special . h:mm))
org-goto-interface 'outline-path-completion
;; agenda stuff copied from
;; https://github.com/alphapapa/org-super-agenda/blob/master/examples.org
org-agenda-skip-scheduled-if-done t
org-agenda-skip-deadline-if-done t
org-agenda-block-separator nil
org-agenda-include-diary nil
org-agenda-compact-blocks t
org-agenda-start-with-log-mode t
;; allows multiple agenda views to coexist
org-agenda-sticky nil ;; setting it to t breaks capture from agenda, for now
org-agenda-span 'day
org-plantuml-jar-path "/opt/plantuml.jar"
org-latex-pdf-process (list "latexmk -silent -f -pdf %f")
org-log-reschedule 'note
org-log-into-drawer t
org-refile-use-cache t
org-cite-export-processors '((latex biblatex)
(moderncv basic)
(html csl)
(t csl))
org-refile-use-cache t
org-pretty-entities t
org-pretty-entities-include-sub-superscripts t)
(plist-put org-format-latex-options :scale 1.3)
(defun my/org-capture-mail ()
"https://github.com/rougier/emacs-gtd"
(interactive)
;; (mu4e-headers-mark-for-move)
(call-interactively 'org-store-link)
(org-capture nil "e"))
;; format timestamps. See
;; http://endlessparentheses.com/better-time-stamps-in-org-export.html
;; get images to reload after execution. Useful for things such as
;; gnuplot. See https://emacs.stackexchange.com/q/3302
(add-hook 'org-babel-after-execute-hook 'org-display-inline-images)
(add-hook 'org-mode-hook 'org-indent-mode)
;; org mode is better at this than smart parens, plus speed
(add-hook 'org-mode-hook #'turn-off-smartparens-strict-mode)
(org-babel-do-load-languages
'org-babel-load-languages
'((dot . t)
(latex . t)
(shell . t)
(python . t)
(js . t)
(ditaa . t)
(ocaml . t)
(java . t)
(scheme . t)
(plantuml . t)
(ditaa . t)
(sqlite . t)
(gnuplot . t)
(ditaa . t)
(C . t)
(org . t)))
(defun org-set-as-habit ()
(interactive)
(org-set-property "STYLE" "habit")))
(use-package re-builder
:config (setq reb-re-syntax 'string))
(use-package smerge-mode
:config
(setq smerge-command-prefix "C-c m"))
(defun set-browser! (&optional arg)
"Makes the default browser external or internal by setting the
`browse-url-browser-function' accordingly"
(interactive "P")
(setq browse-url-browser-function
(if (equal arg '(4))
'eww-browse-url
'browse-url-generic)))
(use-package browse-url
:bind (:map
global-map
("C-c w" . 'set-browser!)))
(use-package scroll-bar
:config
(scroll-bar-mode 0))
(use-package minibuffer
:config
(setq completion-styles '(flex))
(scroll-bar-mode 0))
(defun my/mu4e-ask-bookmark (prompt)
"Ask the user for a bookmark (using PROMPT) as defined in
`mu4e-bookmarks', then return the corresponding query."
(unless (mu4e-bookmarks) (mu4e-error "No bookmarks defined"))
(let* ((prompt (mu4e-format "%s" prompt))
(server-queries (plist-get mu4e--server-props :queries))
(bmarks
(mapconcat
(lambda (bm)
(let ((bm-server-query (seq-find (lambda (q)
(string= (plist-get q :query)
(plist-get bm :query)))
server-queries)))
(format "[%s]%s (%s/%s)"
(propertize (make-string 1 (plist-get bm :key))
'face 'mu4e-highlight-face)
(plist-get bm :name)
(plist-get bm-server-query :unread)
(plist-get bm-server-query :count))))
(mu4e-bookmarks)
", "))
(kar (read-char (concat prompt bmarks))))
(mu4e-get-bookmark-query kar)))
(defun my/mu4e-swap-windows ()
(let* ((headers-buffer (mu4e-get-headers-buffer))
(headers-window (get-buffer-window headers-buffer))
(view-buffer (mu4e-get-view-buffer))
(view-window (get-buffer-window view-buffer))
(view-window-state (window-state-get view-window))
(headers-window-state (window-state-get headers-window)))
(window-state-put view-window-state headers-window t)
(window-state-put headers-window-state view-window t)))
(use-package mu4e
:bind (:map
mu4e-headers-mode-map (("C-c i" . 'my/org-capture-mail))
:map
mu4e-view-mode-map (("C-c i" . 'my/org-capture-mail)))
:config
(require 'mu4e-contrib)
;; general config
;; need to update the key
(advice-add 'mu4e-ask-bookmark :override #'my/mu4e-ask-bookmark)
(setq
mu4e-get-mail-command "mbsync -c ~/.mbsyncrc gmail"
mail-extr-all-top-level-domains nil
;; avoid auto next
mu4e-headers-advance-after-mark t
mu4e-headers-show-threads t
mu4e-view-html-plaintext-ratio-heuristic most-positive-fixnum
mu4e-contact-process-function 'filter-bad-contacts
;; "html2text -utf8 -width 72" ?
;; http://pragmaticemacs.com/emacs/fixing-duplicate-uid-errors-when-using-mbsync-and-mu4e/
;; stop UID errors
mu4e-change-filenames-when-moving t
mu4e-html2text-command 'mu4e-shr2text
mu4e-update-interval 300
mu4e-headers-auto-update t
mu4e-attachment-dir "~/Downloads"
mu4e-maildir (expand-file-name "~/Mail/")
;; don't save message to Sent Messages, GMail/IMAP will take care of this
mu4e-sent-messages-behavior 'delete
;; kill buffers on exit
message-kill-buffer-on-exit t
;; show fancy chars
mu4e-use-fancy-chars t
;; really fancy
mu4e-headers-draft-mark '("D" . "💈")
mu4e-headers-flagged-mark '("F" . "📍")
mu4e-headers-new-mark '("N" . "🔥")
mu4e-headers-passed-mark '("P" . "❯")
mu4e-headers-replied-mark '("R" . "❮")
mu4e-headers-seen-mark '("S" . "☑")
mu4e-headers-trashed-mark '("T" . "💀")
mu4e-headers-attach-mark '("a" . "📎")
mu4e-headers-encrypted-mark '("x" . "🔒")
mu4e-headers-signed-mark '("s" . "🔑")
mu4e-headers-unread-mark '("u" . "⎕")
mu4e-headers-list-mark '("s" . "🔈")
mu4e-headers-personal-mark '("p" . "👨")
mu4e-headers-calendar-mark '("c" . "📅")
mu4e-headers-visible-flags '(draft flagged new passed replied trashed attach encrypted signed)
;; attempt to show images when viewing messages sometimes this
;; slows down in the case of big djvu files (they are
;; interpreted as images).
mu4e-view-show-images t
org-mu4e-convert-to-html t
mu4e-headers-fields '((:human-date . 12)
(:flags . 6)
(:from-or-to . 22)
(:subject))
mu4e-maildir-shortcuts
'(("/INBOX" . 105)
("/sent" . 115)
("/starred" . 116)
("/all" . 97))
;; There is a new message-view for mu4e, based on the Gnus'
;; article-view. This bring a lot of (but not all) of the very rich Gnus
;; article-mode feature-set to mu4e, such as S/MIME-support,
;; syntax-highlighting,
;; mu4e-view-use-gnus nil
mu4e-date-format-long "%F"
mu4e-headers-date-format "%F"
mu4e-headers-time-format "%T"
mu4e-split-view 'single-window
mail-user-agent 'mu4e-user-agent
mu4e-headers-visible-lines 20
mu4e-hide-index-messages t
mu4e-org-contacts-file (my/path :agenda "contacts.org")
;; The error occurs because mu4e is binding more variables than emacs allows
;; for, by default. You can avoid this by setting a higher value, e.g. by
;; adding the following to your configuration:
max-specpdl-size 10000)
(advice-add 'org-msg-post-setup :after 'myorg/mu4e-compose-org-msg)
(add-hook 'mu4e-view-mode-hook #'shrface-mode)
(add-hook 'mu4e-message-changed-hook #'mu4e--start)
(add-hook 'mu4e-index-updated-hook #'mu4e--start)
(add-to-list 'mu4e-headers-actions
'("org-contact-add" . mu4e-action-add-org-contact) t)
(add-to-list 'mu4e-view-actions
'("org-contact-add" . mu4e-action-add-org-contact) t)
;; add info folder
;; (add-to-list 'Info-directory-list "/opt/mu/mu4e/")
;; (add-to-list 'Info-directory-list "~/Projects/emacs/info/")
(add-to-list 'mu4e-view-actions '("decrypt inline PGP" . epa-mail-decrypt))
(add-to-list 'mu4e-view-actions '("browse body" . mu4e-action-view-in-browser)))
(use-package mml-sec
:config
(setq mml-secure-openpgp-encrypt-to-self t
mml-secure-openpgp-sign-with-sender t))
(use-package mm-decode
:config
(add-to-list 'mm-inlined-types "application/pgp$")
(add-to-list 'mm-inline-media-tests
'("application/pgp$" mm-inline-text identity))
(add-to-list 'mm-automatic-display "application/pgp$")
(setq mm-automatic-display
(remove "application/pgp-signature" mm-automatic-display)))
(use-package windmove
:bind
(("C-x <left>" . 'windmove-left) ; move to left windnow
("C-x <right>" . 'windmove-right) ; move to right window
("C-x <up>" . 'windmove-up) ; move to upper window
("C-x <down>" . 'windmove-down) ; move to downer window
))
(use-package nxml
:mode (("\..*proj$" . nxml-mode)))
(use-package ediff
;; https://emacs.stackexchange.com/a/21336/16861
:config
(add-hook 'ediff-prepare-buffer-hook #'show-all)
;; https://stackoverflow.com/a/29757750
(defun ediff-copy-both-to-C ()
(interactive)
(ediff-copy-diff ediff-current-difference nil 'C nil
(concat
(ediff-get-region-contents ediff-current-difference 'A ediff-control-buffer)
(ediff-get-region-contents ediff-current-difference 'B ediff-control-buffer))))
(defun add-d-to-ediff-mode-map () (define-key ediff-mode-map "d" 'ediff-copy-both-to-C))
(add-hook 'ediff-keymap-setup-hook 'add-d-to-ediff-mode-map))
(use-package comint
;; This is based on
;; https://oleksandrmanzyuk.wordpress.com/2011/10/23/a-persistent-command-history-in-emacs/
;; The idea is to store sessions of comint based modes. For example, to enable
;; reading/writing of command history in, say, inferior-haskell-mode buffers,
;; simply add turn-on-comint-history to inferior-haskell-mode-hook by adding
;; it to the :hook directive
:config
(defun comint-write-history-on-exit (process event)
(comint-write-input-ring)
(let ((buf (process-buffer process)))
(when (buffer-live-p buf)
(with-current-buffer buf
(insert (format "\nProcess %s %s" process event))))))
(defun turn-on-comint-history ()
(let ((process (get-buffer-process (current-buffer))))
(when process
(setq comint-input-ring-file-name
(format "~/.emacs.d/inferior-%s-history"
(process-name process)))
(comint-read-input-ring)
(set-process-sentinel process
#'comint-write-history-on-exit))))
(defun mapc-buffers (fn)
(mapc (lambda (buffer)
(with-current-buffer buffer
(funcall fn)))
(buffer-list)))
(defun comint-write-input-ring-all-buffers ()
(mapc-buffers 'comint-write-input-ring))
(add-hook 'kill-emacs-hook 'comint-write-input-ring-all-buffers)
(add-hook 'kill-buffer-hook 'comint-write-input-ring))
;;; save history of some modes
(use-package sql
:after comint
:hook (sql-interactive-mode-hook . turn-on-comint-history)
:custom (c-basic-offset 4)
(sql-password-wallet (list "~/.authinfo.gpg")))
(use-package python
:after comint
:config
(add-to-list 'Info-directory-list "/home/user/Projects/pydoc-info/python-3.12.0-docs-texinfo/")
(add-hook 'inferior-python-mode-hook 'turn-on-comint-history))
(use-package esh
:init
(require 'em-hist)
(require 'em-tramp)
(defun eshell-here ()
"Opens up a new shell in the directory associated with the
current buffer's file. The eshell is renamed to match that
directory to make multiple eshell windows easier. from
http://www.howardism.org/Technical/Emacs/eshell-fun.html"
(interactive)
(let* ((parent (if (buffer-file-name)
(file-name-directory (buffer-file-name))
default-directory))
(height (/ (window-total-height) 3))
(name (car (last (split-string parent "/" t)))))
(split-window-vertically (- height))
(other-window 1)
(eshell "new")
(rename-buffer (concat "*eshell: " name "*"))
(insert (concat "ls"))
(eshell-send-input)))
(defun eshell/c ()
"clear the eshell buffer."
(interactive)
(let ((inhibit-read-only t))
(erase-buffer)))
(defun eshell/x ()
(delete-window)
(eshell-save-some-history)
(eshell/exit))
(defun eshell-maybe-bol ()
"I use the following code. It makes C-a go to the beginning of
the command line, unless it is already there, in which case it
goes to the beginning of the line. So if you are at the end of
the command line and want to go to the real beginning of line,
hit C-a twice:"
(interactive)
(let ((p (point)))
(eshell-bol)
(if (= p (point))
(beginning-of-line))))
(setenv "PAGER" "cat")
(setq eshell-history-size 1024
eshell-visual-commands
'("mtr" "nethogs" "htop" "ncdu" "nmon" "top" "less" "more"))
(add-hook 'eshell-mode-hook (lambda () (company-mode -1)))
:bind (:map
global-map
("C-x !" . 'eshell-here)
:map
eshell-command-map
("C-a" . eshell-maybe-bol)
:map
eshell-mode-map
("C-a" . eshell-maybe-bol)))
(use-package ispell
:no-require t
:bind (("C-c i c" . ispell-comments-and-strings)
("C-c i d" . ispell-change-dictionary)
("C-c i k" . ispell-kill-ispell)
("C-c i m" . ispell-message)
("C-c i r" . ispell-region)))
(use-package frame
:bind (("C-c f" . 'make-frame)))
(use-package paren
:config (show-paren-mode 1))
(use-package elisp-mode
:after elisp-slime-nav-mode
:bind
(("C-c d" . 'elisp-disassemble)
("C-c m" . 'elisp-macroexpand)
("C-c M" . 'elisp-macroexpand-all)
("C-c C-c" . 'compile-defun))
:config
(require 'cl)
(defun elisp-disassemble (function)
(interactive (list (function-called-at-point)))
(disassemble function))
(defun elisp-pp (sexp)
(with-output-to-temp-buffer "*Pp Eval Output*"
(pp sexp)
(with-current-buffer standard-output
(emacs-lisp-mode))))
(defun elisp-macroexpand (form)
(interactive (list (form-at-point 'sexp)))
(elisp-pp (macroexpand form)))
(defun elisp-macroexpand-all (form)
(interactive (list (form-at-point 'sexp)))
(elisp-pp (cl-macroexpand-all form)))
(elisp-slime-nav-mode 1))
(use-package time
:config
(setq display-time-format "%F %R %z"
display-time-mode 1))
(use-package dired
:config
(setq dired-listing-switches "-alh"
dired-dwim-target 'dired-dwim-target-recent))
(use-package dired-x
:after dired)
(use-package autorevert
:config
(global-auto-revert-mode t))
(use-package simple
:defer 5
:bind (("C-w" . 'backward-kill-word)
("C-x C-k" . 'kill-region))
:hook ((before-save . delete-trailing-whitespace))
:config
(setq
column-number-mode t
auto-fill-mode 1
async-shell-command-buffer 'new-buffer))
(use-package hl-line
:config
(global-hl-line-mode t))
(use-package files
:config
(setq require-final-newline nil))
(use-package tool-bar
:config
(tool-bar-mode 0))
(use-package menu-bar
:config
(menu-bar-mode 0))
(use-package tooltip
:config
(tooltip-mode 0))
(use-package files
:config
(setq backup-directory-alist
`((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
`((".*" ,temporary-file-directory t))))
(use-package ox
:after org
:config
(add-to-list
'org-export-filter-timestamp-functions
(lambda
(trans back _comm)
"Remove <> around time-stamps."
(pcase back
(`html
(replace-regexp-in-string
"[][]"
""
(replace-regexp-in-string "&[lg]t;" "" trans)))
((or `ascii `latex)
(replace-regexp-in-string "[][<>]" "" trans))))))
;;; packages that are fetched
;;; Libraries
(use-package diminish
:straight t)
(use-package parse-csv
:straight t
:defer t)
(use-package s
:straight t
:defer t)
(use-package dash
:straight t
:defer t)
(use-package ht
:straight t
:defer t)
(use-package org-ql
:straight t
:defer t)
;;; packages
(use-package async
:straight t
:defer 0
:config
(require 'smtpmail-async)
(setq ; why mail-extr-all-top-level-domains is breaking this?
;; look at inject variables later
omail-extr-all-top-level-domains nil
send-mail-function 'async-smtpmail-send-it
message-send-mail-function 'async-smtpmail-send-it
async-debug t
;; message-send-mail-function #'smtpmail-send-it
;; #'message--default-send-mail-function
smtpmail-default-smtp-server "smtp.gmail.com"
smtpmail-smtp-server "smtp.gmail.com"
smtpmail-smtp-service 587
undo-tree-enable-undo-in-region nil
smtpmail-debug-info nil
))
(use-package undo-tree
:straight t
:config
(global-undo-tree-mode)
(setq undo-tree-visualizer-diff t
undo-tree-enable-undo-in-region nil
undo-tree-visualizer-timestamps t
undo-tree-history-directory-alist `(("." . ,temporary-file-directory))))
(use-package psession
:straight t
:config
(psession-savehist-mode 1)
(psession-mode 1)
(psession-autosave-mode 0)
(bind-key "C-x p s" 'psession-save-winconf)
(bind-key "C-x p d" 'psession-delete-winconf)
(bind-key "C-x p j" 'psession-restore-winconf))
(use-package magit
:straight t
:bind
(("C-x g" . magit-status))
:config
(setq magit-display-buffer-function 'magit-display-buffer-fullframe-status-topleft-v1
magit-bury-buffer-function 'magit-restore-window-configuration))
(use-package forge
:straight t
:after magit)
(use-package git-timemachine
:straight t
:after magit)
(use-package switch-window
:straight t
:config
(setq switch-window-threshold 3)
:bind
("C-x o" . 'switch-window)
("C-x 1" . 'switch-window-then-maximize)
("C-x 2" . 'switch-window-then-split-below)
("C-x 3" . 'switch-window-then-split-right)
("C-x 0" . 'switch-window-then-delete)
("C-x 4 d" . 'switch-window-then-dired)
("C-x 4 f" . 'switch-window-then-find-file)
("C-x 4 m" . 'switch-window-then-compose-mail)
("C-x 4 r" . 'switch-window-then-find-file-read-only)
("C-x 4 C-f" . 'switch-window-then-find-file)
("C-x 4 C-o" . 'switch-window-then-display-buffer)
("C-x 4 0" . 'switch-window-then-kill-buffer))
(use-package pdf-tools
;; https://github.com/jwiegley/use-package#magic-handlers
:straight t :config
(pdf-tools-install :no-query)
(setq pdf-view-resize-factor 1.05))
(use-package org-pdftools
:straight t
:after pdf-tools
:hook (org-mode . org-pdftools-setup-link))
(use-package web-mode
:straight t
:mode (("\\.html?\\''" . web-mode)
("\\.fsproj$" . web-mode)))
(use-package hippie-exp
:straight t
:bind ("M-/" . hippie-expand)
:init
(setf hippie-expand-try-functions-list
'(try-expand-dabbrev-visible
try-expand-dabbrev
try-expand-dabbrev-all-buffers
try-expand-line
try-complete-lisp-symbol)))
(use-package company
:straight t
:demand t
:commands (company-mode company-indent-or-complete-common)
:config
(setf company-idle-delay 0.5
company-selection-wrap-around t)
:hook (after-init . global-company-mode))
(use-package helm-company
:straight t
:after helm company
:bind (:map