957417f85475d001f4e47d9c65ee477c3aea9af6
[~bandali/configs] / lisp / bandali-org.el
1 (use-package org
2 :config
3 (setq org-src-tab-acts-natively t
4 org-src-preserve-indentation nil
5 org-edit-src-content-indentation 0
6 org-link-email-description-format "Email %c: %s" ; %.30s
7 org-highlight-latex-and-related '(entities)
8 org-use-speed-commands t
9 org-startup-folded 'content
10 org-catch-invisible-edits 'show-and-error
11 org-log-done 'time)
12 (when (version< org-version "9.3")
13 (setq org-email-link-description-format
14 org-link-email-description-format))
15 (add-to-list 'org-structure-template-alist '("L" . "src emacs-lisp") t)
16 (add-to-list 'org-modules 'org-habit)
17 :bind
18 (("C-c a o a" . org-agenda)
19 :map org-mode-map
20 ("M-L" . org-insert-last-stored-link)
21 ("M-O" . org-toggle-link-display))
22 :hook ((org-mode . org-indent-mode)
23 (org-mode . auto-fill-mode)
24 (org-mode . flyspell-mode))
25 :custom
26 (org-pretty-entities t)
27 (org-agenda-files '("~/usr/org/todos/personal.org"
28 "~/usr/org/todos/habits.org"
29 "~/src/git/masters-thesis/todo.org"))
30 (org-agenda-start-on-weekday 0)
31 (org-agenda-time-leading-zero t)
32 (org-habit-graph-column 44)
33 (org-latex-packages-alist '(("" "listings") ("" "color")))
34 :custom-face
35 '(org-block-begin-line ((t (:foreground "#5a5b5a" :background "#1d1f21"))))
36 '(org-block ((t (:background "#1d1f21"))))
37 '(org-latex-and-related ((t (:foreground "#b294bb")))))
38
39 (use-package ox-latex
40 :after ox
41 :config
42 (setq org-latex-listings 'listings
43 ;; org-latex-prefer-user-labels t
44 )
45 (add-to-list 'org-latex-classes
46 '("IEEEtran" "\\documentclass[11pt]{IEEEtran}"
47 ("\\section{%s}" . "\\section*{%s}")
48 ("\\subsection{%s}" . "\\subsection*{%s}")
49 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
50 ("\\paragraph{%s}" . "\\paragraph*{%s}")
51 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
52 t)
53 (require 'ox-beamer))
54
55 (use-package ox-extra
56 :config
57 (ox-extras-activate '(latex-header-blocks ignore-headlines)))
58
59 ;; asynchronous tangle, using emacs-async to asynchronously tangle an
60 ;; org file. closely inspired by
61 ;; https://github.com/dieggsy/dotfiles/tree/cc10edf7701958eff1cd94d4081da544d882a28c/emacs.d#dotfiles
62 (with-eval-after-load 'org
63 (defvar b/show-async-tangle-results nil
64 "Keep *emacs* async buffers around for later inspection.")
65
66 (defvar b/show-async-tangle-time nil
67 "Show the time spent tangling the file.")
68
69 (defun b/async-babel-tangle ()
70 "Tangle org file asynchronously."
71 (interactive)
72 (let* ((file-tangle-start-time (current-time))
73 (file (buffer-file-name))
74 (file-nodir (file-name-nondirectory file))
75 ;; (async-quiet-switch "-q")
76 (file-noext (file-name-sans-extension file)))
77 (async-start
78 `(lambda ()
79 (require 'org)
80 (org-babel-tangle-file ,file))
81 (unless b/show-async-tangle-results
82 `(lambda (result)
83 (if result
84 (message "Tangled %s%s"
85 ,file-nodir
86 (if b/show-async-tangle-time
87 (format " (%.3fs)"
88 (float-time (time-subtract (current-time)
89 ',file-tangle-start-time)))
90 ""))
91 (message "Tangling %s failed" ,file-nodir))))))))
92
93 (add-to-list
94 'safe-local-variable-values
95 '(eval add-hook 'after-save-hook #'b/async-babel-tangle 'append 'local))
96
97 (provide 'bandali-org)