-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.el
3226 lines (2756 loc) · 130 KB
/
init.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; Init.el --- Daniel's Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;; This is the main entry point for Emacs to load this configuration. The
;; structure is roughly as follows:
;; - first comes some preliminary setup, mostly setting up `package’;
;; - the main activation of the configuration is done in the function
;; `db/run-init’, which is installed in `after-init-hook’; it is thus run
;; after init.el has been read
;; - then comes setting up all the packages that can be used by this
;; configuration; most of these packages are not loaded however, and only
;; configuration hooks are installed (using `use-package’); this way a user
;; can choose in `db/run-init’ which configuration to activate without
;; changing much of the rest of the file.
;; - this file also introduces a new customization group `personal-settings’
;; containing variables (mostly file paths) that must be set to enable some
;; of the provided functionality.
;;; Code:
;; * Preliminaries (constants and path settings)
(defconst emacs-d (file-name-directory
(file-chase-links load-file-name))
"The giant turtle on which the world rests.")
(add-to-list 'load-path (expand-file-name "site-lisp" emacs-d))
(defvar emacs-d-userdata (expand-file-name "private/" emacs-d)
"Directory to store user data in.")
;; Ensure that `emacs-d-userdata' exists as a directory, because we want to
;; store data there.
(unless (file-directory-p emacs-d-userdata)
(make-directory emacs-d-userdata))
(setq custom-file (expand-file-name "custom.el" emacs-d-userdata)
custom-theme-directory (expand-file-name "themes/" emacs-d))
(defconst on-windows (memq system-type '(windows-nt cygwin))
"Non-nil if and only if this instance of Emacs runs on Windows.")
;; * Packages
(setq package-archives
'(("melpa" . "https://melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/")
("melpa-stable" . "https://stable.melpa.org/packages/")
("nongnu" . "https://elpa.nongnu.org/nongnu/")))
(when (< emacs-major-version 27)
;; Before Emacs 27.1, we had to do package initialization ourselves. In Emacs
;; 27.1 and later, it's done directly after loading early-init.el. See
;; https://www.gnu.org/software/emacs/news/NEWS.27.1
(load-file (expand-file-name "early-init.el" emacs-d))
(package-initialize))
(defvar use-package-enable-imenu-support t)
(eval-when-compile
(dolist (package '(bind-key use-package))
(unless (package-installed-p package)
(package-install package))
(require package)))
(setq use-package-always-defer t
use-package-verbose t
use-package-minimum-reported-time 0.01)
(add-to-list 'package-pinned-packages '(use-package . "melpa-stable"))
(add-to-list 'package-pinned-packages '(bind-key . "melpa-stable"))
(put 'use-package 'lisp-indent-function 1)
(put 'use-package 'common-lisp-indent-function 1)
;; * Personal Customization Variables
(use-package db-customize
:demand t
:defines (db/jabber-id
db/important-documents-path
db/path-to-onenote
db/path-to-outlook
db/cert-file-directory
org-working-task-id
org-break-task-id
org-home-task-id
db/org-clock-current-task-file
db/org-default-org-file
db/org-default-work-file
db/org-default-home-file
db/org-default-notes-file
db/org-default-refile-file
db/after-init-load-files))
;; * Core Configuration
(use-package cl-lib
:demand t)
(use-package subr-x
:demand t)
;; Encoding: use UTF-8 everywhere
(set-default-coding-systems 'utf-8)
(prefer-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(setq buffer-file-coding-system 'utf-8)
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))
;; Startup configuration
(setq inhibit-startup-message t
inhibit-default-init t
frame-inhibit-implied-resize t
initial-scratch-message nil
initial-major-mode 'fundamental-mode
ring-bell-function #'ignore
load-prefer-newer nil ; t breaks `org-reload'
use-short-answers nil)
(setq-default fill-column 100)
(setq-default indent-tabs-mode nil)
(setq frame-title-format "emacs")
(use-package help-fns
:defines (help-enable-symbol-autoload))
(setq select-enable-clipboard t
select-enable-primary t
save-interprogram-paste-before-kill t
mouse-yank-at-point t
scroll-conservatively 10
scroll-preserve-screen-position 'always ; Make M-v undo C-v
message-log-max t
inhibit-eol-conversion nil
tab-always-indent 'complete
enable-recursive-minibuffers t
set-mark-command-repeat-pop t
echo-keystrokes 0.1
delete-trailing-lines nil
x-underline-at-descent-line t
visual-line-fringe-indicators '(left-curly-arrow right-curly-arrow)
history-delete-duplicates t
track-eol t
garbage-collection-messages nil
read-process-output-max (* 1024 1024) ; 1mb
next-error-message-highlight t
help-enable-symbol-autoload t
describe-bindings-outline t
redisplay-skip-fontification-on-input t
undo-limit 80000000
async-shell-command-buffer 'new-buffer
byte-compile-warnings '(not docstrings))
(put 'set-goal-column 'disabled nil)
(when (memq system-type '(gnu gnu/linux gnu/kfreebsd))
(setq x-wait-for-event-timeout nil))
(when on-windows
;; Fix: treat memory for display time ... hey, this is Windows, memory doesn’t
;; matter!
(setq inhibit-compacting-font-caches t))
;; don't let the cursor go into minibuffer prompt
(setq minibuffer-prompt-properties '(read-only t
face minibuffer-prompt
cursor-intangible t))
;; Fix: disable gconf settings, as it might interfere with ours, see
;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25228 and
;; https://emacs.stackexchange.com/questions/32641/something-changes-the-default-face-in-my-emacs.
(define-key special-event-map [config-changed-event] 'ignore)
;; Individual package configuration from here on.
(use-package appt
:commands (appt-activate)
:init (setq appt-display-mode-line nil))
(use-package auth-source
:init (setq auth-sources '("~/.authinfo.gpg")
auth-source-save-behavior nil))
(use-package browser-url
:init (setq browse-url-browser-function 'browse-url-generic
browse-url-generic-program "firefox"))
(use-package calc
;; https://florian.adamsky.it/2016/03/31/emacs-calc-for-programmers-and-cs.html
:defines (math-additional-units
math-units-table)
:init (setq math-additional-units
'((bit nil "Bit")
(byte "8 * bit" "Byte")
(bps "bit / s" "Bit per second"))
math-units-table nil))
(use-package calender
:init (setq calendar-date-style 'iso
calendar-time-zone-style 'numeric
calendar-week-start-day 1 ; Monday
calendar-bahai-all-holidays-flag nil
calendar-chinese-all-holidays-flag nil
calendar-christian-all-holidays-flag nil
calendar-islamic-all-holidays-flag nil
calendar-hebrew-all-holidays-flag nil
;; The following list should contain only holidays without work, as it is examined by
;; `db/org-home-time-for-date'.
holiday-general-holidays '((holiday-fixed 1 1 "New Year's Day")
(holiday-fixed 5 1 "Labour Day")
(holiday-fixed 10 3 "German Unity Day")
(holiday-fixed 10 31 "Reformation Day")
(holiday-float 11 3 -1 "Day of Repentance and Prayer" 22))
holiday-other-holidays '((holiday-fixed 2 13 "Jahrestag Zerstörung Dresden 1945")
(holiday-fixed 2 14 "Valentine's Day")
(holiday-fixed 4 1 "April Fools' Day")
(holiday-fixed 5 25 "Towel Day")
(holiday-fixed 6 4 "Tiananmen Massacre 1989")
(holiday-fixed 6 5 "Snowden-Veröffentlichungen 2013")
(holiday-fixed 6 6 "D-Day 1944")
(holiday-fixed 6 8 "Yoneda Appreciation Day")
(holiday-fixed 6 10 "Jahrestag Zerstörung von Oradour-sur-Glane 1944")
(holiday-fixed 6 10 "Jahrestag Massaker von Distomo 1944")
(holiday-fixed 6 16 "Bloomsday")
(holiday-fixed 7 20 "Jahrestag Attentat auf Hitler 1944")
(holiday-fixed 7 21 "Jahrestag der 1. Mondlandung 1969")
(holiday-fixed 7 21 "Jahrestag Massaker von Vassieux-en-Vercors 1944")
(holiday-fixed 7 28 "Start WWI 1914")
(holiday-float 11 4 4 "Thanksgiving")
(holiday-fixed 11 11 "End WWI 1918"))
diary-show-holidays-flag t
calendar-view-holidays-initially-flag nil))
(use-package grep
:commands (rgrep zrgrep)
:bind (:map grep-mode-map
("C-x C-q" . wgrep-change-to-wgrep-mode)
("C-c C-c" . wgrep-finish-edit))
:config (progn
;; I am not quite sure why `grep-read-files' is prompting for file
;; names when asking for a file pattern, so let's just hook it up
;; and replace it with something more straightforward.
(advice-add 'grep-read-files :around #'db/grep-read-files)))
(use-package multisession
:init (setq multisession-directory (expand-file-name "multisession/" emacs-d-userdata)))
(use-package proced
:custom ((proced-tree-flag t)
(proced-auto-update-flag (not on-windows))
(proced-format 'medium)
(proced-auto-update-interval 1)
(proced-goal-attribute nil)
(proced-enable-color-flag t)))
(use-package quail
:init (setq default-input-method "TeX")
:config (add-hook 'input-method-activate-hook
#'db/add-symbols-to-TeX-input-method))
(use-package savehist
:commands (savehist-mode)
:init (setq savehist-file (expand-file-name "savehist" emacs-d-userdata)))
(use-package server
:commands (server-running-p server-start)
:init (setq server-log t))
(use-package tab-bar
:init (setq tab-bar-show t
tab-bar-format '(tab-bar-format-tabs
tab-bar-separator
;; tab-bar-format-align-right
;; current-time-string
))
:config (progn
(tab-bar-history-mode +1)))
(use-package url
:init (setq url-configuration-directory (expand-file-name "url" emacs-d-userdata)))
(use-package window
:init (setq switch-to-buffer-obey-display-actions t
switch-to-buffer-in-dedicated-window 'pop
recenter-positions '(top middle bottom)
display-buffer-base-action '(display-buffer-reuse-window))
:config (progn
(add-to-list 'display-buffer-alist
'("^\\*Async Shell Command*"
(display-buffer-no-window)))
(add-to-list 'display-buffer-alist
'("^\\*Warnings\\*"
(display-buffer-in-side-window)
(side . right)
(slot . 1)
(window-width . 0.33)))
;; Inspired by masteringemacs
(add-to-list 'display-buffer-alist
'("^\\*Help\\*"
(display-buffer-reuse-window
display-buffer-pop-up-window)))
;; Inspired by masteringemacs and
;; https://www.gnu.org/software/emacs/manual/html_node/elisp/Frame-Layouts-with-Side-Windows.html
(add-to-list 'display-buffer-alist
'("^\\*eshell\\*"
display-buffer-in-side-window
(side . bottom)
(slot . -1)
(window-height . 0.33)
(window-parameters . ((no-other-window . t)))))
(add-to-list 'display-buffer-alist
'("^\\*shell\\*"
display-buffer-in-side-window
(side . bottom)
(slot . 1)
(window-height . 0.33)
(window-parameters . ((no-other-window . t)))))))
(use-package winner
:commands (winner-mode winner-undo winner-redo))
;; * Basic External Packages
(use-package crux
:ensure t
:commands (crux-eval-and-replace
crux-smart-open-line-above
crux-kill-whole-line
crux-cleanup-buffer-or-region
crux-delete-buffer-and-file))
(use-package dash
:defer nil
:autoload (-difference)
:config (progn
(global-dash-fontify-mode)
(dash-register-info-lookup)))
(use-package db-utils
:commands (endless/fill-or-unfill
db/delete-trailing-whitespace-maybe
db/run-or-hide-shell
db/gnus
db/org-agenda
db/scratch
db/find-user-init-file
db/run-or-hide-ansi-term
db/ement-connect
db/hex-to-ascii
db/text-to-hex
turn-on-lispy-when-available
turn-on-flycheck-when-file
db/sort-nsm-permanent-settings
endless/colorize-compilation
db/turn-off-local-electric-pair-mode
db/add-symbols-to-TeX-input-method
db/two-monitors-xrandr
db/one-monitor-xrandr
db/pretty-print-xml
db/bookmark-add-external
db/bookmark-add-url
db/lookup-smime-key
db/dired-from-shell-command
db/system-open
db/switch-to-dark-theme
db/switch-to-light-theme
keyboard-quit-context+
db/convert-lf-to-crlf-in-buffer
db/convert-crlf-to-lf-in-buffer
db/replace-variables-in-string
db/dired-ediff-files
db/grep-read-files
db/make-selector-from-table-header
db/get-library-version
db/dired-back-to-top
db/dired-jump-to-bottom
db/dired-get-size))
(use-package db-hydras
:commands (hydra-toggle/body
hydra-zoom/body
hydra-rectangle/body
db/define-feature-shortcuts-hydra
hydra-feature-shortcuts/body))
(use-package exec-path-from-shell
:pin "melpa-stable"
:commands (exec-path-from-shell-copy-envs))
(use-package helpful
:pin "melpa-stable"
:ensure t)
(use-package hydra
:pin "melpa-stable"
:ensure t)
;; `lv' is a dependency of `hydra'
(add-to-list 'package-pinned-packages '(lv . "melpa-stable"))
(use-package projectile
:ensure t
:commands (projectile-mode)
:defines (projectile-known-projects)
:bind (:map projectile-mode-map ("C-c p" . projectile-command-map))
:init (setq projectile-switch-project-action 'projectile-dired
projectile-completion-system 'helm
projectile-ignored-project-function #'file-remote-p
projectile-create-missing-test-files t
projectile-known-projects-file (expand-file-name "projectile-bookmarks.eld"
emacs-d-userdata)
projectile-cache-file (expand-file-name "projectile.cache"
emacs-d-userdata))
:diminish projectile-mode)
;; * Text editing
(setq sentence-end-double-space t)
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(put 'narrow-to-region 'disabled nil)
(put 'scroll-left 'disabled nil)
(use-package abbrev
:init (setq save-abbrevs 'silently
abbrev-file-name (expand-file-name "abbrev_defs" emacs-d-userdata))
:diminish abbrev-mode)
(use-package dictionary
:init (setq dictionary-server "dict.org"))
(use-package electric
:commands (electric-quote-mode))
(use-package elec-pair
:commands (electric-pair-mode)
:config (progn
(add-to-list 'electric-pair-pairs '(?“ . ?”))
(add-to-list 'electric-pair-text-pairs '(?“ . ?”))
(add-to-list 'electric-pair-pairs '(?„ . ?“))
(add-to-list 'electric-pair-text-pairs '(?„ . ?“))))
(use-package flyspell
:commands (flyspell-mode turn-on-flyspell)
:config (progn
(unbind-key "C-M-i" flyspell-mode-map)
(unbind-key "C-c $" flyspell-mode-map)))
(use-package key-chord
:ensure t
:commands (key-chord-mode)
:config (progn
(key-chord-define-global "``" "“")
(key-chord-define-global "''" "”")
(key-chord-define-global ",," "„")))
(use-package multiple-cursors
:pin "melpa-stable"
:ensure t
:commands (mc/edit-lines
mc/mark-next-like-this
mc/mark-previous-like-this
mc/mark-all-like-this))
(use-package olivetti
:ensure t
:commands (olivetti-mode)
:preface (progn
(defun turn-on-olivetti-mode ()
"Turn on `olivetti-mode'."
(interactive)
(olivetti-mode 1))
(defun turn-off-olivetti-mode ()
"Turn off `olivetti-mode'."
(interactive)
(olivetti-mode -1)))
:init (setq-default olivetti-body-width 0.618034))
(use-package undo-tree
:ensure t
:commands (global-undo-tree-mode
undo
undo-tree-redo)
:init (setq undo-tree-visualizer-timestamps t
undo-tree-visualizer-diff t
undo-tree-auto-save-history nil
undo-tree-history-directory-alist `(("." . ,(expand-file-name "ebackup/" emacs-d))))
:diminish undo-tree-mode)
(use-package wgrep
:ensure t
:commands (wgrep-finish-edit
wgrep-change-to-wgrep-mode))
(use-package yasnippet
:commands (yas-minor-mode-on
yas-minor-mode
yas-global-mode
yas-reload-all)
:ensure t
:diminish yas-minor-mode
:config (yas-reload-all))
;; * Org
(use-package db-org
:commands (db/check-special-org-files-in-agenda
db/verify-refile-target
db/find-parent-task
db/ensure-running-clock
db/save-current-org-task-to-file
db/org-update-frame-title-with-current-clock
db/org-clock-out
db/org-clock-in-break-task
db/org-clock-in-home-task
db/org-clock-in-work-task
db/show-current-org-task
db/org-remaining-effort-of-current-item
db/org-cmp-remaining-effort
org-dblock-write:db/org-workload-report
db/org-home-time-for-date
endless/org-ispell
db/org-agenda-list-deadlines
db/org-agenda-insert-active-filters
hydra-org-agenda-view/body
db/org-agenda-insert-efforts
db/org-eval-subtree-no-confirm
db/org-timestamp-difference
db/org-capture-code-snippet
hydra-org-clock/body
hydra-org-jump/body
hydra-org-custom/body
db/make-org-capture-frame
db/org-onenote-open
db/org-outlook-open
db/org-rfc-open
db/org-cleanup-continuous-clocks
db/find-csv-in-org
db/org-mark-current-default-task
db/org-clocktable-write-with-threshold
db/export-diary
db/org-insert-checklist
db/org-copy-body-from-item-to-point
db/org-find-links-to-current-item
db/org-add-link-to-other-item
db/org-add-link-to-current-clock
hydra-org-linking/body
org-dblock-write:db/org-backlinks
db/org-clock-goto-first-open-checkbox
org-password-manager-get-password-by-id))
;; This is to make the byte-compiler happy about setting some variables later on
;; that are defined in those packages.
(use-package org-attach)
(use-package org-id)
(use-package org-goto)
(use-package org
:pin "gnu"
:bind (:map org-mode-map
([remap org-return] . (lambda () (interactive) (org-return :indent)))
([remap org-clock-goto] . db/org-clock-goto-first-open-checkbox))
:autoload (org-get-todo-state
org-entry-get)
:commands (org-return)
:init (progn
(setq org-deadline-warning-days 14
org-read-date-popup-calendar t
org-insert-heading-respect-content t
org-adapt-indentation nil
org-edit-timestamp-down-means-later t
org-archive-location "%s_archive.gpg::"
org-image-actual-width nil
org-imenu-depth 10
org-footnote-section nil
org-log-into-drawer "LOGBOOK"
org-log-reschedule 'note
org-log-redeadline 'note
org-log-refile 'note
org-log-note-clock-out nil
org-log-done 'note
org-clone-delete-id t
org-fold-catch-invisible-edits 'show-and-error
org-M-RET-may-split-line '((default . nil))
org-highlight-latex-and-related '(latex)
org-use-sub-superscripts '{}
org-src-fontify-natively t
org-src-preserve-indentation t
org-src-tab-acts-natively nil
org-ellipsis "↲"
org-fontify-done-headline nil
org-cycle-separator-lines 2
org-special-ctrl-a/e t
org-highlight-latex-and-related nil
org-attach-store-link-p 'attached
org-attach-auto-tag nil
org-bookmark-names-plist nil
org-goto-interface 'outline-path-completion
org-id-link-to-org-use-id t
org-blank-before-new-entry '((heading . t)
(plain-list-item . auto))
org-duration-format '(("y") ("w") ("d") (special . h:mm))
org-treat-S-cursor-todo-selection-as-state-change nil
org-global-properties
'(("Effort_ALL" . "0:00 0:05 0:10 0:15 0:30 0:45 1:00 2:00 3:00 4:00 6:00 8:00"))
org-columns-default-format
"%80ITEM(Task) %10Effort(Effort) %10CLOCKSUM")
;; Keywords and Tags
(setq org-todo-keywords
'((sequence "TODO(t@)" "CONT(n!)" "REFINE(f!)" "|" "DONE(d@)" "CANC(c@)" "MRGD(m@)")
(sequence "GOTO(g@)" "ATTN(a!)" "|" "DONE(d@)")
(sequence "READ(r@)" "CONT(n!)" "|" "DONE(d@)")
(sequence "DELG(e@)" "WAIT(w@)" "HOLD(h@)" "|" "CANC(c@)"))
org-todo-state-tags-triggers
'(("WAIT" ("HOLD") ("WAIT" . t))
("DELG" ("HOLD") ("WAIT" . t))
("HOLD" ("HOLD" . t) ("WAIT"))
(done ("HOLD") ("WAIT"))
("TODO" ("HOLD") ("WAIT") ("DATE") ("READ"))
("READ" ("READ" . t) ("DATE") ("HOLD") ("WAIT"))
("GOTO" ("DATE" . t) ("READ") ("HOLD") ("WAIT"))
("CONT" ("DATE") ("HOLD") ("WAIT") ("READ"))
("REFINE" ("DATE") ("HOLD") ("WAIT") ("READ"))
("ATTN" ("DATE" . t) ("READ") ("HOLD") ("WAIT"))
("" ("HOLD") ("WAIT") ("DATE") ("READ")))
org-tag-alist
'((:startgroup)
("WORK" . ?w)
("HOME" . ?h)
("FUN" . ?f)
("UNTAGGED" . ?u)
(:endgroup)
("NOTE" . ?n)
(:startgroup)
("PERIODIC" . ?p)
("NOP" . ?o)
("TOPIC" . ?t)
("TEMPLATE" . ?l)
("GOAL" . ?g)
(:endgroup))
org-tags-exclude-from-inheritance
'("NOP" "TOPIC" "GOAL")
org-tags-column -85
org-fast-tag-selection-single-key 'expert)
;; Faces
(setq org-todo-keyword-faces
'(("TODO" :foreground "red" :weight normal)
("GOTO" :foreground "red" :weight normal)
("READ" :foreground "red" :weight normal)
("CONT" :foreground "DeepSkyBlue" :weight normal)
("ATTN" :foreground "DeepSkyBlue" :weight normal)
("DONE" :foreground "forest green" :weight normal)
("MRGD" :foreground "dark cyan" :weight normal)
("DELG" :foreground "dark orange" :weight normal)
("REFINE" :foreground "tomato" :weight normal)
("WAIT" :foreground "orange" :weight normal)
("HOLD" :foreground "magenta" :weight normal)
("CANC" :foreground "lime green" :weight normal))
org-priority-faces
'((?A . (:foreground "Red" :weight bold))
(?B . (:foreground "firebrick"))
(?C . (:foreground "tomato"))))
;; Refiling
(setq org-refile-targets '((org-agenda-files . (:maxlevel . 9))
(nil . (:maxlevel . 9))
(db/org-default-notes-file . (:maxlevel . 9)))
org-refile-use-outline-path 'buffer-name
org-refile-use-cache nil
org-refile-allow-creating-parent-nodes 'confirm
org-indirect-buffer-display 'current-window
org-outline-path-complete-in-steps nil
org-refile-target-verify-function 'db/verify-refile-target)
;; Babel
(setq org-babel-load-languages '((shell . t)
(emacs-lisp . t)
(sql . t)))
;; Link shortcuts (some taken from the documentation)
(setq org-link-abbrev-alist
'(("wpen" . "https://en.wikipedia.org/wiki/")
("wpde" . "https://de.wikipedia.org/wiki/")
("ddg" . "https://duckduckgo.com/?q=%s")
("omap" . "https://nominatim.openstreetmap.org/search?q=%s&polygon=1")
("github" . "https://github.com/")
("gitlab" . "https://gitlab.com/"))))
:config (progn
;; Some hooks from text-mode-hook, Org mode does not seem to run those?
(add-hook 'org-mode-hook 'page-break-lines-mode)
(add-hook 'org-mode-hook 'turn-on-auto-fill)
;; Hide drawers by default when cycling items
(add-hook 'org-cycle-hook #'org-cycle-hide-drawers)
;; Statically color links indepedently of whether the file exists or
;; not (we could add different faces to highlight non-existing
;; files, but this turns out to be slow on Windows, and we can use
;; `org-lint' to check this when necessary)
(org-link-set-parameters "file" :face 'org-link)
;; File Apps
(add-to-list 'org-file-apps '(directory . emacs))
(add-to-list 'org-file-apps '("\\.docx?\\'" . default))
(add-to-list 'org-file-apps '("\\.pptx?\\'" . default))
(add-to-list 'org-file-apps '("\\.xlsx?\\'" . default))
(when (eq system-type 'cygwin)
(add-to-list 'org-file-apps '(t . "cygstart %s") t))
;; Custom link types
(org-link-set-parameters "rfc" :follow #'db/org-rfc-open)
(org-link-set-parameters "cve" :follow #'(lambda (number)
(browse-url
(format "https://www.cve.org/CVERecord?id=CVE-%s"
number))))
(when (eq system-type 'windows-nt)
(org-link-set-parameters "onenote" :follow #'db/org-onenote-open)
(org-link-set-parameters "outlook" :follow #'db/org-outlook-open))
;; Mark some org mode regions to be skipped by ispell
(add-hook 'org-mode-hook #'endless/org-ispell)
;; Some timers
(unless (memq #'org-clock-save
(mapcar #'timer--function timer-list))
(run-with-timer 0 3600 #'org-clock-save))
;; Hack: The default implementation is too slow, because it is
;; parsing all properties of an entry by default. Let’s simplify
;; this to only parse what we are looking for. This makes tag
;; search *much* faster!
(when (version<= org-version "9.5.5")
(with-eval-after-load 'org
(define-advice org-cached-entry-get (:around
(orig-fun pom property)
speed-up-cache-lookup)
(ignore orig-fun)
(if (or (eq t org-use-property-inheritance)
(and (stringp org-use-property-inheritance)
(let ((case-fold-search t))
(string-match-p org-use-property-inheritance property)))
(and (listp org-use-property-inheritance)
(member-ignore-case property org-use-property-inheritance)))
;; Caching is not possible, check it directly.
(org-entry-get pom property 'inherit)
;; This is different in the original implementation
(org-entry-get pom property)))))
;; Fix (Org 9.5.5): the variable `org-time-was-given' dynamically
;; bound to signify when `org-read-date-analyze' has found a hh:mm
;; part; it's only considered, however, when it has previously been
;; bound, resulting in some prior calls of `org-read-date' to ignore
;; the hh:mm part. So let's bind this variable now to make things
;; work.
(defvar org-time-was-given nil)))
(use-package org-cycle
:autoload (org-cycle-hide-drawers)
:init (setq org-cycle-include-plain-lists 'integrate))
(use-package org-lint
:autoload (org-lint-checker-name)
:config (progn
;; Yes, this is ugly, but I would like to get rid of checking for
;; obsolete percentage encoding in URLs without loosing the other
;; checkers.
(setq org-lint--checkers (cl-remove-if #'(lambda (c)
(eq (org-lint-checker-name c)
'percent-encoding-link-escape))
org-lint--checkers))))
;; Drag-and-Drop images into org-mode buffer
(use-package org-download
:commands (org-download-yank
org-download-screenshot
org-download-clipboard)
:init (setq org-download-method 'attach))
;; Extended query language and dynamic blocks
(use-package org-ql
:pin "melpa-stable"
:ensure t
:commands (org-ql-view
org-ql-search
org-dblock-write:org-ql)
;; `org-ql-search' defines the dblock features of `org-ql' but is not loaded
;; by default, so let's do this here; note that this implicitly loads
;; `org-ql-view' as well.
:config (require 'org-ql-search))
(use-package ol
:init (setq org-link-keep-stored-after-insertion t)
:commands (org-store-link)
:autoload (org-link-set-parameters)
:config (progn
;; Allow additional link targets
(require 'ol-man) ; manpages
(with-demoted-errors "Cannot load package: %s"
(require 'orgit)) ; magit buffers
(when (version< (org-version) "9.7")
;; Pushing already stored links to the front of `org-stored-links' became default
;; behavior in Org 9.7, the below code is thus only needed for older versions.
(define-advice org-store-link (:around
(orig-func &rest args)
db/org--push-new-links-to-beginning)
"Ensure that new links in `org-store-link' are always at the beginning."
;; The idea here is to store the list of already known links,
;; stored in `org-stored-links', and call `org-store-link' with an
;; empty value of `org-stored-links'. This way, the link to the
;; current item is store in any case, and we prepend these new
;; values (can be more than one if CUSTOM_ID is set) to the old
;; list of links. We also remove the newly prepended links from
;; the list of already known links.
(let ((org-stored-links--original org-stored-links)
(org-stored-links--new nil)
(org-store-link--return-value nil))
(let ((org-stored-links nil))
;; This is the actual call to `org-store-link', which may (and
;; usually will) update `org-stored-links'. Note that the new
;; value of `org-stored-links' is only available after
;; `org-store-link' as finished, which is why we make two
;; separate calls to `setq' here instead of only one.
(setq org-store-link--return-value (apply orig-func args))
(setq org-stored-links--new org-stored-links))
;; Note: `org-stored-links--new' might still be nil after
;; calling `org-store-link', as under some circumstances (and
;; only when the `interactive?' argument to `org-store-link' is
;; non-nil), `org-store-link' may only return a link and not
;; update `org-stored-links'; in this case, we do not have to
;; touch the original value of `org-stored-links' at all.
(unless (null org-stored-links--new)
(setq org-stored-links (nconc org-stored-links--new
(cl-remove-if #'(lambda (x)
(member x org-stored-links--new))
org-stored-links--original))))
org-store-link--return-value)))
(define-advice org-link-make-string (:around
(orig-func link &optional description)
db/org--remove-statistics-cookie-from-link-descriptions)
"Remove statistics cookies from link descriptions.
Such cookies get updated with other statistics cookies and
quickly loose their meaning.
Temporary fix: when the description ends on a closing
bracket (ignoring trailing whitespace) after the statistics
cookie has been removed, add a non-breaking space to the end.
This is to fix the current alignment of Org tables, which counts
a zero-width character, which is used to escape the end of an Org
link, as one character but does not adjust the width of the table
accordingly."
(funcall orig-func
link
(when description
;; Inspired by `org--get-outline-path-1':
(->> description
(replace-regexp-in-string "\\[[0-9]*%\\]\\|\\[[0-9]+/[0-9]+\\]\\|\\[/\\]" "")
(replace-regexp-in-string "\\]\s-*$" "] ") ; XXX temporary
(org-trim)))))))
(use-package ol-bbdb
:config (add-to-list 'org-bbdb-anniversary-format-alist
(cons "day-of-death"
#'(lambda (name years suffix)
(format "Day of Death: [[bbdb:%s][%s (%s%s)]]"
name name years suffix)))))
(use-package org-clock
:commands (org-clock-save)
:init (progn
(setq org-clock-history-length 35
org-clock-in-resume t
org-clock-into-drawer t
org-clock-idle-time nil
org-clock-out-remove-zero-time-clocks t
org-clock-out-when-done '("DONE" "CANC" "MRGD" "WAIT" "HOLD")
org-clock-auto-clock-resolution 'when-no-clock-is-running
org-clock-mode-line-total 'auto
org-clock-report-include-clocking-task t
org-clock-in-switch-to-state #'(lambda (_)
(when (not
(and (boundp 'org-capture-mode)
org-capture-mode))
(cond
((member (org-get-todo-state)
(list "TODO" "READ"))
"CONT")
((member (org-get-todo-state)
(list "GOTO"))
"ATTN"))))
org-clock-persist t
org-clock-persist-file (expand-file-name "org-clock-save.el" emacs-d-userdata)
org-clock-persist-query-resume nil
org-clock-ask-before-exiting nil
org-time-stamp-rounding-minutes '(1 1))
;; On Windows, we don't have dbus to show notifications; default to
;; `message' instead
(when on-windows
(setq org-show-notification-handler #'message)))
:config (progn
(org-clock-persistence-insinuate)
(add-hook 'org-clock-in-hook #'db/org-mark-current-default-task)
(add-hook 'org-clock-in-hook #'db/org-update-frame-title-with-current-clock)
;; Clock in default task if no other task is given
(add-hook 'org-clock-out-hook #'db/ensure-running-clock 'append)
;; Communicate the currently clocked in task to the outside world
(add-hook 'org-clock-in-hook #'db/save-current-org-task-to-file)))
;; Agenda
(use-package org-agenda
:commands (org-agenda
org-agenda-redo-all)
:bind (:map org-agenda-mode-map
("i" . org-agenda-clock-in)
("v" . hydra-org-agenda-view/body)
([remap org-clock-goto] . db/org-clock-goto-first-open-checkbox)
([remap org-agenda-redo-all] . org-agenda-redo))
:init (setq org-agenda-include-diary t
org-agenda-span 1
org-agenda-insert-diary-strategy 'top-level
org-agenda-sorting-strategy '((agenda time-up priority-down user-defined-up category-keep)
(todo priority-down user-defined-up category-keep)
(tags priority-down user-defined-up category-keep)
(search priority-down user-defined-up category-keep))
org-agenda-cmp-user-defined #'db/org-cmp-remaining-effort
org-agenda-window-setup 'current-window
org-agenda-restore-windows-after-quit t
org-agenda-compact-blocks nil
org-agenda-todo-ignore-with-date nil
org-agenda-todo-ignore-deadlines nil
org-agenda-todo-ignore-scheduled nil
org-agenda-todo-ignore-timestamp nil
org-agenda-skip-deadline-if-done t
org-agenda-skip-scheduled-if-done t
org-agenda-skip-timestamp-if-done t
org-agenda-skip-scheduled-if-deadline-is-shown 'not-today
org-agenda-tags-todo-honor-ignore-options t
org-agenda-start-with-log-mode nil
org-agenda-log-mode-items '(closed)
org-agenda-remove-tags nil
org-agenda-sticky nil
org-agenda-inhibit-startup nil
org-agenda-tags-todo-honor-ignore-options t
org-agenda-dim-blocked-tasks nil
org-enforce-todo-checkbox-dependencies t
org-enforce-todo-dependencies t
org-agenda-use-time-grid t
org-agenda-persistent-filter t
org-agenda-search-headline-for-time nil