-
Notifications
You must be signed in to change notification settings - Fork 1
/
my-org-mode.el
126 lines (110 loc) · 4.51 KB
/
my-org-mode.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
;;; Org Mode
(require 'org)
(require 'ox-md nil t) ; markdown export mode
(unless (boundp 'org-ans1)
(defvar org-ans1)
(defvar org-ans2))
(let ((emacs-mastery-base-dir (concat (getenv "writing") "/books/emacs-mastery/")))
(setq org-publish-project-alias
'(("emacs-mastery"
:base-directory emacs-mastery-base-dir
:publishing-directory (concat emacs-mastery-base-dir "_html/")))))
;;; Org Capture
(setq org-capture-templates
'(("t" "Todo" entry (file+headline "todo.org" "To Do")
"* TODO %?\n %a\n %f"
:prepend t
:empty-lines 1)
("n" "Note" entry (file+headline "notes.org" "Notes")
"* %?\n %U\n %i\n %a"
:prepend t
:empty-lines 1)))
;; Org Mode extras
(defun my-org-execute-src ()
"Saves current Org mode src block to a temp file and executes
it in a compilation buffer by using the source language
name (e.g., \"sh\", \"ruby\") as a command. Obviously doesn't
work for all langauges."
(interactive)
(let* ((props (cadr (org-element-context)))
(p-beg (1- (plist-get props :begin)))
(p-end (1- (plist-get props :end)))
(lang (plist-get props :language))
(tmpfile (make-temp-file "org-src-")))
(write-region p-beg p-end tmpfile)
(compile (concat lang " " tmpfile))))
;; The first three are recommended
(setq org-agenda-include-diary t
org-directory (concat *my-pim-dir* "orgs/")
org-agenda-files (list (concat *my-pim-dir* "orgs/todo.org"))
org-startup-folded 'nofold
org-adapt-indentation nil
org-src-fontify-natively t
org-fontify-whole-heading-line t ; bg color covers whole line
org-default-notes-file (concat *my-pim-dir* "orgs/notes.org")
org-use-sub-superscripts "{}")
(add-hook 'org-mode-hook
(lambda ()
(org-add-link-type "addr" #'address)
(org-add-link-type "date" #'my-goto-calendar-date)
(setq org-export-with-sub-superscripts nil)
(define-key org-mode-map "\C-cr" #'my-org-execute-src)
(define-key org-mode-map "\C-ct" #'org-toggle-link-display)
;; Bind keys normally used for TAGS finding/return
(define-key org-mode-map "\M-." #'org-open-at-point)
(define-key org-mode-map "\M-," #'org-mark-ring-goto)
;; yasnippet mode
;; TODO org-set-local has gone away. Delete this call when all
;; of my Emacs instances are updated
(when-fboundp-call org-set-local 'yas-trigger-key "\t")
(add-to-list 'org-tab-first-hook
(lambda ()
(let ((yas/fallback-behavior 'return-nil))
(yas/expand))))
(when (fboundp #'yas-global-mode)
(define-key yas-keymap "\t" 'yas-next-field-or-maybe-expand))))
;; Modify org-structure-template-alist when Org Mode version is < 9.3.
(when (version< org-version "9.3")
"I like lower-case Org Mode templates. This function returns a
copy of org-structure-template-alist with lower-case template
values."
(setq org-structure-template-alist
(mapcar (lambda (entry)
(list (car entry)
(downcase (cadr entry))))
org-structure-template-alist)))
(when (>= emacs-major-version 24)
(set-face-attribute 'org-level-1 nil
:height 1.15
:bold t)
(set-face-attribute 'org-level-2 nil
:bold t))
;;; ================================================================
;;
;; Org Present Mode
;;
(eval-after-load "org-present"
'(progn
(add-hook 'org-present-mode-hook
(lambda ()
(org-present-big)
(org-present-hide-cursor)
(org-display-inline-images)
(org-present-read-only)))
(add-hook 'org-present-mode-quit-hook
(lambda ()
(org-present-small)
(org-present-show-cursor)
(org-remove-inline-images)
(org-present-read-write)))))
;; Note that there's a bug in the (old) version of Org mode that Org Present
;; depends on that breaks table formatting.
;;
;; https://github.com/rlister/org-present
(defvar *org-present-orig-background* nil)
(add-hook 'org-present-mode-hook
(lambda ()
(set-background-color *org-presentation-background*)))
(add-hook 'org-present-mode-quit-hook
(lambda ()
(set-background-color *current-background*)))