-
Notifications
You must be signed in to change notification settings - Fork 17
/
init.el
1486 lines (1291 loc) · 44.7 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
;; DO NOT EDIT THIS FILE DIRECTLY
;; This is a file generated from a literate programing source file located at
;; https://gitlab.com/zzamboni/dot-emacs/-/blob/master/init.org
;; You should make any changes there and regenerate it from Emacs org-mode using C-c C-v t
(let ((file-name-handler-alist nil))
(add-hook 'emacs-startup-hook
(lambda ()
(message "Emacs ready in %s with %d garbage collections."
(format "%.2f seconds"
(float-time
(time-subtract after-init-time before-init-time)))
gcs-done)))
;; (setq debug-on-error t)
;; (when (require 'gcmh nil t)
;; (gcmh-mode 1))
(setq gc-cons-threshold most-positive-fixnum)
(setq custom-file "~/.emacs.d/custom.el")
(load custom-file)
(custom-set-variables '(package-archives
'(("marmalade" . "https://marmalade-repo.org/packages/")
("melpa" . "https://melpa.org/packages/")
("elpa" . "https://elpa.gnu.org/packages/"))))
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
(when (not (package-installed-p 'use-package))
(package-install 'use-package))
(require 'use-package)
(custom-set-variables '(use-package-always-ensure t))
(custom-set-variables '(use-package-always-defer t))
(custom-set-variables '(use-package-verbose nil))
(use-package quelpa
:defer nil
:config
(quelpa
'(quelpa-use-package
:fetcher git
:url "https://github.com/quelpa/quelpa-use-package.git"))
(require 'quelpa-use-package))
(require 'quelpa)
(quelpa-use-package-activate-advice)
(custom-set-variables '(load-prefer-newer t))
(use-package auto-compile
:defer nil
:config (auto-compile-on-load-mode))
(add-to-list 'load-path "~/.emacs.d/lisp")
(use-package paradox
:defer nil
:custom
(paradox-github-token t)
:config
(paradox-enable))
(require 'auth-source)
(require 'auth-source-pass)
(auth-source-pass-enable)
(custom-set-variables '(confirm-kill-processes nil))
(defun zz/set-proxy ()
(interactive)
(customize-set-variable 'url-proxy-services
'(("http" . "proxy.corproot.net:8079")
("https" . "proxy.corproot.net:8079"))))
(defun zz/unset-proxy ()
(interactive)
(customize-set-variable 'url-proxy-services nil))
(set-language-environment "UTF-8")
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(setq default-buffer-file-coding-system 'utf-8)
(require 'cl)
(use-package async)
(server-start)
(add-hook 'before-save-hook 'time-stamp)
(custom-set-variables '(kill-whole-line t))
(custom-set-variables '(mouse-yank-at-point t))
(setq completion-ignore-case t)
(custom-set-variables
'(read-buffer-completion-ignore-case t)
'(read-file-name-completion-ignore-case t))
(custom-set-variables '(show-trailing-whitespace nil))
(show-paren-mode)
(custom-set-variables '(indent-tabs-mode nil))
(custom-set-variables
'(backup-directory-alist
`(("." . ,(concat user-emacs-directory "backups")))))
(when (fboundp 'winner-mode) (winner-mode))
(use-package unfill
:bind
("M-q" . unfill-toggle)
("A-q" . unfill-paragraph))
(use-package saveplace
:defer nil
:config
(save-place-mode))
(use-package imenu-anywhere
:bind
("M-i" . helm-imenu-anywhere))
(use-package smooth-scrolling
:config
(smooth-scrolling-mode 1))
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(custom-set-variables '(ad-redefinition-action (quote accept)))
(cond ((eq system-type 'darwin)
(custom-set-variables
'(mac-command-modifier 'meta)
'(mac-option-modifier 'alt)
'(mac-right-option-modifier 'super))
(bind-key "M-+" 'text-scale-increase)
(bind-key "M-=" 'text-scale-increase)
(bind-key "M--" 'text-scale-decrease)
(defun zz/text-scale-reset ()
(interactive)
(text-scale-set 0))
(bind-key "M-0" 'zz/text-scale-reset)
(use-package exec-path-from-shell
:defer nil
:config
(exec-path-from-shell-initialize))
(if (fboundp 'mac-auto-operator-composition-mode)
(mac-auto-operator-composition-mode))
(bind-key "A-M-SPC" #'mark-sexp)
(bind-key "M-s-SPC" #'mark-sexp)
)
((eq system-type 'windows-nt)
)
((eq system-type 'gnu/linux)
))
(use-package which-key
:defer nil
:diminish which-key-mode
:config
(which-key-mode))
(require 'bind-key)
(bind-key "M-g" 'goto-line)
(bind-key "M-`" 'other-frame)
(use-package pcre2el)
(use-package visual-regexp-steroids
:custom
(vr/engine 'pcre2el "Use PCRE regular expressions")
:bind
("C-c r" . vr/replace)
("C-c q" . vr/query-replace)
("C-r" . vr/isearch-backward)
("C-S-s" . vr/isearch-forward)
("C-M-s" . isearch-forward)
("C-M-r" . isearch-backward))
(bind-key "M-/" 'hippie-expand)
(defun zz/goto-match-paren (arg)
"Go to the matching paren/bracket, otherwise (or if ARG is not
nil) insert %. vi style of % jumping to matching brace."
(interactive "p")
(if (not (memq last-command '(set-mark
cua-set-mark
zz/goto-match-paren
down-list
up-list
end-of-defun
beginning-of-defun
backward-sexp
forward-sexp
backward-up-list
forward-paragraph
backward-paragraph
end-of-buffer
beginning-of-buffer
backward-word
forward-word
mwheel-scroll
backward-word
forward-word
mouse-start-secondary
mouse-yank-secondary
mouse-secondary-save-then-kill
move-end-of-line
move-beginning-of-line
backward-char
forward-char
scroll-up
scroll-down
scroll-left
scroll-right
mouse-set-point
next-buffer
previous-buffer
previous-line
next-line
back-to-indentation
)))
(self-insert-command (or arg 1))
(cond ((looking-at "\\s\(") (sp-forward-sexp) (backward-char 1))
((looking-at "\\s\)") (forward-char 1) (sp-backward-sexp))
(t (self-insert-command (or arg 1))))))
(bind-key "%" 'zz/goto-match-paren)
(use-package org
;; :pin manual
:load-path ("lisp/org-mode/lisp" "lisp/org-mode/lisp/contrib/lisp")
:bind
(:map org-mode-map
("C-c l" . org-store-link)
("A-h" . org-mark-element)
("C-a" . org-beginning-of-line)
("C-e" . org-end-of-line)
("C-k" . org-kill-line))
:custom
(org-directory "~/org")
(org-log-done t)
(org-startup-indented t)
(org-log-into-drawer t)
(org-special-ctrl-a/e t)
(org-special-ctrl-k t)
(org-use-speed-commands
(lambda ()
(and (looking-at org-outline-regexp)
(looking-back "^\**"))))
(org-confirm-babel-evaluate nil)
(org-src-fontify-natively t)
(org-src-tab-acts-natively t)
(org-hide-emphasis-markers t)
(prettify-symbols-unprettify-at-point 'right-edge)
(org-fontify-done-headline t)
(org-tags-column 0)
(org-todo-keyword-faces
'(("AREA" . "DarkOrchid1")
("[AREA]" . "DarkOrchid1")
("PROJECT" . "DarkOrchid1")
("[PROJECT]" . "DarkOrchid1")
("INBOX" . "cyan")
("[INBOX]" . "cyan")
("PROPOSAL" . "orange")
("[PROPOSAL]" . "orange")
("DRAFT" . "yellow3")
("[DRAFT]" . "yellow3")
("INPROGRESS" . "yellow4")
("[INPROGRESS]" . "yellow4")
("MEETING" . "purple")
("[MEETING]" . "purple")
("CANCELED" . "blue")
("[CANCELED]" . "blue")))
:custom-face
(variable-pitch ((t (:family "ETBembo" :height 180 :weight thin))))
;;(variable-pitch ((t (:family "Avenir Next" :height 160 :weight light))))
;; (fixed-pitch ((t (:family "Inconsolata Nerd Font"))))
(fixed-pitch ((t (:family "Fira Code Retina" :height 160))))
(org-indent ((t (:inherit (org-hide fixed-pitch)))))
(org-done ((t (:foreground "PaleGreen"
:strike-through t))))
:hook
(org-mode . (lambda () (add-hook 'after-save-hook 'org-babel-tangle :append :local)))
(org-babel-after-execute . org-redisplay-inline-images)
(org-mode . (lambda ()
"Beautify Org Checkbox Symbol"
(push '("[ ]" . "☐" ) prettify-symbols-alist)
(push '("[X]" . "☑" ) prettify-symbols-alist)
(push '("[-]" . "⊡" ) prettify-symbols-alist)
(prettify-symbols-mode)))
(org-mode . visual-line-mode)
(org-mode . variable-pitch-mode)
:config
(org-babel-do-load-languages
'org-babel-load-languages
'((cfengine3 . t)
(ruby . t)
(latex . t)
(plantuml . t)
(python . t)
(shell . t)
(elvish . t)
(calc . t)
(dot . t)
(ditaa . t)
(org . t)))
(font-lock-add-keywords
'org-mode
'(("^ *\\([-]\\) "
(0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•"))))))
(defface org-checkbox-done-text
'((t (:foreground "#71696A" :strike-through t)))
"Face for the text part of a checked org-mode checkbox.")
(font-lock-add-keywords
'org-mode
`(("^[ \t]*\\(?:[-+*]\\|[0-9]+[).]\\)[ \t]+\\(\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?\\[\\(?:X\\|\\([0-9]+\\)/\\2\\)\\][^\n]*\n\\)"
1 'org-checkbox-done-text prepend))
'append)
(let* ((variable-tuple
(cond ((x-list-fonts "ETBembo") '(:font "ETBembo"))
((x-list-fonts "Source Sans Pro") '(:font "Source Sans Pro"))
((x-list-fonts "Lucida Grande") '(:font "Lucida Grande"))
((x-list-fonts "Verdana") '(:font "Verdana"))
((x-family-fonts "Sans Serif") '(:family "Sans Serif"))
(nil (warn "Cannot find a Sans Serif Font."))))
(base-font-color (face-foreground 'default nil 'default))
(headline `(:inherit default :weight bold
:foreground ,base-font-color)))
(custom-theme-set-faces
'user
`(org-level-8 ((t (,@headline ,@variable-tuple))))
`(org-level-7 ((t (,@headline ,@variable-tuple))))
`(org-level-6 ((t (,@headline ,@variable-tuple))))
`(org-level-5 ((t (,@headline ,@variable-tuple))))
`(org-level-4 ((t (,@headline ,@variable-tuple :height 1.1))))
`(org-level-3 ((t (,@headline ,@variable-tuple :height 1.25))))
`(org-level-2 ((t (,@headline ,@variable-tuple :height 1.5))))
`(org-level-1 ((t (,@headline ,@variable-tuple :height 1.75))))
`(org-headline-done ((t (,@headline ,@variable-tuple :strike-through t))))
`(org-document-title ((t (,@headline ,@variable-tuple
:height 2.0 :underline nil))))))
(eval-after-load 'face-remap '(diminish 'buffer-face-mode))
(eval-after-load 'simple '(diminish 'visual-line-mode)))
(use-package org-indent
:ensure nil
:diminish
:custom
(org-indent-indentation-per-level 4))
(defun zz/add-file-keybinding (key file &optional desc)
(lexical-let ((key key)
(file file)
(desc desc))
(global-set-key (kbd key) (lambda () (interactive) (find-file file)))
(which-key-add-key-based-replacements key (or desc file))))
(custom-set-variables '(org-agenda-files
'("~/gtd" "~/Work/work.org.gpg" "~/org/ideas.org" "~/org/projects.org" "~/org/diary.org")))
(zz/add-file-keybinding "C-c f w" "~/Work/work.org.gpg" "work.org")
(zz/add-file-keybinding "C-c f i" "~/org/ideas.org" "ideas.org")
(zz/add-file-keybinding "C-c f p" "~/org/projects.org" "projects.org")
(zz/add-file-keybinding "C-c f d" "~/org/diary.org" "diary.org")
(use-package org-capture
:ensure nil
:after org
:defer 1
:bind
("C-c c" . org-capture)
:config
(add-to-list 'org-capture-templates
'("i" "GTD item"
entry (file (lambda () (org-gtd--path org-gtd-inbox-file-basename)))
"* %?\n%U\n\n %i"
:kill-buffer t))
(add-to-list 'org-capture-templates
'("l" "GTD item with link to where you are in emacs now"
entry (file (lambda () (org-gtd--path org-gtd-inbox-file-basename)))
"* %?\n%U\n\n %i\n %a"
:kill-buffer t))
(defun org-hugo-new-subtree-post-capture-template ()
"Returns `org-capture' template string for new Hugo post.
See `org-capture-templates' for more information."
(let* ((title (read-from-minibuffer "Post Title: "))
(fname (org-hugo-slug title)))
(mapconcat #'identity
`(,(concat "* TODO " title)
":PROPERTIES:"
,(concat ":EXPORT_HUGO_BUNDLE: " fname)
":EXPORT_FILE_NAME: index"
":END:"
"%?\n") ; Place the cursor here finally
"\n")))
(add-to-list 'org-capture-templates
'("z" ;`org-capture' binding + z
"zzamboni.org post"
entry
(file+olp "~/Personal/websites/zzamboni.org/content-org/zzamboni.org" "Ideas")
(function org-hugo-new-subtree-post-capture-template)))
)
(setq org-refile-targets '((nil :maxlevel . 9)
(org-agenda-files :maxlevel . 9)))
(setq org-outline-path-complete-in-steps nil) ; Refile in a single go
(setq org-refile-use-outline-path t) ; Show full paths for refiling
(use-package org-agenda
:ensure nil
:after org
:bind
("C-c a" . org-agenda)
:custom
(org-agenda-include-diary t)
(org-agenda-prefix-format '((agenda . " %i %-12:c%?-12t% s")
;; Indent todo items by level to show nesting
(todo . " %i %-12:c%l")
(tags . " %i %-12:c")
(search . " %i %-12:c")))
(org-agenda-start-on-weekday nil))
(use-package mexican-holidays
:defer nil)
(quelpa '(swiss-holidays :fetcher github :repo "egli/swiss-holidays"))
(require 'swiss-holidays)
(setq swiss-holidays-zh-city-holidays
'((holiday-float 4 1 3 "Sechseläuten") ;; meistens dritter Montag im April
(holiday-float 9 1 3 "Knabenschiessen"))) ;; zweites Wochenende im September
(use-package holidays
:defer nil
:ensure nil
:init
(require 'mexican-holidays)
:config
(setq calendar-holidays
(append '((holiday-fixed 1 1 "New Year's Day")
(holiday-fixed 2 14 "Valentine's Day")
(holiday-fixed 4 1 "April Fools' Day")
(holiday-fixed 10 31 "Halloween")
(holiday-easter-etc)
(holiday-fixed 12 25 "Christmas")
(solar-equinoxes-solstices))
swiss-holidays
swiss-holidays-labour-day
swiss-holidays-catholic
swiss-holidays-zh-city-holidays
holiday-mexican-holidays)))
(require 'org-habit)
(use-package org-super-agenda
:defer nil
:custom
(org-super-agenda-groups '((:auto-dir-name t)))
:config
(org-super-agenda-mode))
(use-package org-archive
:ensure nil
:custom
(org-archive-location "archive.org::datetree/"))
(use-package org-edna
:defer nil)
(use-package org-gtd
:defer 3
:after org
:config
(require 'org-gtd)
;; these are the interactive functions you're likely to want to use as you go about GTD.
(global-set-key (kbd "C-c d c") 'org-gtd-capture) ;; add item to inbox
(global-set-key (kbd "C-c d p") 'org-gtd-process-inbox) ;; process entire inbox
(global-set-key (kbd "C-c d a") 'org-agenda-list) ;; see what's on your plate today
(global-set-key (kbd "C-c d n") 'org-gtd-show-all-next) ;; see all NEXT items
(global-set-key (kbd "C-c d s") 'org-gtd-show-stuck-projects) ;; see projects that don't have a NEXT item
;; package: https://www.nongnu.org/org-edna-el/
;; org-edna is used to make sure that when a project task gets DONE,
;; the next TODO is automatically changed to NEXT.
(setq org-edna-use-inheritance t)
(org-edna-load)
;; package: https://github.com/Malabarba/org-agenda-property
;; this is so you can see who an item was delegated to in the agenda
(setq org-agenda-property-list '("DELEGATED_TO"))
;; I think this makes the agenda easier to read
(setq org-agenda-property-position 'next-line))
(use-package emacsql
:defer nil)
(use-package emacsql-sqlite
:after emacsql
:defer nil)
(use-package org-roam
:after (org emacsql emacsql-sqlite)
:load-path "lisp/org-roam"
:diminish
:hook
((org-mode . org-roam-mode)
(after-init . org-roam--build-cache-async))
:custom
(org-roam-directory "~/org")
:bind
("C-c n l" . org-roam)
("C-c n t" . org-roam-today)
("C-c n f" . org-roam-find-file)
("C-c n i" . org-roam-insert)
("C-c n g" . org-roam-show-graph))
(use-package deft
:after org
:bind
("C-c n d" . deft)
:custom
(deft-directory org-directory)
(deft-recursive t)
(deft-use-filename-as-title nil)
(deft-use-filter-string-for-filename t)
(deft-file-naming-rules '((noslash . "-")
(nospace . "-")
(case-fn . downcase)))
(deft-org-mode-title-prefix t)
(deft-extensions '("org" "txt" "text" "md" "markdown" "org.gpg"))
(deft-default-extension "org"))
(use-package org-download
:after org
:defer nil
:custom
(org-download-method 'directory)
(org-download-image-dir "images")
(org-download-heading-lvl nil)
(org-download-timestamp "%Y%m%d-%H%M%S_")
(org-image-actual-width 300)
:bind
("C-M-y" .
(lambda (&optional noask)
(interactive "P")
(let ((file
(if (not noask)
(read-string (format "Filename [%s]: " org-download-screenshot-basename)
nil nil org-download-screenshot-basename)
nil)))
(org-download-clipboard file))))
:config
(require 'org-download))
(use-package ox-reveal
:load-path ("lisp/org-reveal")
:defer 3
:after org
:custom
(org-reveal-note-key-char nil)
(org-reveal-root "file:///Users/taazadi1/.emacs.d/lisp/reveal.js"))
(use-package htmlize
:defer 3
:after ox-reveal)
(use-package ox-html
:ensure nil
:defer 3
:after org
:custom
(org-html-checkbox-type 'unicode))
(use-package ox-md
:ensure nil
:defer 3
:after org)
(use-package ox-jira
:defer 3
:after org)
(use-package org-jira
:defer 3
:after org
:custom
(jiralib-url "https://jira.swisscom.com"))
(use-package ox-confluence
:defer 3
:ensure nil
:after org)
(use-package ox-asciidoc
:defer 3
:after org)
(use-package ox-texinfo
:load-path "lisp/org-mode/lisp"
:defer 3
:ensure nil
:after org)
(use-package ox-latex
:load-path "lisp/org-mode/lisp"
:ensure nil
:demand
:after org
:custom
(org-latex-compiler "xelatex")
;; (org-latex-pdf-process
;; '("%latex -shell-escape -interaction nonstopmode -output-directory %o %f"
;; "%latex -interaction nonstopmode -output-directory %o %f"
;; "%latex -interaction nonstopmode -output-directory %o %f"))
:config
;; (setq org-latex-listings 'minted)
;; (add-to-list 'org-latex-packages-alist '("newfloat" "minted"))
;; (add-to-list 'org-latex-minted-langs '(lua "lua"))
;; (add-to-list 'org-latex-minted-langs '(shell "shell"))
(add-to-list 'org-latex-classes
'("book-no-parts" "\\documentclass[11pt,letterpaper]{book}"
("\\chapter{%s}" . "\\chapter*{%s}")
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")))
;; Necessary for LuaLaTeX to work - see
;; https://tex.stackexchange.com/a/374391/10680
(setenv "LANG" "en_US.UTF-8"))
(use-package ox-clip
:bind
("A-C-M-k" . ox-clip-formatted-copy))
(use-package ox-awesomecv
:load-path "~/.emacs.d/lisp/org-cv"
:init
(require 'ox-awesomecv))
(use-package ox-hugocv
:disabled
:load-path "~/.emacs.d/lisp/org-cv"
:init
(require 'ox-hugocv))
(use-package ox-org
:ensure nil
:defer 3
:after org)
(use-package ox-hugo
:defer 3
:after org
;; Testing hooks to automatically set the filename on an ox-hugo
;; blog entry when it gets marked as DONE
;; :hook
;; (org-mode . (lambda ()
;; (add-hook 'org-after-todo-state-change-hook
;; (lambda ()
;; (org-set-property
;; "testprop"
;; (concat "org-state: " org-state
;; " prev-state: " (org-get-todo-state))))
;; 'run-at-end 'only-in-org-mode)))
:custom
(org-hugo-use-code-for-kbd t))
(use-package epa-file
:ensure nil ;; included with Emacs
:config
(setq epa-file-encrypt-to '("diego@zzamboni.org"))
:custom
(epa-file-select-keys 'silent))
(use-package org-crypt
:ensure nil ;; included with org-mode
:after org
:config
(org-crypt-use-before-save-magic)
(setq org-tags-exclude-from-inheritance (quote ("crypt")))
:custom
(org-crypt-key "diego@zzamboni.org"))
(use-package org-journal
:after org
:custom
(org-journal-dir (concat (file-name-as-directory org-directory) "journal"))
(org-journal-file-format "%Y/%m/%Y%m%d")
(org-journal-date-format "%A, %Y-%m-%d")
(org-journal-encrypt-journal t)
(org-journal-enable-encryption nil)
(org-journal-enable-agenda-integration t)
:bind
("C-c j" . org-journal-new-entry))
(use-package ob-cfengine3
:after org)
(use-package ob-elvish
:after org)
(require 'subr-x)
(setq homebrew-plantuml-jar-path
(expand-file-name
(string-trim
(shell-command-to-string "brew list plantuml | grep jar"))))
(use-package plantuml-mode
:custom
(plantuml-jar-path homebrew-plantuml-jar-path))
(use-package ob-plantuml
:ensure nil
:after org
:custom
(org-plantuml-jar-path homebrew-plantuml-jar-path))
(defalias 'console-mode 'shell-script-mode)
(defun zz/org-babel-tangle-async (file)
"Invoke `org-babel-tangle-file' asynchronously."
(message "Tangling %s..." (buffer-file-name))
(async-start
(let ((args (list file)))
`(lambda ()
(require 'org)
;;(load "~/.emacs.d/init.el")
(let ((start-time (current-time)))
(apply #'org-babel-tangle-file ',args)
(format "%.2f" (float-time (time-since start-time))))))
(let ((message-string (format "Tangling %S completed after " file)))
`(lambda (tangle-time)
(message (concat ,message-string
(format "%s seconds" tangle-time)))))))
(defun zz/org-babel-tangle-current-buffer-async ()
"Tangle current buffer asynchronously."
(zz/org-babel-tangle-async (buffer-file-name)))
(use-package org-bullets
:after org
:hook
(org-mode . (lambda () (org-bullets-mode 1))))
(defun zz/write ()
(interactive)
;; Line spacing
(setq line-spacing 0.1)
;; Top padding
(setq header-line-format " ")
;; Hide modeline
(hide-mode-line-mode)
;;(setq mode-line-format nil)
;; Side padding
(setq left-margin-width 2)
(setq right-margin-width 2)
(set-window-buffer nil (current-buffer)))
(use-package hide-mode-line)
(with-eval-after-load 'org
(defvar-local rasmus/org-at-src-begin -1
"Variable that holds whether last position was a ")
(defvar rasmus/ob-header-symbol ?☰
"Symbol used for babel headers")
(defun rasmus/org-prettify-src--update ()
(let ((case-fold-search t)
(re "^[ \t]*#\\+begin_src[ \t]+[^ \f\t\n\r\v]+[ \t]*")
found)
(save-excursion
(goto-char (point-min))
(while (re-search-forward re nil t)
(goto-char (match-end 0))
(let ((args (org-trim
(buffer-substring-no-properties (point)
(line-end-position)))))
(when (org-string-nw-p args)
(let ((new-cell (cons args rasmus/ob-header-symbol)))
(cl-pushnew new-cell prettify-symbols-alist :test #'equal)
(cl-pushnew new-cell found :test #'equal)))))
(setq prettify-symbols-alist
(cl-set-difference prettify-symbols-alist
(cl-set-difference
(cl-remove-if-not
(lambda (elm)
(eq (cdr elm) rasmus/ob-header-symbol))
prettify-symbols-alist)
found :test #'equal)))
;; Clean up old font-lock-keywords.
(font-lock-remove-keywords nil prettify-symbols--keywords)
(setq prettify-symbols--keywords (prettify-symbols--make-keywords))
(font-lock-add-keywords nil prettify-symbols--keywords)
(while (re-search-forward re nil t)
(font-lock-flush (line-beginning-position) (line-end-position))))))
(defun rasmus/org-prettify-src ()
"Hide src options via `prettify-symbols-mode'.
`prettify-symbols-mode' is used because it has uncollpasing. It's
may not be efficient."
(let* ((case-fold-search t)
(at-src-block (save-excursion
(beginning-of-line)
(looking-at "^[ \t]*#\\+begin_src[ \t]+[^ \f\t\n\r\v]+[ \t]*"))))
;; Test if we moved out of a block.
(when (or (and rasmus/org-at-src-begin
(not at-src-block))
;; File was just opened.
(eq rasmus/org-at-src-begin -1))
(rasmus/org-prettify-src--update))
;; Remove composition if at line; doesn't work properly.
;; (when at-src-block
;; (with-silent-modifications
;; (remove-text-properties (match-end 0)
;; (1+ (line-end-position))
;; '(composition))))
(setq rasmus/org-at-src-begin at-src-block)))
;; This function helps to produce a single glyph out of a
;; string. The glyph can then be used in prettify-symbols-alist.
;; This function was provided by Ihor in the org-mode mailing list.
(defun yant/str-to-glyph (str)
"Transform string into glyph, displayed correctly."
(let ((composition nil))
(dolist (char (string-to-list str)
(nreverse (cdr composition)))
(push char composition)
(push '(Br . Bl) composition))))
(defun rasmus/org-prettify-symbols ()
(mapc (apply-partially 'add-to-list 'prettify-symbols-alist)
(cl-reduce 'append
(mapcar (lambda (x) (list x (cons (upcase (car x)) (cdr x))))
`(("#+begin_src" . ?⎡) ;; ⎡ ➤ 🖝 ➟ ➤ ✎
;; multi-character strings can be used with something like this:
;; ("#+begin_src" . ,(yant/str-to-glyph "```"))
("#+end_src" . ?⎣) ;; ⎣ ✐
("#+header:" . ,rasmus/ob-header-symbol)
("#+begin_quote" . ?«)
("#+end_quote" . ?»)))))
(turn-on-prettify-symbols-mode)
(add-hook 'post-command-hook 'rasmus/org-prettify-src t t))
(add-hook 'org-mode-hook #'rasmus/org-prettify-symbols))
(use-package toc-org
:after org
:hook
(org-mode . toc-org-enable))
(use-package org-mac-link
:ensure nil
:load-path "lisp/org-mode/contrib/lisp"
:after org
:custom
(org-mac-grab-Acrobat-app-p nil "Disable grabbing from Adobe Acrobat")
(org-mac-grab-devonthink-app-p nil "Disable grabbinb from DevonThink")
:bind
(:map org-mode-map
("C-c g" . org-mac-grab-link)))
(defun zz/org-reformat-buffer ()
(interactive)
(when (y-or-n-p "Really format current buffer? ")
(let ((document (org-element-interpret-data (org-element-parse-buffer))))
(erase-buffer)
(insert document)
(goto-char (point-min)))))
(defun afs/org-remove-link ()
"Replace an org link by its description or if empty its address"
(interactive)
(if (org-in-regexp org-bracket-link-regexp 1)
(let ((remove (list (match-beginning 0) (match-end 0)))
(description (if (match-end 3)
(org-match-string-no-properties 3)
(org-match-string-no-properties 1))))
(apply 'delete-region remove)
(insert description))))
(bind-key "C-c C-M-u" 'afs/org-remove-link)
(defun zz/org-if-str (str &optional desc)
(when (org-string-nw-p str)
(or (org-string-nw-p desc) str)))
(defun zz/org-macro-hsapi-code (module &optional func desc)
(org-link-make-string
(concat "https://www.hammerspoon.org/docs/"
(concat module (zz/org-if-str func (concat "#" func))))
(or (org-string-nw-p desc)
(format "=%s="
(concat module
(zz/org-if-str func (concat "." func)))))))
(defun zz/org-macro-keys-code-outer (str)
(mapconcat (lambda (s)
(concat "~" s "~"))
(split-string str)
(concat (string ?\u200B) "+" (string ?\u200B))))
(defun zz/org-macro-keys-code-inner (str)
(concat "~" (mapconcat (lambda (s)
(concat s))
(split-string str)
(concat (string ?\u200B) "-" (string ?\u200B)))
"~"))
(defun zz/org-macro-keys-code (str)
(zz/org-macro-keys-code-inner str))
(defun zz/org-macro-luadoc-code (func &optional section desc)
(org-link-make-string
(concat "https://www.lua.org/manual/5.3/manual.html#"
(zz/org-if-str func section))
(zz/org-if-str func desc)))
(defun zz/org-macro-luafun-code (func &optional desc)
(org-link-make-string
(concat "https://www.lua.org/manual/5.3/manual.html#"
(concat "pdf-" func))
(zz/org-if-str (concat "=" func "()=") desc)))
(defun org-latex-publish-to-latex-and-open (plist file pub-dir)
(org-open-file (org-latex-publish-to-pdf plist file pub-dir)))
(use-package ox-leanpub
:defer 1
:after org
:config
(require 'ox-leanpub-markdown)
(org-leanpub-book-setup-menu-markdown))
(defun org-get-keyword (key)
(org-element-map (org-element-parse-buffer 'element) 'keyword
(lambda (k)
(when (string= key (org-element-property :key k))
(org-element-property :value k)))
nil t))
(use-package org-sidebar)
(when (>= emacs-major-version 26)
(pixel-scroll-mode))
(use-package diminish
:defer 1)
;;(use-package solarized-theme)
;;(use-package darktooth-theme)
;;(use-package kaolin-themes)
;;(use-package gruvbox-theme)
(use-package spacemacs-theme)
(load-theme 'spacemacs-light)
(use-package smart-mode-line
:defer 2
:config
(sml/setup)
:custom
(sml/theme 'respectful)
(sml/replacer-regexp-list
'(("^~/\\.emacs\\.d/elpa/" ":ELPA:")
("^~/\\.emacs\\.d/" ":ED:")
("^/sudo:.*:" ":SU:")
("^~/Documents/" ":Doc:")
("^:\\([^:]*\\):Documento?s/" ":\\1/Doc:")
("^~/Dropbox/" ":DB:")
("^:DB:org" ":Org:")
("^:DB:Personal/" ":P:")
("^:DB:Personal/writing/" ":Write:")
("^:P:devel/" ":Dev:")
("^:Write:learning-cfengine-3/learning-cfengine-3/" ":cf-learn:")
("^:Dev:go/src/github.com/elves/elvish/" ":elvish:")
("^:Dev:zzamboni.org/zzamboni.org/" ":zz.org:"))))
(use-package desktop
:defer nil
:custom
(desktop-restore-eager 1 "Restore the first buffer right away")
(desktop-lazy-idle-delay 1 "Restore the other buffers 1 second later")
(desktop-lazy-verbose nil "Be silent about lazily opening buffers")
:bind
("C-M-s-k" . desktop-clear)
:config
(desktop-save-mode))
(use-package uniquify