Configure org-roam
This commit is contained in:
parent
daf8eb1cd9
commit
a92340ae81
@ -1,4 +1,5 @@
|
||||
;;; init-org.el --- -*- lexical-binding: t -*-
|
||||
;; -*- lexical-binding: t; -*-
|
||||
;;; init-org.el --- org initialization
|
||||
;;
|
||||
;; Filename: init-org.el
|
||||
;; Description: Initialize Org, Toc-org, HTMLize, OX-GFM
|
||||
@ -131,29 +132,173 @@
|
||||
(unless (file-directory-p pub-dir)
|
||||
(make-directory pub-dir)))
|
||||
(apply orig-fun extension subtreep pub-dir nil))
|
||||
(advice-add 'org-export-output-file-name :around #'org-export-output-file-name-modified))
|
||||
(advice-add 'org-export-output-file-name :around #'org-export-output-file-name-modified)
|
||||
|
||||
(setq org-capture-templates
|
||||
'(("t" "Personal todo" entry
|
||||
(file+headline +org-capture-todo-file "Inbox")
|
||||
"* TODO %? :@general:" :prepend t)
|
||||
|
||||
("f" "Empty" entry
|
||||
(file+headline +org-capture-todo-file "Inbox")
|
||||
"* TODO %?" :prepend t)
|
||||
|
||||
("w" "WATCH" entry
|
||||
(file+headline +org-capture-todo-file "Inbox")
|
||||
"* TODO %? :@watch:" :prepend t)
|
||||
|
||||
("r" "READ" entry
|
||||
(file+headline +org-capture-todo-file "Inbox")
|
||||
"* TODO %? :@read:" :prepend t)
|
||||
|
||||
("c" "CHECK" entry
|
||||
(file+headline +org-capture-todo-file "Inbox")
|
||||
"* TODO %? :@check:" :prepend t)
|
||||
|
||||
("i" "Got a new idea?" entry
|
||||
(file+headline +org-capture-todo-file "Inbox")
|
||||
"* TODO %? :@idea:" :prepend t)
|
||||
|
||||
("j" "Journal" entry
|
||||
(file+headline +org-capture-journal-file "Posts")
|
||||
"*** %?\n:DATE:\n%<[%Y-%m-%d %a %H:%M]>\n:END:" :prepend t)))
|
||||
|
||||
(setq org-agenda-custom-commands
|
||||
'(
|
||||
("f" "Today Tasks"
|
||||
(
|
||||
(agenda "" ((org-agenda-span 4)))
|
||||
(org-ql-block '(and
|
||||
(todo "TODO")
|
||||
(or (scheduled)
|
||||
(deadline)))
|
||||
((org-ql-block-header "Soon")))
|
||||
))
|
||||
|
||||
("v" "General Tasks"
|
||||
(
|
||||
(agenda "" ((org-agenda-span 4)))
|
||||
(org-ql-block '(and
|
||||
(priority "A")
|
||||
(not (deadline))
|
||||
(not (scheduled)))
|
||||
((org-ql-block-header "High-priority tasks")))
|
||||
|
||||
(org-ql-block '(and
|
||||
(todo "TODO")
|
||||
(tags "@idea")
|
||||
(not (tags "@later"))
|
||||
(not (deadline))
|
||||
(not (scheduled)))
|
||||
((org-ql-block-header "Looking for an idea?")))
|
||||
|
||||
(org-ql-block '(and
|
||||
(todo "TODO")
|
||||
(tags "@write")
|
||||
(not (tags "@later"))
|
||||
(not (tags "project"))
|
||||
(not (deadline))
|
||||
(not (scheduled)))
|
||||
((org-ql-block-header "Write something:")))
|
||||
|
||||
(org-roam-ql-agenda-block '(and (todo "TODO")))
|
||||
))))
|
||||
)
|
||||
;; -OrgPac
|
||||
|
||||
;; OrgRoamPac
|
||||
(use-package org-roam
|
||||
:after org
|
||||
:ensure t
|
||||
:demand t ;; Ensure org-roam is loaded by default
|
||||
:custom
|
||||
(org-roam-node-display-template
|
||||
(concat "${title:*} "
|
||||
(propertize "${tags:10}" 'face 'org-tag)))
|
||||
(org-roam-directory "~/Documents/Org-mode/brain")
|
||||
(org-roam-completion-everywhere t)
|
||||
:bind
|
||||
(("C-c n l" . org-roam-buffer-toggle)
|
||||
("C-c n f" . org-roam-node-find)
|
||||
("C-c n i" . org-roam-node-insert)
|
||||
("C-c n h" . org-id-get-create))
|
||||
:bind (("C-c n l" . org-roam-buffer-toggle)
|
||||
("C-c n f" . org-roam-node-find)
|
||||
("C-c n i" . org-roam-node-insert)
|
||||
("C-c n I" . org-roam-node-insert-immediate)
|
||||
("C-c n p" . my/org-roam-find-project)
|
||||
("C-c n t" . my/org-roam-capture-task)
|
||||
:map org-mode-map
|
||||
("C-M-i" . completion-at-point)
|
||||
:map org-roam-dailies-map
|
||||
("Y" . org-roam-dailies-capture-yesterday)
|
||||
("T" . org-roam-dailies-capture-tomorrow))
|
||||
:bind-keymap
|
||||
("C-c n d" . org-roam-dailies-map)
|
||||
:config
|
||||
(when (file-directory-p "~/Documents/Org-mode/brain")
|
||||
(setq org-roam-directory (file-truename "~/Documents/Org-mode/brain")))
|
||||
(require 'org-roam-dailies)
|
||||
(require 'org-roam-dailies) ;; Ensure the keymap is available
|
||||
(org-roam-db-autosync-mode))
|
||||
|
||||
|
||||
(defun my/org-roam-filter-by-tag (tag-name)
|
||||
(lambda (node)
|
||||
(member tag-name (org-roam-node-tags node))))
|
||||
|
||||
(defun my/org-roam-list-notes-by-tag (tag-name)
|
||||
(mapcar #'org-roam-node-file
|
||||
(seq-filter
|
||||
(my/org-roam-filter-by-tag tag-name)
|
||||
(org-roam-node-list))))
|
||||
|
||||
(defun my/org-roam-refresh-agenda-list ()
|
||||
(interactive)
|
||||
(setq org-agenda-files (my/org-roam-list-notes-by-tag "Project")))
|
||||
|
||||
;; Build the agenda list the first time for the session
|
||||
(my/org-roam-refresh-agenda-list)
|
||||
|
||||
(defun my/org-roam-project-finalize-hook ()
|
||||
"Adds the captured project file to `org-agenda-files' if the
|
||||
capture was not aborted."
|
||||
;; Remove the hook since it was added temporarily
|
||||
(remove-hook 'org-capture-after-finalize-hook #'my/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)))))
|
||||
|
||||
;;; This does not work, something wrong with template..
|
||||
;; (defun my/org-roam-find-project ()
|
||||
;; (interactive)
|
||||
;; ;; Add the project file to the agenda after capture is finished
|
||||
;; (add-hook 'org-capture-after-finalize-hook #'my/org-roam-project-finalize-hook)
|
||||
|
||||
;; ;; Select a project file to open, creating it if necessary
|
||||
;; (org-roam-node-find
|
||||
;; nil
|
||||
;; nil
|
||||
;; (my/org-roam-filter-by-tag "Project")
|
||||
;; :templates '(("p" "project" plain "* Goals\n\n%?\n\n* Tasks\n\n* TODO Add initial tasks\n\n* Dates\n\n"
|
||||
;; :if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n#+category: ${title}\n#+filetags: Project")
|
||||
;; :unnarrowed t))))
|
||||
|
||||
(defun my/org-roam-capture-task ()
|
||||
(interactive)
|
||||
;; Add the project file to the agenda after capture is finished
|
||||
(add-hook 'org-capture-after-finalize-hook #'my/org-roam-project-finalize-hook)
|
||||
|
||||
;; Capture the new task, creating the project file if necessary
|
||||
(org-roam-capture- :node (org-roam-node-read
|
||||
nil
|
||||
(my/org-roam-filter-by-tag "Project"))
|
||||
:templates '(("p" "project" plain "** TODO %?"
|
||||
:if-new (file+head+olp "%<%Y%m%d%H%M%S>-${slug}.org"
|
||||
"#+title: ${title}\n#+category: ${title}\n#+filetags: Project"
|
||||
("Tasks"))))))
|
||||
;; ~OrgRoamPac
|
||||
|
||||
(use-package org-roam-ql
|
||||
:after (org-roam)
|
||||
:bind ((:map org-roam-mode-map
|
||||
;; Have org-roam-ql's transient available in org-roam-mode buffers
|
||||
("v" . org-roam-ql-buffer-dispatch)
|
||||
:map minibuffer-mode-map
|
||||
;; Be able to add titles in queries while in minibuffer.
|
||||
;; This is similar to `org-roam-node-insert', but adds
|
||||
;; only title as a string.
|
||||
("C-c n i" . org-roam-ql-insert-node-title))))
|
||||
;; -OrgRoamPac
|
||||
|
||||
;; TocOrgPac
|
||||
|
||||
Loading…
Reference in New Issue
Block a user