Commit | Line | Data |
---|---|---|
4c05c418 AB |
1 | ;;; bandali-org.el --- bandali's Org setup -*- lexical-binding: t; -*- |
2 | ||
78d731e1 | 3 | ;; Copyright (C) 2018-2022 Amin Bandali |
4c05c418 AB |
4 | |
5 | ;; Author: Amin Bandali <bandali@gnu.org> | |
6 | ;; Keywords: calendar, data, docs, hypermedia, outlines | |
7 | ||
8 | ;; This program is free software; you can redistribute it and/or modify | |
9 | ;; it under the terms of the GNU General Public License as published by | |
10 | ;; the Free Software Foundation, either version 3 of the License, or | |
11 | ;; (at your option) any later version. | |
12 | ||
13 | ;; This program is distributed in the hope that it will be useful, | |
14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | ;; GNU General Public License for more details. | |
17 | ||
18 | ;; You should have received a copy of the GNU General Public License | |
19 | ;; along with this program. If not, see <https://www.gnu.org/licenses/>. | |
20 | ||
21 | ;;; Commentary: | |
22 | ||
23 | ;; My set up for Org (org-mode) and all things Org. | |
24 | ||
25 | ;;; Code: | |
26 | ||
c84be134 | 27 | (with-eval-after-load 'org |
78d731e1 AB |
28 | (setq |
29 | org-src-tab-acts-natively t | |
30 | org-src-preserve-indentation nil | |
31 | org-edit-src-content-indentation 0 | |
32 | org-id-locations-file (b/var "org/id-locations.el") | |
33 | org-link-email-description-format "Email %c: %s" ; %.30s | |
34 | org-highlight-latex-and-related '(entities) | |
35 | org-use-speed-commands t | |
36 | org-startup-folded 'content | |
37 | org-catch-invisible-edits 'show-and-error | |
38 | org-log-done 'time | |
39 | org-pretty-entities t | |
40 | org-agenda-files '("~/usr/org/todos/personal.org" | |
41 | "~/usr/org/todos/habits.org" | |
42 | "~/src/git/masters-thesis/todo.org") | |
43 | org-agenda-start-on-weekday 0 | |
44 | org-agenda-time-leading-zero t | |
45 | org-habit-graph-column 44 | |
46 | org-latex-packages-alist '(("" "listings") ("" "color"))) | |
f7910e3d AB |
47 | (add-to-list 'org-structure-template-alist '("L" . "src emacs-lisp") t) |
48 | (add-to-list 'org-modules 'org-habit) | |
c84be134 | 49 | (custom-set-faces |
c84be134 AB |
50 | '(org-latex-and-related ((t (:foreground "#b294bb"))))) |
51 | ;; local key bindings | |
52 | (define-key org-mode-map (kbd "M-L") #'org-insert-last-stored-link) | |
53 | (define-key org-mode-map (kbd "M-O") #'org-toggle-link-display) | |
54 | ;; hooks | |
74d83601 AB |
55 | ;; `org-indent-mode' doesn't seem to play nice with |
56 | ;; `display-fill-column-indicator'. | |
57 | ;; (add-hook 'org-mode-hook #'org-indent-mode) | |
c84be134 AB |
58 | (add-hook 'org-mode-hook #'auto-fill-mode) |
59 | (add-hook 'org-mode-hook #'flyspell-mode) | |
60 | ||
49ec21e9 AB |
61 | ;; additional export backends |
62 | (require 'ox-md) | |
63 | ||
c84be134 AB |
64 | ;; asynchronous tangle, using emacs-async to asynchronously tangle an |
65 | ;; org file. closely inspired by | |
66 | ;; https://github.com/dieggsy/dotfiles/tree/cc10edf7701958eff1cd94d4081da544d882a28c/emacs.d#dotfiles | |
f7910e3d AB |
67 | (defvar b/show-async-tangle-results nil |
68 | "Keep *emacs* async buffers around for later inspection.") | |
69 | ||
70 | (defvar b/show-async-tangle-time nil | |
71 | "Show the time spent tangling the file.") | |
72 | ||
73 | (defun b/async-babel-tangle () | |
74 | "Tangle org file asynchronously." | |
75 | (interactive) | |
76 | (let* ((file-tangle-start-time (current-time)) | |
77 | (file (buffer-file-name)) | |
78 | (file-nodir (file-name-nondirectory file)) | |
79 | ;; (async-quiet-switch "-q") | |
3d7cc479 AB |
80 | ;; (file-noext (file-name-sans-extension file)) |
81 | ) | |
f7910e3d AB |
82 | (async-start |
83 | `(lambda () | |
84 | (require 'org) | |
85 | (org-babel-tangle-file ,file)) | |
86 | (unless b/show-async-tangle-results | |
87 | `(lambda (result) | |
88 | (if result | |
89 | (message "Tangled %s%s" | |
90 | ,file-nodir | |
91 | (if b/show-async-tangle-time | |
92 | (format " (%.3fs)" | |
93 | (float-time (time-subtract (current-time) | |
94 | ',file-tangle-start-time))) | |
95 | "")) | |
c84be134 AB |
96 | (message "Tangling %s failed" ,file-nodir))))))) |
97 | (add-to-list | |
98 | 'safe-local-variable-values | |
99 | '(eval add-hook 'after-save-hook #'b/async-babel-tangle 'append 'local))) | |
100 | ;; global key bindings | |
101 | (global-set-key (kbd "C-c a o a") #'org-agenda) | |
102 | ||
103 | (with-eval-after-load 'ox-latex | |
78d731e1 AB |
104 | (setq |
105 | org-latex-listings 'listings | |
106 | ;; org-latex-prefer-user-labels t | |
107 | ) | |
c84be134 AB |
108 | (add-to-list 'org-latex-classes |
109 | '("IEEEtran" "\\documentclass[11pt]{IEEEtran}" | |
110 | ("\\section{%s}" . "\\section*{%s}") | |
111 | ("\\subsection{%s}" . "\\subsection*{%s}") | |
112 | ("\\subsubsection{%s}" . "\\subsubsection*{%s}") | |
113 | ("\\paragraph{%s}" . "\\paragraph*{%s}") | |
114 | ("\\subparagraph{%s}" . "\\subparagraph*{%s}")) | |
115 | t) | |
116 | (require 'ox-beamer)) | |
f7910e3d | 117 | |
c84be134 AB |
118 | (with-eval-after-load 'ox-extra |
119 | (declare-function ox-extras-activate "ox-extra" (extras)) | |
120 | (ox-extras-activate '(latex-header-blocks ignore-headlines))) | |
fc9a59fb | 121 | |
f7910e3d | 122 | (provide 'bandali-org) |
4c05c418 | 123 | ;;; bandali-org.el ends here |