-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit-org.el
96 lines (75 loc) · 4.04 KB
/
init-org.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
;; customize the variable org-file-apps to set pdf viewer etc
;; use __ instead of \emsp in org clock tables
(add-hook 'org-mode-hook (lambda ()
(defun org-clocktable-indent-string (level)
(if (= level 1) ""
(let ((str ""))
(dotimes (k (1- level) str)
;; (setq str (concat "\\emsp" str))))))
(setq str (concat "__" str))))))
))
(add-hook 'org-mode-hook (lambda ()
(add-to-list 'org-clock-clocktable-language-setup
'("da" "Fil" "L" "Timestamp" "Emne" "Tid" "ALL" "Total tid" "File time" "Tabel genereret"))))
;; do clocksums as fractional hours instead of hours:minutes
;; breaks setting deadline in some cases
;; (setq org-time-clocksum-format (quote (:hours "%d" :require-hours t)))
(setq org-time-clocksum-use-fractional t)
(add-hook 'org-mode-hook (lambda () (local-set-key (kbd "C-c C-S-l") 'org-store-link)))
(add-hook 'org-mode-hook (lambda () (local-set-key (kbd "M-j") 'org-meta-return)))
;; languages to allow running from org-mode code blocks
; does not work in emacs 26
; (org-babel-do-load-languages
; 'org-babel-load-languages
; '((python . t) (sh . t)))
(org-babel-do-load-languages
'org-babel-load-languages
'((emacs-lisp . t)
(python . t)
(jupyter . t)))
;; handle python src blocks as if they were jupyter-python blocks
(org-babel-jupyter-override-src-block "python")
;; uncomment to initially show latex fragments, inline images and pretty inline entities in org-mode
;; (add-hook 'org-mode-hook (lambda () (org-preview-latex-fragment)))
;; (add-hook 'org-mode-hook (lambda () (org-display-inline-images)))
;; (add-hook 'org-mode-hook (lambda () (org-toggle-pretty-entities)))
;;(setq org-latex-preview-ltxpng-directory "/tmp/ramdisk/")
;; when nil, inline images obey following or fall back on true img width: #+ATTR: :width 400px
;; when '(x), width x or overridden with ATTR as above
;; when x, width x always
;; when t, always true width
(setq org-image-actual-width '(400))
;; scale up latex inline math a bit
; does not work in emacs 26
;(plist-put org-format-latex-options :scale 1.5)
(global-set-key (kbd "C-c o f") 'org-iswitchb)
(global-set-key (kbd "C-c o a") 'org-agenda)
(setq org-clock-persist 'history)
(org-clock-persistence-insinuate)
(setq org-clock-idle-time nil) ; emacs idle time before org-mode will alert of running clock
;; org-time-clocksum-format is now deprecated in favor of org-duration-format
;; (setq org-time-clocksum-format (quote (:hours "%d" :require-hours t :minutes ":%02d" :require-minutes t)))
;; Following is from the org-duration format documentation: format periods >1 day as fractional days, <1 day as
;; fractional hours. Always two decimals precision.
(setq org-duration-format '(("d" . nil) ("h" . nil) (special . 2)))
;; doesn't work?
;; (setq org-time-stamp-rounding-minutes (quote (5 5))) ; round clock times to 5 mins
;; use google-chrome for opening URLs
(setq browse-url-browser-function 'browse-url-generic
browse-url-generic-program "google-chrome")
(require 'ox-confluence)
;; collapse src code blocks by default (use org-show-block-all to open)
(add-hook 'org-mode-hook 'org-hide-block-all)
;; C-c b s/h to show/hide all blocks
(add-hook 'org-mode-hook (lambda () (local-set-key (kbd "C-c b s") 'org-show-block-all)))
(add-hook 'org-mode-hook (lambda () (local-set-key (kbd "C-c b h") 'org-hide-block-all)))
;; babel: dont ask when executing python code
(defun my-org-confirm-babel-evaluate (lang body)
(not (member lang '("jupyter-python"))))
(setq org-confirm-babel-evaluate 'my-org-confirm-babel-evaluate)
;; insert python src using emacs-jupyter in org-mode with C-c C-, p
(add-to-list 'org-structure-template-alist
'("p" . "src jupyter-python :session py"))
;; after executing code, redisplay images
;(add-hook 'org-babel-after-execute-hook (lambda () (org-redisplay-inline-images)))
(setq org-image-actual-width 600)