Skip to content
Snippets Groups Projects
Commit 208c46cb authored by Tim van Deurzen's avatar Tim van Deurzen
Browse files

Updated emacs config with workflow fixes.

parent acee2b27
No related branches found
No related tags found
No related merge requests found
......@@ -55,7 +55,7 @@
(sequence "WAITING(w@/!)" "SOMEDAY(s)" "|" "CANCELED(c@)")))
(setq org-hide-emphasis-markers t
org-startup-folded 'fold
org-startup-folded 'overview
org-pretty-entities t
org-time-clocksum-format (quote (:hours "%d" :require-hours t :minutes ":%02d" :require-minutes t))
......@@ -102,15 +102,13 @@
#'visual-line-mode
#'org-appear-mode)
(use-package! vulpea
:hook ((org-roam-db-autosync-mode . vulpea-db-autosync-mode)))
(use-package! org-transclusion
:after org-roam)
(after! org-roam
(setq org-roam-directory "~/org/roam/"
org-roam-v2-ack t)
org-roam-v2-ack t
org-roam-db-update-on-save t)
(setq deft-directory "~/org/roam")
(setq deft-extensions '("org"))
......@@ -119,67 +117,82 @@
(require 'vulpea-select)
(defun tim/org-roam-filter-by-tag (tag)
"Return a lambda to select nodes with a particular tag TAG."
(lambda (node)
(member tag (org-roam-node-tags node))))
(defun tim/hidden-file-p (name)
"Return whether the file with name NAME is hidden."
(string-prefix-p "." name))
(defun tim/org-roam-workspaces ()
"Use subfolders in the org-roam-directory ask workspaces for particular projects."
(let ((files (directory-files org-roam-directory)))
(seq-filter (lambda (name)
(and (file-directory-p (concat org-roam-directory name))
(not (tim/hidden-file-p name))))
files)))
(defun tim/find-project ()
"Select or capture project within a particular."
"Select or capture project within a particular workspace."
(interactive)
(let* ((workspace (completing-read "workspace: " (tim/org-roam-workspaces)))
(org-roam-directory (expand-file-name workspace org-roam-directory))
(node (vulpea-select-from "project: " (vulpea-db-query-by-tags-every (list workspace "project")))))
(node (vulpea-select-from "item" (vulpea-db-query-by-tags-every (list workspace "project"))))
(org-roam-directory (expand-file-name workspace org-roam-directory)))
(if (vulpea-note-id node)
(org-roam-node-visit (org-roam-node-from-id (vulpea-note-id node)))
(org-roam-capture- :node (org-roam-node-create :title (vulpea-note-title node))
:props '(:finalize find-file)
:templates
`(("p" "project" plain (file ,(concat org-roam-directory "/templates/project.org"))
`(
("p" "project" plain (file ,(concat org-roam-directory "/templates/project.org"))
:target (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}")
:unnarrowed t)
("n" "note" plain (file ,(concat org-roam-directory "/templates/note.org"))
:target (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}")
:unnarrowed t))))))
:unnarrowed t)
)))))
;; TODO Create something similar to vulpea-find by first querying for the node and running org-roam-capture- if nothing is found.
(defun tim/capture-report ()
"Select or capture a (monthly) report within a particular workspace."
;; Yes this is duplicated ... still learning elisp.
(defun tim/find-report ()
"Select or capture report within a particular workspace."
(interactive)
(let* ((workspace (completing-read "workspace: " (tim/org-roam-workspaces)))
(workspace-path (expand-file-name workspace org-roam-directory))
(org-roam-directory (expand-file-name workspace org-roam-directory))
(template-path (format "%s/templates/" workspace-path)))
(org-roam-capture- :node (org-roam-node-visit (or (org-roam-node-from-id (vulpea-note-id (vulpea-select-from "report" (vulpea-db-query-by-tags-every (list "report"))))) (org-roam-node-create)))
:templates
`(
("m" "monthly report" plain (file ,(concat template-path "monthly-report.org"))
:if-new (file+head "%<%Y-%B>.org" "#+title: %<%B %Y>")
:unnarrowed t)
))))
;; TODO Use vulpea-select-from to find the right node, extended with the workspace, and open it if the filter matches.
;; (vulpea-select-from "report" (vulpea-db-query-by-tags-every (list "report")))
;; (vulpea-db-qu)
(defun tim/org-roam-filter-by-tag (tag)
"Return a lambda to select nodes with a particular tag TAG."
(lambda (node)
(member tag (org-roam-node-tags node))))
(node (vulpea-select-from "report" (vulpea-db-query-by-tags-every (list workspace "report"))))
(org-roam-directory (expand-file-name workspace org-roam-directory)))
(defun tim/hidden-file-p (name)
"Return whether the file with name NAME is hidden."
(if (vulpea-note-id node)
(org-roam-node-visit (org-roam-node-from-id (vulpea-note-id node)))
(org-roam-capture- :node (org-roam-node-create :title (vulpea-note-title node))
:props '(:finalize find-file)
:templates
`(
("m" "monthly report" plain (file ,(concat org-roam-directory "/templates/monthly-report.org"))
:target (file+head "%<%Y-%B>.org" "#+title: ${title}")
:unnarrowed t)
(string-prefix-p "." name))
("y" "yearly report" plain (file ,(concat org-roam-directory "/templates/yearly-report.org"))
:target (file+head "%<%Y>.org" "#+title: ${title}")
:unnarrowed t)
(defun tim/org-roam-workspaces ()
"Use subfolders in the org-roam-directory ask workspaces for particular projects."
)))))
(let ((files (directory-files org-roam-directory)))
(seq-filter (lambda (name)
(and (file-directory-p (concat org-roam-directory name))
(not (tim/hidden-file-p name))))
files)))
(map! :leader
(:prefix-map ("n" . "notes")
(:prefix ("p" . "personal workflow")
:desc "Find project in a workspace." "f" #'tim/find-project
:desc "Find report in a workspace." "r" #'tim/find-report)))
;; (defun tim/org-roam-find-project-workspace ()
......@@ -193,11 +206,6 @@
;; (tim/org-roam-filter-by-tag directory))
;; ))
(map! :leader
(:prefix-map ("n" . "notes")
(:prefix ("w" . "workspace")
:desc "New project in a workspace" "n" #'tim/org-roam-find-project-workspace)))
;; TODO Define custom key maps to load a specific agenda view that only contains relevant files.
;; TODO Redefine the default agenda to use a static set of files?
(use-package! org-super-agenda
......@@ -274,7 +282,8 @@
(setq tabulated-list-entries (tim/my-projects))
(tabulated-list-print t))
(use-package! vulpea
:config (vulpea-db-autosync-mode))
;; Here are some additional functions/macros that could help you configure Doom:
;;
......
......@@ -19,6 +19,12 @@
(package! org-appear)
(package! lister)
(package! delve
:recipe (:host github
:repo "publicimageltd/delve"))
;; To install a package directly from a remote git repo, you must specify a
;; `:recipe'. You'll find documentation on what `:recipe' accepts here:
;; https://github.com/raxod502/straight.el#the-recipe-format
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment