-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathorg-config.el
208 lines (168 loc) · 7.16 KB
/
org-config.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
;;; org-config.el --- My config for org
;;
;;; Code:
(setq org-directory "~/org")
;; auto-fill-mode
;; (set to 78 in files)
(add-hook 'org-mode-hook 'auto-fill-mode)
;; Use-enter-to-follow-links
(setq org-return-follows-link t)
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(setq org-agenda-files '("~/org"))
;; Todo-rules
;; (find-node "(org)Fast access to TODO states")
(setq org-todo-keywords
'((sequence "TODO(t)" "|" "INPROGRESS(i)" "DONE(d)" "CANCELED(c)" "DEFERRED(s)")))
(setq org-todo-keyword-faces
'(("TODO" . ((:foreground "red")))
("INPROGRESS" . ((:foreground "yellow")))
("BUGREPORT" . ((:foreground "VioletRed4" :weight bold)))
("FIXED" . ((:foreground "SpringGreen4" :weight bold)))
("DEFERRED" . shadow)
("CANCELED" . ((:foreground "blue" :weight bold)))))
(setq org-log-done 'time)
(setq org-use-fast-todo-selection t)
(setq org-reverse-note-order t)
;; Tags-setting
;; (info "(org)Setting tags")
(setq org-tag-alist '(("entrainement")
("climbing")
("equipement")
("running")
("bike")
("vtt")
("montagne")
("cascade")
("github")
("helm")
("async")
("crypt")
("home")
("travel")))
;; org-capture
(setq org-default-notes-file (expand-file-name "notes.org" org-directory)
org-capture-use-agenda-date t)
(setq org-capture-templates
'(("t" "Todo" entry (file+headline "~/org/agenda.org" "Tasks") "** TODO %?\n %i\n %a" :prepend t)
("n" "Notes" entry (file+headline "~/org/notes.org" "General") "** %T %?\n\n %i\n" :prepend t)
("E" "Entrainement" entry (file+headline "~/org/notes.org" "Entrainement") "** %T %?\n\n %i\n" :prepend t)
("H" "Helm" entry (file+headline "~/org/notes.org" "Helm") "** %^{Title}\n %i\n %a" :prepend t)
("l" "Lisp" entry (file+headline "~/org/notes.org" "Elisp") "** %^{Title}\n %i\n %a" :prepend t)
("p" "Python" entry (file+headline "~/org/notes.org" "Python") "** %^{Title}\n %i\n %a" :prepend t)
("b" "Bash" entry (file+headline "~/org/notes.org " "Bash") "** %^{Title}\n %i\n %a" :prepend t)
("L" "Linux" entry (file+headline "~/org/notes.org" "Linux") "** %^{Title}\n %i\n %a" :prepend t)))
;; Org-protocol
;; See https://orgmode.org/worg/org-contrib/org-protocol.html for
;; setting it up.
(require 'org-protocol)
;; org-annotation-helper
;; (require 'org-annotation-helper)
;; Diary-integration-in-org
(setq org-agenda-include-diary t) ; show also content of regular diary file.
;; (setq org-agenda-diary-file "~/org/diary.org")
;; Subtasks
(defun org-summary-todo (n-done n-not-done)
"Switch entry to DONE when all subentries are done, to TODO otherwise."
(let (org-log-done org-log-states) ; turn off logging
(org-todo (if (= n-not-done 0) "DONE" "TODO"))))
(add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
;; leave-a-blank-line-when-insert-new-item
(setq org-blank-before-new-entry '((heading . t)
(plain-list-item . nil)))
(defun tv:insert-org-src-keyword ()
(interactive)
(if (region-active-p)
(let ((beg (region-beginning))
(end (region-end)))
(goto-char beg)
(forward-line -1)
(insert "#+begin_src ")
(save-excursion
;; (insert "\n")
(goto-char end)
(end-of-line)
(insert "\n#+end_src")))
(insert "#+begin_src ")
(save-excursion (insert "\n#+end_src"))))
(defun tv:org-headings (arg)
(interactive "P")
(if (eq major-mode 'org-mode)
(helm-org-in-buffer-headings arg)
(helm-org-agenda-files-headings arg)))
(add-hook 'org-mode-hook
(lambda ()
(define-key org-mode-map (kbd "<f11> o") 'tv:org-headings)
(define-key org-mode-map (kbd "<f11> k") 'tv:insert-org-src-keyword)))
;; Colorize-Diary's-entries-in-agenda
(defvar tv:diary-regexp "^ *[Dd]iary")
(defvar tv:diary-done-regexp "^ *[Dd]iary.* *==> *done$")
(defun tv:org-propertize-diary-entries ()
(save-excursion
(let ((inhibit-read-only t))
(goto-char (point-min))
(while (not (eobp))
(cond ((re-search-forward tv:diary-done-regexp (point-at-eol) t)
(add-text-properties
(point-at-bol) (point-at-eol) '(face 'tv:org-diary-done)))
((re-search-forward tv:diary-regexp (point-at-eol) t)
(add-text-properties
(point-at-bol) (point-at-eol) '(face tv:org-diary))))
(forward-line 1)))))
(add-hook 'org-finalize-agenda-hook 'tv:org-propertize-diary-entries)
(defface tv:org-diary '((t (:foreground "Yellow3" :underline t)))
"*Face for diary entry in org agenda."
:group 'org)
(defface tv:org-diary-done '((t (:foreground "darkgrey")))
"*Face for finished diary entry in org agenda."
:group 'org)
(defun tv:org-propertize-note-entry ()
(save-excursion
(let ((inhibit-read-only t))
(goto-char (point-min))
(while (re-search-forward "^ +note" nil t)
(add-text-properties (match-beginning 0) (point-at-eol)
'(face '((:foreground "magenta"))))))))
(add-hook 'org-finalize-agenda-hook 'tv:org-propertize-note-entry)
(add-hook 'org-agenda-mode-hook
(lambda () (set-face-attribute 'org-agenda-date-weekend nil :foreground "red")))
;; org-crypt
(org-crypt-use-before-save-magic)
(setq org-crypt-key "08FDB07A7433A7F2")
(setq org-crypt-disable-auto-save t)
(define-key org-mode-map (kbd "C-c e") 'org-encrypt-entry)
(define-key org-mode-map (kbd "C-c d") 'org-decrypt-entry)
;; fontify source code
(setq org-src-fontify-natively t)
;; Always show full path of files
(setq org-link-file-path-type 'absolute)
;; Invisible edits
(setq org-catch-invisible-edits 'smart)
(setq org-show-context-detail '((default . local)))
;; Org babel
(with-eval-after-load 'ob-emacs-lisp
;; active Babel languages
(org-babel-do-load-languages
'org-babel-load-languages
'((gnuplot . t)
(emacs-lisp . t))))
(define-key org-mode-map (kbd "<M-up>") 'tv:scroll-up)
(define-key org-mode-map (kbd "<M-down>") 'tv:scroll-down)
(define-key org-mode-map (kbd "<C-M-up>") 'tv:scroll-other-up)
(define-key org-mode-map (kbd "<C-M-down>") 'tv:scroll-other-down)
(define-key org-mode-map (kbd "C-d") 'tv:delete-char)
(define-key org-mode-map (kbd "<C-return>") nil)
(define-key org-mode-map (kbd "C-,") nil)
(define-key org-mode-map (kbd "<C-return>") nil)
(define-key org-mode-map (kbd "<M-right>") nil)
(define-key org-mode-map (kbd "<M-left>") nil)
(define-key org-mode-map (kbd "C-c C-i") 'org-table-insert-row)
;; Disable org-persist
(when (> emacs-major-version 28)
(with-eval-after-load 'org-persist
(advice-add 'org-persist-register :override #'ignore)))
;; Imenu
(setq org-imenu-depth 4)
;; Org-indent
(setq org-startup-indented t)
(provide 'org-config)
;;; org-config.el ends here