-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-org-mode.el
73 lines (66 loc) · 2.18 KB
/
setup-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
;; (add-hook 'org-mode-hook
;; (function
;; (lambda ()
;; (define-key org-mode-map [(tab)] 'org-cycle))))
(require 'evil)
(require 'org)
(define-minor-mode evil-org-mode
"Buffer local minor mode for evil-org"
:init-value nil
:lighter " EvilOrg"
:keymap (make-sparse-keymap) ; defines evil-org-mode-map
:group 'evil-org)
(add-hook 'org-mode-hook 'evil-org-mode) ;; only load with org-mode
(defun always-insert-item ()
(if (not (org-in-item-p))
(insert "\n- ")
(org-insert-item))
)
(defun evil-org-eol-call (fun)
(end-of-line)
(funcall fun)
(evil-append nil)
)
;; normal state shortcuts
(evil-define-key 'normal evil-org-mode-map
"gh" 'outline-up-heading
"gj" 'org-forward-same-level
"gk" 'org-backward-same-level
"gl" 'outline-next-visible-heading
"t" 'org-todo
"T" '(lambda () (interactive) (evil-org-eol-call '(org-insert-todo-heading nil)))
"H" 'org-beginning-of-line
"L" 'org-end-of-line
";t" 'org-show-todo-tree
"o" '(lambda () (interactive) (evil-org-eol-call 'always-insert-item))
"O" '(lambda () (interactive) (evil-org-eol-call 'org-insert-heading))
"$" 'org-end-of-line
"^" 'org-beginning-of-line
"<" 'org-metaleft
">" 'org-metaright
";a" 'org-agenda
"-" 'org-cycle-list-bullet
(kbd "TAB") 'org-cycle)
;; normal & insert state shortcuts.
(mapc (lambda (state)
(evil-define-key state evil-org-mode-map
(kbd "M-l") 'org-metaright
(kbd "M-h") 'org-metaleft
(kbd "M-k") 'org-metaup
(kbd "M-j") 'org-metadown
(kbd "M-L") 'org-shiftmetaright
(kbd "M-H") 'org-shiftmetaleft
(kbd "M-K") 'org-shiftmetaup
(kbd "M-J") 'org-shiftmetadown
(kbd "M-o") '(lambda () (interactive)
(evil-org-eol-call
'(lambda()
(org-insert-heading)
(org-metaright))))
(kbd "M-t") '(lambda () (interactive)
(evil-org-eol-call
'(lambda()
(org-insert-todo-heading nil)
(org-metaright))))
))
'(normal insert))