Commit 208c46cb authored by Tim van Deurzen's avatar Tim van Deurzen

Updated emacs config with workflow fixes.

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