Drop use-package
[~bandali/configs] / lisp / bandali-org.el
CommitLineData
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
c84be134
AB
27(with-eval-after-load 'org
28 (csetq org-src-tab-acts-natively t
29 org-src-preserve-indentation nil
30 org-edit-src-content-indentation 0
31 org-link-email-description-format "Email %c: %s" ; %.30s
32 org-highlight-latex-and-related '(entities)
33 org-use-speed-commands t
34 org-startup-folded 'content
35 org-catch-invisible-edits 'show-and-error
36 org-log-done 'time
37 org-pretty-entities t
38 org-agenda-files '("~/usr/org/todos/personal.org"
39 "~/usr/org/todos/habits.org"
40 "~/src/git/masters-thesis/todo.org")
41 org-agenda-start-on-weekday 0
42 org-agenda-time-leading-zero t
43 org-habit-graph-column 44
44 org-latex-packages-alist '(("" "listings") ("" "color")))
f7910e3d
AB
45 (add-to-list 'org-structure-template-alist '("L" . "src emacs-lisp") t)
46 (add-to-list 'org-modules 'org-habit)
c84be134
AB
47 (custom-set-faces
48 '(org-block-begin-line
49 ((t (:foreground "#5a5b5a" :background "#1d1f21"))))
50 '(org-block ((t (:background "#1d1f21"))))
51 '(org-latex-and-related ((t (:foreground "#b294bb")))))
52 ;; local key bindings
53 (define-key org-mode-map (kbd "M-L") #'org-insert-last-stored-link)
54 (define-key org-mode-map (kbd "M-O") #'org-toggle-link-display)
55 ;; hooks
56 (add-hook 'org-mode-hook #'org-indent-mode)
57 (add-hook 'org-mode-hook #'auto-fill-mode)
58 (add-hook 'org-mode-hook #'flyspell-mode)
59
60 ;; asynchronous tangle, using emacs-async to asynchronously tangle an
61 ;; org file. closely inspired by
62 ;; https://github.com/dieggsy/dotfiles/tree/cc10edf7701958eff1cd94d4081da544d882a28c/emacs.d#dotfiles
f7910e3d
AB
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")
3d7cc479
AB
76 ;; (file-noext (file-name-sans-extension file))
77 )
f7910e3d
AB
78 (async-start
79 `(lambda ()
80 (require 'org)
81 (org-babel-tangle-file ,file))
82 (unless b/show-async-tangle-results
83 `(lambda (result)
84 (if result
85 (message "Tangled %s%s"
86 ,file-nodir
87 (if b/show-async-tangle-time
88 (format " (%.3fs)"
89 (float-time (time-subtract (current-time)
90 ',file-tangle-start-time)))
91 ""))
c84be134
AB
92 (message "Tangling %s failed" ,file-nodir)))))))
93 (add-to-list
94 'safe-local-variable-values
95 '(eval add-hook 'after-save-hook #'b/async-babel-tangle 'append 'local)))
96;; global key bindings
97(global-set-key (kbd "C-c a o a") #'org-agenda)
98
99(with-eval-after-load 'ox-latex
100 (csetq org-latex-listings 'listings
101 ;; org-latex-prefer-user-labels t
102 )
103 (add-to-list 'org-latex-classes
104 '("IEEEtran" "\\documentclass[11pt]{IEEEtran}"
105 ("\\section{%s}" . "\\section*{%s}")
106 ("\\subsection{%s}" . "\\subsection*{%s}")
107 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
108 ("\\paragraph{%s}" . "\\paragraph*{%s}")
109 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
110 t)
111 (require 'ox-beamer))
f7910e3d 112
c84be134
AB
113(with-eval-after-load 'ox-extra
114 (declare-function ox-extras-activate "ox-extra" (extras))
115 (ox-extras-activate '(latex-header-blocks ignore-headlines)))
fc9a59fb 116
f7910e3d 117(provide 'bandali-org)
4c05c418 118;;; bandali-org.el ends here