Commit | Line | Data |
---|---|---|
4c05c418 AB |
1 | ;;; bandali-org.el --- bandali's Org setup -*- lexical-binding: t; -*- |
2 | ||
3 | ;; Copyright (C) 2018-2020 Amin Bandali | |
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 | ||
f7910e3d AB |
27 | (use-package org |
28 | :config | |
29 | (setq org-src-tab-acts-natively t | |
30 | org-src-preserve-indentation nil | |
31 | org-edit-src-content-indentation 0 | |
32 | org-link-email-description-format "Email %c: %s" ; %.30s | |
33 | org-highlight-latex-and-related '(entities) | |
34 | org-use-speed-commands t | |
35 | org-startup-folded 'content | |
36 | org-catch-invisible-edits 'show-and-error | |
37 | org-log-done 'time) | |
f7910e3d AB |
38 | (add-to-list 'org-structure-template-alist '("L" . "src emacs-lisp") t) |
39 | (add-to-list 'org-modules 'org-habit) | |
40 | :bind | |
41 | (("C-c a o a" . org-agenda) | |
42 | :map org-mode-map | |
43 | ("M-L" . org-insert-last-stored-link) | |
44 | ("M-O" . org-toggle-link-display)) | |
45 | :hook ((org-mode . org-indent-mode) | |
46 | (org-mode . auto-fill-mode) | |
47 | (org-mode . flyspell-mode)) | |
48 | :custom | |
49 | (org-pretty-entities t) | |
50 | (org-agenda-files '("~/usr/org/todos/personal.org" | |
51 | "~/usr/org/todos/habits.org" | |
52 | "~/src/git/masters-thesis/todo.org")) | |
53 | (org-agenda-start-on-weekday 0) | |
54 | (org-agenda-time-leading-zero t) | |
55 | (org-habit-graph-column 44) | |
56 | (org-latex-packages-alist '(("" "listings") ("" "color"))) | |
57 | :custom-face | |
58 | '(org-block-begin-line ((t (:foreground "#5a5b5a" :background "#1d1f21")))) | |
59 | '(org-block ((t (:background "#1d1f21")))) | |
60 | '(org-latex-and-related ((t (:foreground "#b294bb"))))) | |
61 | ||
62 | (use-package ox-latex | |
63 | :after ox | |
64 | :config | |
65 | (setq org-latex-listings 'listings | |
66 | ;; org-latex-prefer-user-labels t | |
67 | ) | |
68 | (add-to-list 'org-latex-classes | |
69 | '("IEEEtran" "\\documentclass[11pt]{IEEEtran}" | |
70 | ("\\section{%s}" . "\\section*{%s}") | |
71 | ("\\subsection{%s}" . "\\subsection*{%s}") | |
72 | ("\\subsubsection{%s}" . "\\subsubsection*{%s}") | |
73 | ("\\paragraph{%s}" . "\\paragraph*{%s}") | |
74 | ("\\subparagraph{%s}" . "\\subparagraph*{%s}")) | |
75 | t) | |
76 | (require 'ox-beamer)) | |
77 | ||
78 | (use-package ox-extra | |
79 | :config | |
80 | (ox-extras-activate '(latex-header-blocks ignore-headlines))) | |
81 | ||
82 | ;; asynchronous tangle, using emacs-async to asynchronously tangle an | |
83 | ;; org file. closely inspired by | |
84 | ;; https://github.com/dieggsy/dotfiles/tree/cc10edf7701958eff1cd94d4081da544d882a28c/emacs.d#dotfiles | |
85 | (with-eval-after-load 'org | |
86 | (defvar b/show-async-tangle-results nil | |
87 | "Keep *emacs* async buffers around for later inspection.") | |
88 | ||
89 | (defvar b/show-async-tangle-time nil | |
90 | "Show the time spent tangling the file.") | |
91 | ||
92 | (defun b/async-babel-tangle () | |
93 | "Tangle org file asynchronously." | |
94 | (interactive) | |
95 | (let* ((file-tangle-start-time (current-time)) | |
96 | (file (buffer-file-name)) | |
97 | (file-nodir (file-name-nondirectory file)) | |
98 | ;; (async-quiet-switch "-q") | |
99 | (file-noext (file-name-sans-extension file))) | |
100 | (async-start | |
101 | `(lambda () | |
102 | (require 'org) | |
103 | (org-babel-tangle-file ,file)) | |
104 | (unless b/show-async-tangle-results | |
105 | `(lambda (result) | |
106 | (if result | |
107 | (message "Tangled %s%s" | |
108 | ,file-nodir | |
109 | (if b/show-async-tangle-time | |
110 | (format " (%.3fs)" | |
111 | (float-time (time-subtract (current-time) | |
112 | ',file-tangle-start-time))) | |
113 | "")) | |
114 | (message "Tangling %s failed" ,file-nodir)))))))) | |
115 | ||
116 | (add-to-list | |
117 | 'safe-local-variable-values | |
118 | '(eval add-hook 'after-save-hook #'b/async-babel-tangle 'append 'local)) | |
119 | ||
fc9a59fb AB |
120 | (use-package org-tanglesync |
121 | :hook (org-mode . org-tanglesync-mode)) | |
122 | ||
f7910e3d | 123 | (provide 'bandali-org) |
4c05c418 | 124 | ;;; bandali-org.el ends here |