-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgs-org-roam.el
151 lines (137 loc) · 7.27 KB
/
gs-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
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
;;; -*- lexical-binding: t -*-
(use-package org-roam
:custom
(org-roam-directory (convert-standard-filename (expand-file-name "~/Documents/org-roam/")))
:demand t
:ensure t)
(use-package org-roam-dailies
:after org-roam-dailies
:custom
(org-roam-dailies-capture-templates '(("d" "default" entry
"* %?"
:if-new (file+head ,dw/daily-note-filename
,dw/daily-note-header))
("t" "task" entry
"* TODO %?\n %U\n %a\n %i"
:if-new (file+head+olp ,dw/daily-note-filename
,dw/daily-note-header
("Tasks"))
:empty-lines 1)
("l" "log entry" entry
"* %<%I:%M %p> - %?"
:if-new (file+head+olp ,dw/daily-note-filename
,dw/daily-note-header
("Log")))
("j" "journal" entry
"* %<%I:%M %p> - Journal :journal:\n\n%?\n\n"
:if-new (file+head+olp ,dw/daily-note-filename
,dw/daily-note-header
("Log")))
("m" "meeting" entry
"* %<%I:%M %p> - %^{Meeting Title} :meetings:\n\n%?\n\n"
:if-new (file+head+olp ,dw/daily-note-filename
,dw/daily-note-header
("Log"))))))
(use-package org-roam-capture
:custom
(org-roam-capture-templates '(("d" "default" plain
(file "~/Documents/org-roam/templates/default.org")
:if-new
(file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n\n")
:unnarrowed t)
("p" "padrão" plain
(file "~/Documents/org-roam/templates/padrão.org")
:if-new
(file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n\n")
:unnarrowed t)
("n" "notegpt.io" plain
(file "~/Documents/org-roam/templates/notegpt.io.org")
:if-new
(file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n#+filetags: :notegpt_io:hacker_news:\n\n")
:unnarrowed t)
("r" "redação" plain
(file "~/Documents/org-roam/templates/redação.org")
:if-new
(file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n#+filetags: :redação:\n\n")
:unnarrowed t)
("s" "summarize.ing" plain
(file "~/Documents/org-roam/templates/summarize.ing.org")
:if-new
(file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n#+filetags: :summarize_ing:\n\n")
:unnarrowed t))))
(use-package org-roam-dailies
:bind-keymap
("C-z r d" . org-roam-dailies-map)
:bind
(:map org-roam-dailies-map
("Y" . org-roam-dailies-capture-yesterday)
("T" . org-roam-dailies-capture-tomorrow))
:custom
(dw/daily-note-filename "%<%Y-%m-%d>.org")
(dw/daily-note-header "#+title: %<%Y-%m-%d %a>\n\n[[roam:%<%Y-%B>]]\n\n"))
(use-package org-roam-db
:init
(org-roam-db-autosync-mode))
(use-package org-roam-node
:bind
("C-z r f" . org-roam-node-find)
("C-z r i" . org-roam-node-insert)
:custom
(org-roam-completion-everywhere t))
(use-package org-agenda
:bind
("C-z r b" . dw/org-roam-capture-inbox)
:config
(defun dw/org-roam-filter-by-tag (tag-name)
"Filter org roam files by their tags."
(lambda (node)
(member tag-name (org-roam-node-tags node))))
(defun dw/org-roam-list-notes-by-tag (tag-name)
"List org roam files by their tags."
(mapcar #'org-roam-node-file
(seq-filter
(dw/org-roam-filter-by-tag tag-name)
(org-roam-node-list))))
(defun dw/org-roam-refresh-agenda-list () ;; 1
"Refresh the current agenda list, and add the files with the currosponding tag to the agenda list."
(interactive)
(setq org-agenda-files (dw/org-roam-list-notes-by-tag "agenda")))
;; Build the agenda list the first time for the session
(dw/org-roam-refresh-agenda-list)
(defun dw/org-roam-project-finalize-hook ()
"Adds the captured project file to "org-agenda-file" if the capture was not aborted."
;; Remove the hook since it was added temporarily
(remove-hook 'org-capture-after-finalize-hook #'dw/org-roam-project-finalize-hook)
;; Add project file to the agenda list if the capture was confirmed
(unless org-note-abort
(with-current-buffer (org-capture-get :buffer)
(add-to-list 'org-agenda-files (buffer-file-name)))))
(defun dw/org-roam-capture-inbox ()
"Create a org roam inbox file."
(interactive)
(org-roam-capture- :node (org-roam-node-create)
:templates '(("i" "inbox" plain "* %?"
:if-new (file+head "inbox.org" "#+title: Inbox\n#+filetags: :agenda:\n\n")))))
(defun dw/org-roam-goto-month ()
"Lists the files of the selected month with the set tag."
(interactive)
(org-roam-capture- :goto (when (org-roam-node-from-title-or-alias (format-time-string "%Y-%B")) '(4))
:node (org-roam-node-create)
:templates '(("m" "month" plain "\n* Goals\n\n%?* Summary\n\n"
:if-new (file+head "%<%Y-%B>.org"
"#+title: %<%Y-%B>\n#+filetags: :agenda:\n\n")
:unnarrowed t))))
(defun dw/org-roam-goto-year ()
"Lists the files of the selected year with the set tag."
(interactive)
(org-roam-capture- :goto (when (org-roam-node-from-title-or-alias (format-time-string "%Y")) '(4))
:node (org-roam-node-create)
:templates '(("y" "year" plain "\n* Goals\n\n%?* Summary\n\n"
:if-new (file+head "%<%Y>.org"
"#+title: %<%Y>\n#+filetags: :agenda:\n\n")
:unnarrowed t))))
:custom
(org-agenda-hide-tags-regexp "agenda")
:hook
(org-agenda-finalize . dw/org-roam-refresh-agenda-list))
(provide 'gs-org-roam)