summaryrefslogtreecommitdiff
path: root/home/dots/.emacs
blob: 9a931a15675dfc035107bf9221f6aad662c6fe83 (plain)
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
;; -*- lexical-binding: t; -*-
(add-to-list 'load-path "~/.emacs.d/elisp")
(fset 'yes-or-no-p 'y-or-n-p)
(setq
 inhibit-startup-screen t
 default-frame-alist '((font . "Iosevka SS13 Extended")
		       (height . 170)
		       (line-spacing . 0.5))
 ;; undo
 undo-limit 10000000
 undo-outer-limit 20000000
 
 ;; Package list
 package-list '(
		magit
		nix-mode
		go-mode
		devdocs
		rec-mode
		almost-mono-themes
		eldoc-box
		markdown-mode
		nov
		yasnippet
		yasnippet-snippets
		pinentry
		geiser
		geiser-guile
		guix
		avy
		tldr
		elfeed
		elfeed-protocol
		exwm
		emms
		mastodon
		pass
		lem
		expand-region)
 
 package-archives '(("elpa" . "https://elpa.gnu.org")
                    ("gnu" . "http://elpa.gnu.org/packages/")
		    ("melpa" . "https://melpa.org/packages/")
		    ("non-gnu" . "https://elpa.nongnu.org/nongnu/")
		    ("melpa-stable" . "https://stable.melpa.org/packages/")))


;; UI
(menu-bar-mode -1)
(tool-bar-mode -1)

(setq-default fill-column 80
	      frame-title-format '("%b"))

(package-initialize)


(unless package-archive-contents
  (package-refresh-contents))

;; install the missing packages
(dolist (package package-list)
  (unless (package-installed-p package)
    (package-install package)))

(use-package tab-bar
  :init
  (tab-bar-mode))

(use-package project
  :ensure t
  :init
  (add-to-list 'project-switch-commands '(project-shell "Shell")))

(use-package exwm
  :init
  (setq exwm-workspace-number 1
	exwm-input-global-keys
	`(([?\s-r] . exwm-reset) ;; s-r: Reset (to line-mode).
          ;; s-N: Switch to certain workspace.
          ,@(mapcar (lambda (i)
                      `(,(kbd (format "s-%d" i)) .
			(lambda ()
                          (interactive)
                          (tab-bar-select-tab ,i))))
                    (number-sequence 0 9))))
  (exwm-input-set-key (kbd "s-f")
		      (lambda () (interactive)
			(shell-command "firefox")))
  (exwm-input-set-key (kbd "<print>")
		      (lambda () (interactive)
			(shell-command "scrot -F '/home/mccd/screenshots/%Y-%m-%d_$wx$h.png'")))
  (exwm-input-set-key (kbd "C-<print>")
		      (lambda () (interactive)
			(shell-command "scrot -s -F '/home/mccd/screenshots/%Y-%m-%d_$wx$h.png'")))
  (exwm-input-set-key (kbd "s-<SPC>")
		      (lambda (cmd) ;; s-&: Launch application.
			(interactive (list (read-shell-command "$ ")))
			(start-process-shell-command cmd nil cmd)))  
  (exwm-enable)
  (exwm-xim-mode)
  (push ?\C-\\ exwm-input-prefix-keys)
  :config
  (setq
   ring-bell-function 'ignore
   default-directory "/home/mccd/"
   focus-follows-mouse t
   mouse-autoselect-window t)
  :hook
  (;; Make sure titles match X window
   (server-after-make-frame . (lambda ()
				(set-window-margins (selected-window) 2 2)))
   (exwm-update-title . (lambda ()
			  (exwm-workspace-rename-buffer
			   (concat exwm-class-name ":"
				   (if (<= (length exwm-title) 50) exwm-title
				     (concat (substring exwm-title 0 49) "..."))))))
   (exwm-update-class . (lambda ()
			  (exwm-workspace-rename-buffer
			   (concat exwm-class-name ":"
				   (if (<= (length exwm-title) 50) exwm-title
				     (concat (substring exwm-title 0 49) "..."))))))))

