-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathora-org-roam.el
65 lines (56 loc) · 1.96 KB
/
ora-org-roam.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
(use-package org-roam
:diminish org-roam-mode)
(setq org-roam-directory
(expand-file-name
"roam"
(file-name-directory
(directory-file-name
plain-org-wiki-directory))))
(setq org-roam-buffer-position 'bottom)
(setq org-roam-completion-system 'ivy)
(whicher "dot")
(setq org-roam-capture-templates
'(("d"
"default"
plain
#'org-roam-capture--get-point
"%?"
:file-name "%<%Y-%m-%d_%H:%M>-${slug}"
:head "#+title: ${title}\n* Tasks\n"
:unnarrowed t)))
(defhydra hydra-org-roam (:exit t :idle 0.8)
"Launcher for `org-roam'."
("i" org-roam-insert "insert")
("f" ora-org-roam-find-file "find-file")
("v" org-roam-buffer-activate "backlinks")
("t" ora-roam-todo "todo"))
(org-roam-mode)
(defun ora-org-roam-find-file-action (x)
(if (consp x)
(let ((file-path (plist-get (cdr x) :path)))
(org-roam--find-file file-path))
(let* ((title-with-tags x)
(org-roam-capture--info
`((title . ,title-with-tags)
(slug . ,(funcall org-roam-title-to-slug-function title-with-tags))))
(org-roam-capture--context 'title))
(setq org-roam-capture-additional-template-props (list :finalize 'find-file))
(org-roam-capture--capture))))
(defun ora-org-roam-find-file ()
(interactive)
(unless org-roam-mode (org-roam-mode))
(ivy-read "File: " (org-roam--get-title-path-completions)
:action #'ora-org-roam-find-file-action
:caller 'ora-org-roam-find-file))
(defun ora-roam-todo ()
"An ad-hoc agenda for `org-roam'."
(interactive)
(let* ((regex "^\\* TODO")
(b (get-buffer (concat "*ivy-occur counsel-rg \"" regex "\"*"))))
(if b
(progn
(switch-to-buffer b)
(ivy-occur-revert-buffer))
(setq unread-command-events (listify-key-sequence (kbd "C-c C-o M->")))
(counsel-rg regex org-roam-directory "--sort modified"))))
(provide 'ora-org-roam)