diff options
Diffstat (limited to '.emacs.d/jd/jd-org.el')
-rwxr-xr-x | .emacs.d/jd/jd-org.el | 198 |
1 files changed, 198 insertions, 0 deletions
diff --git a/.emacs.d/jd/jd-org.el b/.emacs.d/jd/jd-org.el new file mode 100755 index 0000000..cd05d72 --- /dev/null +++ b/.emacs.d/jd/jd-org.el | |||
@@ -0,0 +1,198 @@ | |||
1 | ;;; Dotfiles --- Jakub Dlugosz emacs config | ||
2 | ;;; Commentary: | ||
3 | |||
4 | ;;; Code: | ||
5 | |||
6 | (defvar jd/org-home "~/Documents/Org") | ||
7 | (defvar jd/org-roam-home (concat jd/org-home "/roam")) | ||
8 | (defvar jd/org-roam-daily-home (concat jd/org-home "/roam/daily")) | ||
9 | |||
10 | (defun jd/org-mode-init () | ||
11 | (org-indent-mode) | ||
12 | (variable-pitch-mode 1) | ||
13 | (visual-line-mode 1)) | ||
14 | |||
15 | (defun jd-emacs/org-insert-date (&optional date) | ||
16 | (let ((d (or date "+0d"))) | ||
17 | (org-insert-time-stamp (org-read-date nil t d)))) | ||
18 | |||
19 | (jd/use-package org "emacs-org" | ||
20 | :pin org | ||
21 | :commands (org-capture org-agenda) | ||
22 | :hook (org-mode . jd/org-mode-init) | ||
23 | :config | ||
24 | (setq org-directory (file-truename "~/Documents/Org/")) | ||
25 | (setq org-mobile-inbox-for-pull (concat org-directory "flagged.org")) | ||
26 | (setq org-mobile-directory "~/Dropbox/Apps/MobileOrg") | ||
27 | (setq org-agenda-files | ||
28 | '("Tasks.org")) | ||
29 | (setq org-ellipsis " ▾") | ||
30 | (setq org-agenda-start-with-log-mode t) | ||
31 | (setq org-log-done 'time) | ||
32 | (setq org-log-into-drawer t) | ||
33 | (setq org-return-follows-link t) | ||
34 | (setq org-capture-templates | ||
35 | `(("t" "Tasks / Projects") | ||
36 | ("tt" "Task" entry (file+olp "Tasks.org" "Inbox") | ||
37 | "* TODO %?\n %t\n %a\n %i" :empty-lines 1) | ||
38 | ("tT" "Task for tomorow" entry (file+olp "Tasks.org" "Inbox") | ||
39 | "* TODO %?\n %t\n SCHEDULED: %(jd-emacs/org-insert-date \"+1d\")>\n %a\n %i" :empty-lines 1) | ||
40 | |||
41 | ("m" "Metrics Capture") | ||
42 | ("mm" "Metrics" table-line (file+headline "Metrics.org" "Metrics") | ||
43 | "| %U | %^{Weight} | %^{Waist} | %^{Notes} |" :kill-buffer t) | ||
44 | ("sh" "School Homework" entry (file+olp "school/todo(jd-emacs/org-insert-date \"1\").org")))) | ||
45 | |||
46 | (setq org-latex-listings 'minted | ||
47 | org-latex-packages-alist '(("" "minted")) | ||
48 | org-latex-pdf-process | ||
49 | '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f" | ||
50 | "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f")) | ||
51 | (require 'org-tempo) | ||
52 | |||
53 | (jd/leader-key-def | ||
54 | "o" '(:ignore t :which-key "Open/Org") | ||
55 | "oc" '(org-capture :which-key "Open org-capture") | ||
56 | "oop" '(org-mobile-pull :which-key "Org mobile pull") | ||
57 | "ooP" '(org-mobile-push :which-key "Org mobile push") | ||
58 | "oa" '(org-agenda :which-key "Open org-agenda")) | ||
59 | |||
60 | (defun jd/org-font-setup () | ||
61 | ;; Replace list hyphen with dot | ||
62 | (font-lock-add-keywords 'org-mode | ||
63 | '(("^ *\\([-]\\) " | ||
64 | (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•-")))))) | ||
65 | |||
66 | ;; Set faces for heading levels | ||
67 | (dolist (face '((org-level-1 . 1.3) | ||
68 | (org-level-2 . 1.2) | ||
69 | (org-level-3 . 1.1) | ||
70 | (org-level-4 . 1.0) | ||
71 | (org-level-5 . 1.0) | ||
72 | (org-level-6 . 1.0) | ||
73 | (org-level-7 . 1.0) | ||
74 | (org-level-8 . 1.0))) | ||
75 | (set-face-attribute (car face) nil :font "Terminus" :weight 'Bold :height (cdr face))) | ||
76 | |||
77 | ;; Ensure that anything that should be fixed-pitch in Org files appears that way | ||
78 | (set-face-attribute 'org-block nil :font "Terminus" :inherit 'fixed-pitch :height 100) | ||
79 | (set-face-attribute 'org-table nil :inherit 'fixed-pitch) | ||
80 | (set-face-attribute 'org-formula nil :inherit 'fixed-pitch) | ||
81 | (set-face-attribute 'org-code nil :inherit '(shadow fixed-pitch)) | ||
82 | (set-face-attribute 'org-table nil :font "Terminus" :inherit '(shadow fixed-pitch)) | ||
83 | (set-face-attribute 'org-verbatim nil :inherit '(shadow fixed-pitch)) | ||
84 | (set-face-attribute 'org-special-keyword nil :inherit '(font-lock-comment-face fixed-pitch)) | ||
85 | (set-face-attribute 'org-meta-line nil :inherit '(font-lock-comment-face fixed-pitch)) | ||
86 | (set-face-attribute 'org-checkbox nil :inherit 'fixed-pitch) | ||
87 | (set-face-attribute 'line-number nil :inherit 'fixed-pitch) | ||
88 | (set-face-attribute 'line-number-current-line nil :inherit 'fixed-pitch)) | ||
89 | |||
90 | (with-eval-after-load 'org (jd/org-font-setup)) | ||
91 | |||
92 | (defun jd-emacs/org-timer-stop () | ||
93 | (start-process-shell-command "notify-send" nil "notify-send Zakonczono odliczanie")) | ||
94 | |||
95 | |||
96 | (add-hook 'org-timer-stop-hook #'jd-emacs/org-timer-stop) | ||
97 | |||
98 | (defun jd/org-tempo-setup () | ||
99 | (add-to-list 'org-structure-template-alist '("s" . "src")) | ||
100 | (add-to-list 'org-structure-template-alist '("sql" . "src sql")) | ||
101 | (add-to-list 'org-structure-template-alist '("sh" . "src sh")) | ||
102 | (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp")) | ||
103 | (add-to-list 'org-structure-template-alist '("li" . "src lisp")) | ||
104 | (add-to-list 'org-structure-template-alist '("sc" . "src scheme")) | ||
105 | (add-to-list 'org-structure-template-alist '("ts" . "src typescript")) | ||
106 | (add-to-list 'org-structure-template-alist '("py" . "src python")) | ||
107 | (add-to-list 'org-structure-template-alist '("go" . "src go")) | ||
108 | (add-to-list 'org-structure-template-alist '("yaml" . "src yaml"))) | ||
109 | |||
110 | (with-eval-after-load 'org-tempo (jd/org-tempo-setup)) | ||
111 | |||
112 | (org-babel-do-load-languages | ||
113 | 'org-babel-load-languages | ||
114 | '((emacs-lisp . t) | ||
115 | (python . t))) | ||
116 | |||
117 | (defun jd/org-babel-tangle-config () | ||
118 | (when (string-equal (file-name-directory (buffer-file-name)) | ||
119 | (expand-file-name "~/dotfiles/")) | ||
120 | ;; Dynamic scoping to the rescue | ||
121 | (let ((org-confirm-babel-evaluate nil)) | ||
122 | (org-babel-tangle)))) | ||
123 | |||
124 | (add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'jd/org-babel-tangle-config))) | ||
125 | |||
126 | (defun jd/org-mode-visual-fill () | ||
127 | (setq visual-fill-column-width 100 | ||
128 | visual-fill-column-center-text t) | ||
129 | (visual-fill-column-mode 1))) | ||
130 | |||
131 | ;; (jd/use-package evil-org "emacs-evil-org" | ||
132 | ;; :after org | ||
133 | ;; :hook (org-mode . (lambda () evil-org-mode)) | ||
134 | ;; :config | ||
135 | ;; (require 'evil-org-agenda) | ||
136 | ;; (evil-org-agenda-set-keys)) | ||
137 | |||
138 | (jd/use-package visual-fill-column "emacs-visual-fill-column" | ||
139 | :hook (org-mode . jd/org-mode-visual-fill)) | ||
140 | |||
141 | (jd/use-package org-superstar "emacs-org-superstar" | ||
142 | :hook (org-mode . org-superstar-mode) | ||
143 | :init | ||
144 | (setq org-superstar-special-todo-items t) | ||
145 | (setq org-superstar-remove-leading-stars t) | ||
146 | (setq org-superstar-headline-bullets-list '("◉" "○" "●" "○" "●" "○" "●"))) | ||
147 | |||
148 | ; (jd/add-package-to-manifest "emacs-emacsql-sqlite3") | ||
149 | (jd/use-package org-roam "emacs-org-roam" | ||
150 | :custom | ||
151 | (org-roam-directory (file-truename jd/org-roam-home)) | ||
152 | :bind (("C-c n l" . org-roam-buffer-toggle) | ||
153 | ("C-c n f" . org-roam-node-find) | ||
154 | ("C-c n g" . org-roam-graph) | ||
155 | ("C-c n i" . org-roam-node-insert) | ||
156 | ("C-c n c" . org-roam-capture) | ||
157 | ;; Dailies | ||
158 | ("C-c n j" . org-roam-dailies-capture-today)) | ||
159 | :bind-keymap | ||
160 | ("C-c n d" . org-roam-dailies-map) | ||
161 | :config | ||
162 | (defun jd/org-roam-filter-by-tag (tag-name) | ||
163 | (lambda (node) | ||
164 | (member tag-name (org-roam-node-tags node)))) | ||
165 | |||
166 | (defun jd/org-roam-list-notes-by-tag (tag-name) | ||
167 | (mapcar #'org-roam-node-file | ||
168 | (seq-filter | ||
169 | (jd/org-roam-filter-by-tag tag-name) | ||
170 | (org-roam-node-list)))) | ||
171 | |||
172 | (defun jd/org-roam-refreshagenda-list () | ||
173 | (interactive) | ||
174 | (setq org-agenda-files (org-roam-list-files))) | ||
175 | |||
176 | (setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag))) | ||
177 | (setq org-roam-capture-templates | ||
178 | '(("a" "workstuff" plain (file (concat org-roam-directory "/work")) | ||
179 | :target (file+head "work/%<%Y%m%d%H%M%S>-${slug}.org" | ||
180 | "#+title: ${title}\n") :unnarrowed t) | ||
181 | ("b" "research" plain (file "~/Documents/roam/study/templates/research.org") | ||
182 | :target (file+head "study/%<%Y%m%d%H%M%S>-${slug}.org" | ||
183 | "#+title: ${title}\n") :unnarrowed t) | ||
184 | ("s" "School" plain nil | ||
185 | :target (file+head | ||
186 | "school/%<%Y%m%d%H%M%S>-${slug}.org" | ||
187 | "#+title: ${title}\n") | ||
188 | :unnarrowed t) | ||
189 | ("d" "default" plain nil | ||
190 | :target (file+head "%<%Y%m%d%H%M%S>-${slug}.org" | ||
191 | "#+title: ${title}\n") :unnarrowed t) | ||
192 | )) | ||
193 | |||
194 | (org-roam-db-autosync-mode)) | ||
195 | |||
196 | (provide 'jd-org) | ||
197 | |||
198 | ;;; jd-org.el ends here | ||