(use-package time
  :init
  (display-time-mode)
  :config
  (setq display-time-format "%a, %d/%m/%Y %H:%M"))

(use-package geiser
  :ensure t)

(use-package pixel-scroll
  :init
  (pixel-scroll-precision-mode))

(use-package scroll-bar
  :init
  (scroll-bar-mode -1))

(use-package frame
  :init
  (window-divider-mode))

(use-package delsel
  :init
  (delete-selection-mode))

(use-package files
  :config
  (setq delete-old-versions t
	kept-new-versions 6
	kept-old-versions 2
	version-control t
	auto-save-default nil))

(use-package minibuffer
  :defer t
  :config
  (setq completion-cycle-threshold 5
	completion-ignore-case t))

(use-package pass
  :defer t
  :ensure t)

(use-package select
  :config
  (setq x-select-enable-clipboard t
	x-select-enable-primary t))

(use-package imenu
  :defer t
  :config
  (setq imenu-auto-rescan t))

(defun sudo-shell-command (command)
  (interactive "MShell command (root): ")
  (with-temp-buffer
    (cd "/sudo::/")
    (async-shell-command command)))


(use-package guix
  :ensure t
  :bind
  (("C-c C-g g" . guix)
   ("C-c C-g o" . (lambda ()
		  (interactive)
		  (sudo-shell-command "guix system reconfigure /home/mccd/system/os/config.scm")))
   ("C-c C-g h" . (lambda ()
		  (interactive)
		  (async-shell-command "guix home reconfigure ~/system/home/config.scm")))))


(use-package nov
  :defer t
  :ensure t
  :init
  (add-to-list 'auto-mode-alist '("\\.epub'" . nov-mode)))

(use-package battery
  :init
  (display-battery-mode t))

(use-package comint
  :bind
  ((:repeat-map
    repeat-hist-line-map
    ("n" . comint-next-input)
    ("p" . comint-previous-input))))

(use-package repeat
  :demand t
  :bind
  ((:repeat-map
    repeat-normal-movement-map
    ("n" . next-line)
    ("b" . backward-char)
    ("f" . forward-char)
    ("e" . move-end-of-line)
    ("F" . forward-word)
    ("B" . backward-word)
    ("v" . scroll-up-command)
    ("V" . scroll-down-command)    
    ("o" . avy-goto-char-timer)
    ("g" . goto-line)
    ("a" . move-beginning-of-line)
    ("k" . kill-line)
    ("d" . delete-char)
    ("D" . kill-word)
    ("." . er/expand-region)
    ("-" . er/contract-region)
    ("p" . previous-line))
   (:repeat-map
    repeat-movement-map
    ("e" . end-of-defun)
    ("f" . forward-sexp)
    ("n" . forward-list)
    ("p" . backward-list)        
    ("d" . down-list)
    ("u" . up-list)
    ("b" . backward-sexp)
    ("a" . beginning-of-defun)))
  :config
  (setq repeat-on-final-keystroke t
	set-mark-command-repeat-pop t
	repeat-exit-key (kbd "<TAB>"))
  (repeat-mode 1))

(use-package org-crypt
  :ensure nil
  :init
  (setenv "GPG_AGENT_INFO" nil)
  (setq auth-source-debug t
	epg-gpg-program "gpg2")
  (org-crypt-use-before-save-magic))

(use-package grep
  :config
  (setq-default 
   grep-template (string-join
		  '("ugrep"
                    "--color=never"
                    "--ignore-binary"
                    "--ignore-case"
                    "--include=<F>"
                    "--line-number"
                    "--null"
                    "--recursive"
                    "--regexp=<R>")
                  " ")))

(use-package pinentry
  :ensure t
  :init
  (pinentry-start))


(use-package epa-file
  :init
  (epa-file-enable)
  (setq
   epa-pinentry-mode 'loopback))

(use-package exwm-mff
  :demand t
  :load-path "elisp"
  :hook
  ((server-after-make-frame . exwm-mff-mode)))

(use-package avy
  :ensure t
  :config
  (setq
   avy-timeout-seconds 0.2)
  (global-set-key (kbd "M-o") 'avy-goto-char-timer)
  (set-face-attribute 'avy-lead-face nil :inherit 'fixed-pitch)
  (set-face-attribute 'avy-lead-face-0 nil :inherit 'fixed-pitch)
  (set-face-attribute 'avy-lead-face-1 nil :inherit 'fixed-pitch)
  (set-face-attribute 'avy-lead-face-2 nil :inherit 'fixed-pitch)
  (setf (alist-get ?  avy-dispatch-alist) 'avy-action-mark-to-char)
  (define-key isearch-mode-map (kbd "M-o") 'avy-isearch)
  (defun avy-action-kill-whole-line (pt)
    (save-excursion
      (goto-char pt)
      (kill-whole-line))
    (select-window
     (cdr
      (ring-ref avy-ring 0)))
    t)
  (setf (alist-get ?k avy-dispatch-alist) 'avy-action-kill-stay
	(alist-get ?K avy-dispatch-alist) 'avy-action-kill-whole-line)
  (defun avy-action-copy-whole-line (pt)
    (save-excursion
      (goto-char pt)
      (cl-destructuring-bind (start . end)
          (bounds-of-thing-at-point 'line)
	(copy-region-as-kill start end)))
    (select-window
     (cdr
      (ring-ref avy-ring 0)))
    t)
  (defun avy-action-yank-whole-line (pt)
    (avy-action-copy-whole-line pt)
    (save-excursion (yank))
    t)

  (setf (alist-get ?y avy-dispatch-alist) 'avy-action-yank
	(alist-get ?w avy-dispatch-alist) 'avy-action-copy
	(alist-get ?W avy-dispatch-alist) 'avy-action-copy-whole-line
	(alist-get ?Y avy-dispatch-alist) 'avy-action-yank-whole-line)
  (defun avy-action-copy-whole-line (pt)
    (save-excursion
      (goto-char pt)
      (cl-destructuring-bind (start . end)
          (bounds-of-thing-at-point 'line)
	(copy-region-as-kill start end)))
    (select-window
     (cdr
      (ring-ref avy-ring 0)))
    t)

  (defun avy-action-yank-whole-line (pt)
    (avy-action-copy-whole-line pt)
    (save-excursion (yank))
    t)

  (setf (alist-get ?y avy-dispatch-alist) 'avy-action-yank
	(alist-get ?w avy-dispatch-alist) 'avy-action-copy
	(alist-get ?W avy-dispatch-alist) 'avy-action-copy-whole-line
	(alist-get ?Y avy-dispatch-alist) 'avy-action-yank-whole-line)

  (defun avy-action-teleport-whole-line (pt)
    (avy-action-kill-whole-line pt)
    (save-excursion (yank)) t)

  (setf (alist-get ?t avy-dispatch-alist) 'avy-action-teleport
	(alist-get ?T avy-dispatch-alist) 'avy-action-teleport-whole-line)

  (defun avy-action-mark-to-char (pt)
    (activate-mark)
    (goto-char pt))

  (setf (alist-get ?  avy-dispatch-alist) 'avy-action-mark-to-char))

(use-package flymake
  :defer t
  :bind
  (:repeat-map flymake-repeat-map
	       ("]" . flymake-goto-next-error)
	       ("[" . flymake-goto-prev-error))
  :hook
  ((flymake-mode .
		 (lambda ()
		   (define-key flymake-mode-map (kbd "C-c ]") 'flymake-goto-next-error)
		   (define-key flymake-mode-map (kbd "C-c [") 'flymake-goto-prev-error)))))

(use-package expand-region
  :ensure t
  :init
  (global-set-key (kbd "C-c .") 'er/expand-region))

(use-package devdocs
  :ensure t
  :init
  (global-set-key (kbd "C-h D") 'devdocs-lookup))

(use-package sgml-mode
  :init
  (add-to-list 'auto-mode-alist '("\\.njk\\'" . html-mode))
  (add-to-list 'auto-mode-alist '("\\.tmpl\\'" . html-mode))
  :hook
  ;; TODO fix
  ((html-mode . (lambda ()
		  (keymap-local-set (kbd "M-o") 'avy-goto-char-timer)))
   (html-mode . (lambda ()
		  (setq sgml-basic-offset 8
			indent-tabs-mode t)))))

(use-package eldoc
  :ensure t
  :demand t
  :diminish ""
  :config
  (setq eldoc-print-after-edit t
	echo-area-display-truncation-message nil
	eldoc-echo-area-prefer-doc-buffer 'maybe
	eldoc-echo-area-use-multiline-p nil)
  :hook (prog-mode . eldoc-mode))

(use-package eldoc-box
  :ensure t
  :demand t
  :hook
  (eglot-managed-mode . #'eldoc-box-hover-mode)
  :config
  (global-set-key (kbd "C-h .") #'eldoc-box-help-at-point))

(use-package markdown-mode
  :ensure t
  :config
  (set-face-attribute 'markdown-code-face nil :inherit 'fixed-pitch)
  :hook
  ((markdown-mode . variable-pitch-mode)
   (markdown-mode . markdown-toggle-url-hiding)
   (markdown-mode . markdown-toggle-markup-hiding)
   (markdown-mode . visual-line-mode)))

(use-package elec-pair
  :init
  (electric-pair-mode 1)
  :config
  (global-set-key (kbd "M-{") 'insert-pair)
  (global-set-key (kbd "M-\"") 'insert-pair)
  (global-set-key (kbd "M-\'") 'insert-pair)
  (global-set-key (kbd "M-<") 'insert-pair)
  (global-set-key (kbd "M-[") 'insert-pair))

(use-package ido
  :init
  (ido-mode t))

(use-package org-link-minor-mode
  :load-path "elisp"
  :defer t)

(use-package calendar
  :defer t
  :init
  (add-to-list 'auto-mode-alist '("~/personal-db/log" . diary-mode))
  :hook
  ((diary-mode . variable-pitch-mode)
					;   (diary-mode . org-link-minor-mode)
					;   (diary-fancy-display-mode . org-link-minor-mode)
   (diary-fancy-display-mode . variable-pitch-mode)
   (diary-mode . (lambda () 
		   (add-hook 'after-save-hook 'sync-org nil t)))
   (diary-mode . flyspell-mode))
  :config
  (global-set-key (kbd "C-c d") 'calendar)
  (calendar-set-date-style 'european)
  (set-face-attribute 'diary nil :inherit 'fixed-pitch)
  (setq diary-file "~/personal-db/log"
	calendar-mark-diary-entries-flag t
	calendar-week-start-day 1))

(use-package nix-mode
  :ensure t
  :defer t
  :hook
  ((nix-mode . (lambda () 
		 (add-hook 'before-save-hook #'nix-format-buffer nil t)))
   (nix-mode . nix-prettify-mode)))

(use-package eglot
  :config
  ;; Ensure `nil` is in your PATH.
  (add-to-list 'eglot-server-programs '(nix-mode . ("nil")))
  (define-key eglot-mode-map (kbd "C-c r") 'eglot-rename)
  (define-key eglot-mode-map (kbd "C-c o") 'eglot-code-actions)
  :hook
  (nix-mode . eglot-ensure)
  (go-mode . eglot-ensure))

(use-package go-mode
  :ensure t
  :defer t
  :hook
  ((go-mode . (lambda () 
		(add-hook
		 'before-save-hook 'eglot-format-buffer nil t)))
   (go-mode . (lambda ()
		(setq-local compile-command "go build .")))))

(use-package rec-mode
  :ensure nil
  :defer t
  :mode "\\.rec\\'"
  :hook
  ((rec-mode . flymake-mode)
   (rec-mode . eldoc-mode)))

(use-package erc
  :ensure t
  :config
  (setq erc-autojoin-channels-alist
        '(("Libera.Chat"
	   "#emacs"
	   "#permacomputing"
	   "#oldcomputerchallenge"
	   "#go-nuts"
	   "#netbsd"
	   "#nonguix"
	   "#guix")))
  :init
  (global-set-key 
   "\C-cef"
   (lambda ()
     (interactive)
     (erc
      :server "irc.libera.chat"
      :port "6667"
      :nick "mccd"
      :password (shell-command-to-string "pass show libera.chat")))))

(use-package ob-rec
  :ensure nil)

(defun sync-org ()
  (interactive)
  (async-shell-command "org-sync"))

(add-to-list 'display-buffer-alist '("*Async Shell Command*" display-buffer-no-window (nil)))

;; Org
(use-package org
  :ensure t
  :init
  (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
  (org-babel-do-load-languages
   'org-babel-load-languages
   '((shell . t)
     (rec .t)))
  
  :config
  (setq org-refile-targets
	'((nil :maxlevel . 4)
          (org-agenda-files :maxlevel . 4))
	org-default-notes-file "~/personal-db/notes/todo.org"
	org-hide-emphasis-markers t
	org-agenda-include-diary t
	org-agenda-remove-tags t
	org-startup-folded 'content
	org-agenda-inhibit-startup nil
	;; Add /New Heading at the end for use
	org-refile-allow-creating-parent-nodes 'confirm
	org-outline-path-complete-in-steps nil
	org-refile-use-outline-path 'file
	;; Otherwise looks weird in variable-pitch-mode
	org-log-done 'time
	org-capture-templates
	'(("t" "Todo"
           entry (file "~/personal-db/notes/todo.org")
           "* TODO %?\n%i\n%a\n "
           :empty-lines 0)
	  ("l" "Log" plain (file "~/personal-db/log")
	   "%<%d %b %Y %H:%M> %?"
	   :prepend t)
	  ("n" "Inbox"
	   entry (file "~/personal-db/notes/inbox.org")
	   "** %?\n%T"
	   :empty-lines 0)))
  (set-face-attribute 'org-block nil :inherit 'fixed-pitch)
  (set-face-attribute 'org-code nil :inherit 'fixed-pitch)
  (set-face-attribute 'org-table nil :inherit 'fixed-pitch)
  (set-face-attribute 'org-date nil :inherit 'fixed-pitch)
  (set-face-attribute 'org-tag nil :inherit 'fixed-pitch)
  (global-set-key (kbd "C-c l") #'org-store-link)
  (global-set-key (kbd "C-c a") #'org-agenda)
  (global-set-key (kbd "C-c c") #'org-capture)
  (global-set-key (kbd "C-c j") #'org-goto)
  (global-set-key (kbd "C-c s") #'project-find-regexp)
  (global-set-key (kbd "C-c C-o") #'org-open-at-point-global)
  (global-set-key (kbd "C-c C-s") #'sync-org)
  ;; Something errors out with capture logs and non-org files
  (add-to-list 'warning-suppress-log-types '(org-element))
  (add-to-list 'warning-suppress-types '(org-element))
  :hook
  ((org-mode . auto-save-visited-mode)
   (org-mode . org-indent-mode)
   (org-mode . flyspell-mode)
   (org-mode . visual-line-mode)
   (org-mode . (lambda () 
		(add-hook 'after-save-hook 'sync-org nil t)))
   (org-mode . variable-pitch-mode)))

(use-package rec-mode
  :ensure t)

(use-package magit
  :ensure t
  :demand t)

(use-package magit-extras
  :ensure nil)

(use-package yasnippet
  :diminish t
  :ensure t
  :init
  (yas-global-mode 1))

(use-package register
  :bind
  (("C-z" . 'point-to-register)))

(defun marc/set-msmtp-account ()
  (if (message-mail-p)
      (save-excursion
        (let*
            ((from (save-restriction
                     (message-narrow-to-headers)
                     (message-fetch-field "from")))
             (account
              (cond
               ((string-match "marcc@fastmail.fr" from) "home")
               ((string-match "marc.coquand@sustainably.app" from) "work")
               ((string-match "marc@mccd.space" from) "home"))))
          (setq message-sendmail-extra-arguments (list '"-a" account))))))

;(use-package message
;  :defer t
;  :hook
;  ((message-send-mail . marc/set-msmtp-account)
;   (message-mode-hook flyspell-mode)))

(add-hook 'message-send-mail-hook #'marc/set-msmtp-account)
(add-hook 'message-mode-hook #'flyspell-mode)

(use-package flyspell
  :defer t)

(use-package mu4e
  :ensure nil
  :config
  ;; This is set to 't' to avoid mail syncing issues when using mbsync
  (setq mu4e-change-filenames-when-moving t)
  
  ;; don't keep message compose buffers around after sending:
  (setq message-kill-buffer-on-exit t)

  ;; send function:
  (setq send-mail-function 'sendmail-send-it
	message-send-mail-function 'sendmail-send-it)

  ;; send program:
  ;; this is exeranal. remember we installed it before.
  (setq sendmail-program (executable-find "msmtp"))

  ;; select the right sender email from the context.
  (setq message-sendmail-envelope-from 'header)  
    
  ;; Refresh mail using isync every 10 minutes
  (setq mu4e-update-interval (* 10 60)
        mu4e-get-mail-command "mbsync -a"
	mu4e-view-show-images t
	mu4e-view-show-addresses t
	mu4e-attachment-dir "~/Downloads"
	mu4e-view-prefer-html t
	mu4e-maildir "~/mail")

  (setq mu4e-contexts
        (list
	 ;; Home
	 (make-mu4e-context
          :name "home"
	  :enter-func (lambda () (mu4e-message "Entering personal context"))
	  :leave-func (lambda () (mu4e-message "Leaving personal context"))
          :match-func
          (lambda (msg)
            (when msg
              (string-prefix-p "/home" (mu4e-message-field msg :maildir))))
          :vars '((user-mail-address . "marc@mccd.space")
                  (user-full-name    . "Marc Coquand")
                  (mu4e-drafts-folder  . "/home/Drafts")
                  (mu4e-sent-folder  . "/home/Sent")
                  (mu4e-refile-folder  . "/home/Archive")
                  (mu4e-trash-folder  . "/home/Trash")
		  (mu4e-sent-messages-behavior . sent)

		  (mu4e-maildir-shortcuts .
					  (("/home/INBOX" . ?i)
					   ("/home/Archive/Done" . ?d)
					   ("/home/Archive" . ?a)
					    ("/home/Archive/Todo" . ?t)))))
         ;; Work account
         (make-mu4e-context
          :name "work"
	  :enter-func (lambda () (mu4e-message "Entering work context"))
	  :leave-func (lambda () (mu4e-message "Leaving work context"))
          :match-func
          (lambda (msg)
            (when msg
              (string-prefix-p "/work" (mu4e-message-field msg :maildir))))
          :vars '((user-mail-address . "marc.coquand@sustainably.app")
                  (user-full-name    . "Marc Coquand")
                  (mu4e-drafts-folder  . "/work/[Gmail]/Drafts")
                  (mu4e-sent-folder  . "/work/[Gmail]/Sent Mail")
                  (mu4e-refile-folder  . "/work/[Gmail]/All Mail")
		  (mu4e-sent-messages-behavior . delete)
                  (mu4e-trash-folder  . "/work/[Gmail]/Trash")
		  (mu4e-maildir-shortcuts .
					  (("/work/[Gmail]/All Mail" . ?a)
					   ("/work/INBOX" . ?i))))))))


(use-package lem
  :ensure t
  :config
  (setq lem-instance-url "https://lemmy.sdf.org"))

(use-package elfeed-protocol
  :ensure t
  :init
  (elfeed-protocol-enable))

(use-package elfeed
  :ensure t
  :config
  (setq elfeed-use-curl t
	;; setup feeds
	elfeed-protocol-fever-update-unread-only t
	elfeed-protocol-fever-fetch-category-as-tag t
	elfeed-protocol-feeds '(("fever+https://freshrss@rss.mccd.space"
				 :api-url "https://rss.mccd.space/api/fever.php"
				 :password (shell-command-to-string "pass show mccd/freshrss")))
	;; enable elfeed-protocol
	elfeed-protocol-enabled-protocols '(fever)
	elfeed-curl-extra-arguments '("--insecure")) ;necessary for https without a trust certificate
  (elfeed-set-timeout 36000)
  (global-set-key (kbd "C-x w") 'elfeed))

(use-package mastodon
  :defer t
  :config
  (setq 
   mastodon-active-user "marcc"
   mastodon-instance-url "https://fosstodon.org"))

(use-package eww
  :config
  (setq
   browse-url-browser-function 'eww-browse-url ; Use eww as the default browser
   eww-search-prefix "https://lite.duckduckgo.com/lite/?q="
   shr-max-image-proportion 0.3
   shr-width 70))

;; Can play youtube urls and music.
;; Requires mpv
(use-package emms
  :ensure t
  :init
  (add-hook 'emms-player-started-hook 'emms-show)
  :config
  (setq emms-shop-format "on: %s")
  (emms-all)
  (emms-default-players))

(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(default ((t (:inherit nil :extend nil :stipple nil :background "white" :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight regular :height 150 :width expanded :foundry "UKWN" :family "Iosevka SS13 Extended"))))
 '(avy-lead-face ((t (:inherit fixed-pitch :background "dark red" :foreground "white"))))
 '(calendar-weekend-header ((t (:inherit nil))))
 '(custom-group-subtitle ((t (:weight bold :family "Iosevka Aile"))))
 '(diary ((t (:inherit fixed-pitch :foreground "red1"))))
 '(eglot-highlight-symbol-face ((t (:weight bold))))
 '(eglot-mode-line ((t (:weight regular))))
 '(erc-timestamp-face ((t (:foreground "blue" :weight bold))))
 '(eshell-prompt ((t (:weight bold))))
 '(eww-valid-certificate ((t (:foreground "black" :weight bold))))
 '(fixed-pitch ((t (:family "Iosevka SS13 Extended"))))
 '(font-lock-builtin-face ((t (:weight regular))))
 '(font-lock-comment-face ((t (:foreground "royalblue" :slant normal))))
 '(font-lock-constant-face ((t (:slant italic :weight regular))))
 '(font-lock-function-name-face ((t (:weight regular))))
 '(font-lock-keyword-face ((t (:weight regular))))
 '(font-lock-string-face ((t (:foreground "black" :slant italic))))
 '(font-lock-type-face ((t (:foreground "black"))))
 '(font-lock-variable-name-face ((t (:foreground "black"))))
 '(fringe ((t (:background "white"))))
 '(header-line ((t (:inherit default :foreground "grey20" :box (:line-width (8 . 8) :color "#FFFFFF") :underline (:color "#e0e0e0" :style line :position 0) :family "Iosevka Aile"))))
 '(highlight ((t (:background "azure2"))))
 '(info-header-xref ((t (:inherit info-xref :underline (:color "RoyalBlue3" :style line :position t)))))
 '(info-node ((t (:foreground "brown" :box (:line-width (4 . 4) :color "white") :slant italic :weight bold))))
 '(link ((t (:foreground "royalblue" :underline t))))
 '(magit-branch-remote ((t (:foreground "royalblue"))))
 '(markdown-inline-code-face ((t (:inherit markdown-code-face))))
 '(markdown-pre-face ((t (:inherit markdown-code-face))))
 '(mastodon-display-name-face ((t (:inherit nil :weight bold))))
 '(mode-line ((t (:background "gray95" :foreground "black" :box (:line-width (8 . 8) :style flat-button) :overline "#e0e0e0" :underline (:color "#e0e0e0" :style line :position t) :family "Iosevka Aile"))))
 '(mode-line-emphasis ((t (:weight regular))))
 '(mode-line-inactive ((t (:inherit mode-line :background "#fbfbfb" :foreground "grey60" :overline "#f9f9f9" :underline (:color "#f9f9f9" :style line :position 0) :weight light))))
 '(mu4e-header-highlight-face ((t (:inherit hl-line :extend t :weight bold))))
 '(mu4e-highlight-face ((t (:inherit highlight))))
 '(org-date ((t (:inherit fixed-pitch :foreground "gray40" :underline t))))
 '(org-headline-done ((t (:foreground "gray40"))))
 '(org-level-1 ((t (:inherit outline-1 :extend nil :weight regular))))
 '(org-tag ((t (:inherit fixed-pitch :foreground "gray40" :weight regular))))
 '(org-time-grid ((t (:foreground "gray"))))
 '(outline-4 ((t (:inherit outline-2))))
 '(tab-bar ((t (:box (:line-width (12 . 24) :style flat-button) :weight semi-light :family "Iosevka Aile"))))
 '(tab-bar-tab ((t (:inherit tab-bar :foreground "black" :box (:line-width (20 . 1) :color "white") :weight semi-bold))))
 '(tab-bar-tab-inactive ((t (:inherit tab-bar-tab :background "white" :foreground "#999999" :weight semi-light))))
 '(tldr-code-block ((t (:background "cornsilk" :foreground "black"))))
 '(tldr-command-argument ((t (:background "cornsilk" :foreground "black"))))
 '(tldr-command-itself ((t (:background "khaki" :foreground "black" :weight bold))))
 '(tldr-introduction ((t (:foreground "black" :slant italic))))
 '(tldr-title ((t (:inherit variable-pitch :foreground "black" :weight bold :height 1.2))))
 '(variable-pitch ((t (:family "Iosevka Aile"))))
 '(window-divider ((t (:foreground "gray90")))))
(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(custom-safe-themes
   '("cbd85ab34afb47003fa7f814a462c24affb1de81ebf172b78cb4e65186ba59d2" default))
 '(erc-mode-line-format "")
 '(erc-modules
   '(autojoin button completion fill irccontrols list match menu move-to-prompt netsplit networks noncommands notifications readonly ring services stamp spelling))
 '(magit-section-visibility-indicator '("..." . t))
 '(markdown-list-item-bullets '("-"))
 '(mastodon-tl--enable-proportional-fonts t)
 '(mastodon-use-emojify t)
 '(mode-line-compact 'long)
 '(mode-line-format
   '("%e" mode-line-front-space
     (:propertize
      ("" mode-line-modified " "))
     mode-line-buffer-identification " " mode-line-modes))
 '(mode-line-percent-position nil)
 '(mode-line-position-line-format '(" "))
 '(mu4e-bookmarks
   '((:name "Last 7 days" :query "date:7d..now" :hide-unread t :key 119)
     (:name "Messages with images" :query "mime:image/*" :key 112)))
 '(org-agenda-files
   '("~/personal-db/notes/sustainable-software.org" "/home/mccd/personal-db/notes/thoughts.org" "/home/mccd/personal-db/notes/cal-ios.org" "/home/mccd/personal-db/notes/ethics-and-software.org" "/home/mccd/personal-db/notes/reminders.org" "/home/mccd/builds/sustainably/piva.org" "/home/mccd/personal-db/notes/programming.org" "/home/mccd/personal-db/notes/unix.org" "/home/mccd/personal-db/notes/agency-and-tech.org" "/home/mccd/personal-db/notes/emacs-teaches.org" "/home/mccd/personal-db/notes/emacs.org" "/home/mccd/personal-db/notes/inbox.org" "/home/mccd/personal-db/notes/todo.org"))
 '(org-fold-core-style 'overlays)
 '(package-selected-packages
   '(nov eldoc-box hide-mode-line exwm-mff eat pinentry exwm emms company orglink web-mode flycheck nix-mode nix-ts-mode avy pdf-tools elfeed-protocol lem yasnippet-snippets elfeed yasnippet smartparens markdown-mode mastodon tldr almost-mono-themes rec-mode magit go-mode expand-region devdocs))
 '(tab-bar-auto-width t)
 '(tab-bar-close-button-show nil)
 '(tab-bar-format
   '(tab-bar-format-tabs tab-bar-format-align-right tab-bar-format-global))
 '(tab-bar-position nil)
 '(tab-bar-tab-hints t)
 '(window-divider-default-right-width 2)
 '(yank-from-kill-ring-rotate t))
(put 'secrets-mode 'disabled nil)