diff options
| author | BardofSprites <[email protected]> | 2025-12-26 18:21:18 -0500 |
|---|---|---|
| committer | BardofSprites <[email protected]> | 2025-12-26 18:21:18 -0500 |
| commit | 3fd5220f2890e5efb3021d9b062f2ba2f456eceb (patch) | |
| tree | 31ee99609269203f4a821b73422186ca03cdc5fd | |
| parent | d45da2cce12b4defa12ae61f7deecb405da008de (diff) | |
denote-roam
| -rw-r--r-- | bard-elisp/bard-writing.el | 79 | ||||
| -rw-r--r-- | bard-emacs-modules/bard-emacs-writing.el | 52 |
2 files changed, 24 insertions, 107 deletions
diff --git a/bard-elisp/bard-writing.el b/bard-elisp/bard-writing.el index cd742de..8138b1a 100644 --- a/bard-elisp/bard-writing.el +++ b/bard-elisp/bard-writing.el @@ -40,85 +40,6 @@ (ibuffer nil "*Ibuffer-Notes*" '((name . "^\\[Note\\]")))) -(defun bard/denote-insert-id-at-top () - "Insert or replace a top-level :ID: property at the very top of the current file." - (interactive) - (org-with-wide-buffer - (goto-char (point-min)) - ;; If file already starts with a :PROPERTIES: drawer, remove it - (when (looking-at ":PROPERTIES:") - (let ((end (save-excursion - (re-search-forward ":END:" nil t)))) - (when end - (delete-region (point-min) (min (point-max) (1+ end))))))) - ;; Insert fresh ID drawer at very top - (goto-char (point-min)) - (let ((id (org-id-new))) - (insert (format ":PROPERTIES:\n:ID: %s\n:END:\n" id))) - (save-buffer)) - -(defun bard/denote-maybe-insert-id () - "Insert a top-level :ID: unless this is a denote journal file." - (interactive) - (let ((file (buffer-file-name))) - (unless (and file - (boundp 'denote-journal-directory) - (string-prefix-p (expand-file-name denote-journal-directory) - (expand-file-name file))) - (bard/denote-insert-id-at-top)))) - -(defun bard/insert-or-create-node () - "Insert an Org-roam link if the note exists; otherwise create via Denote." - (interactive) - ;; Prompt for an existing node, but do not auto-create - (let* ((node (org-roam-node-read)) - (title (org-roam-node-title node))) - (if node - ;; Node exists: insert Org-roam link at point - (let ((id (org-roam-node-id node))) - (if id - (insert (org-link-make-string - (concat "id:" id) - title)) - ;; Node does not exist (no id): create via Denote - (bard/denote-insert-node title)))))) - -(defun bard/find-or-create-node () - "Find an Org-roam node by title; if missing, create via Denote." - (interactive) - (let* ((node (org-roam-node-read nil nil)) ;; no auto-create; just selection - (title (org-roam-node-title node))) - (if (org-roam-node-id node) - ;; Node exists → visit - (org-roam-node-visit node) - ;; Node missing → create via Denote - (let ((keyword (denote-keywords-prompt))) - (denote title keyword))))) - -(defun bard/denote-insert-node (title) - "Denote analogy for `org-roam-insert-node', takes TITLE as node title." - (interactive) - (let* ((keywords (denote-keywords-prompt)) - (file (denote title keywords nil nil nil nil nil nil))) - - (when-let ((buf (find-buffer-visiting file))) - (with-current-buffer buf - (save-buffer) - (kill-buffer buf))) - - ;; extract uuid from file that is autogenerated by `bard/denote-insert-id-at-top' - (let ((uuid - (with-temp-buffer - (insert-file-contents file) - (goto-char (point-min)) - (when (re-search-forward "^:ID:\\s-+\\([[:alnum:]-]+\\)" nil t) - (match-string 1))))) - (unless uuid - (error "No :ID: found in Denote file %s" file)) - - ;; Insert link at point - (insert (format "[[id:%s][%s]]" uuid title))))) - (defun denote-sequence-region () "Call `denote-sequence' and insert therein the text of the active region. diff --git a/bard-emacs-modules/bard-emacs-writing.el b/bard-emacs-modules/bard-emacs-writing.el index 2cb28b8..dc08970 100644 --- a/bard-emacs-modules/bard-emacs-writing.el +++ b/bard-emacs-modules/bard-emacs-writing.el @@ -96,25 +96,18 @@ (require 'bard-writing) - (add-hook 'denote-after-new-note-hook #'bard/denote-maybe-insert-id) - :hook (dired-mode . denote-dired-mode) - :bind (("C-c n n" . denote) - ("C-c n <TAB>" . denote-region) ("C-c n d" . denote-sort-dired) ("C-c n r" . denote-rename-file-using-front-matter) ("C-c n k" . denote-rename-file-keywords) - ("C-c n i" . bard/insert-or-create-node) ("C-c n I" . denote-add-links) ("C-c n b" . bard/consult-buffer-notes) ; notes buffer ("C-c n B" . bard/ibuffer-notes) ; notes buffer but more ("C-c n f" . bard/find-notes-file) ; notes-find - ("C-c n g" . bard/search-notes-directory) ; notes-grep - ("C-c n l" . denote-find-link) - ("C-c n L" . denote-find-backlink))) + ("C-c n g" . bard/search-notes-directory))) ; notes-grep (use-package denote-org :ensure t @@ -146,18 +139,37 @@ (setq denote-journal-title-format "Daily Tasks and Notes") ) +(use-package denote-roam + :ensure nil + :load-path "~/Code/denote-roam/" + :bind + ("C-c n i" . denote-roam-insert-or-create-node) ; node insert + ("C-c n o" . denote-roam-find-or-create-node) ; node open + :custom + (denote-roam-include-journal nil) + (denote-roam-directory "~/Notes/denote") + :config + (denote-roam-mode t)) + +;;;; Org Roam (use-package org-roam :ensure t :custom (org-roam-directory (file-truename "~/Notes/denote")) - :bind (("C-c n l" . org-roam-buffer-toggle) - ("C-c n o" . org-roam-node-find)) + :bind (("C-c n l" . org-roam-buffer-toggle)) :config + (setq org-roam-db-node-include-function + (lambda () + (not (member "ATTACH" (org-get-tags))))) + (org-roam-db-autosync-mode 1)) (use-package org-roam-ui - :ensure t) - + :ensure t + :bind + ("C-c n u" . org-roam-ui-open) + :custom + (org-roam-ui-open-on-start nil)) ;;; Focus mode for writing @@ -266,20 +278,4 @@ :ensure t ) -;; Org Roam (trying this out again?) -;;;; Org Roam -(use-package org-roam - :ensure t - :custom - (org-roam-directory (file-truename "~/Notes/denote")) - :bind (("C-c n l" . org-roam-buffer-toggle) - ("C-c n i" . org-roam-node-insert)) - :config - (org-roam-db-autosync-mode 1)) - -(use-package org-roam-ui - :ensure t - :bind - ("C-c n u" . org-roam-ui-open)) - (provide 'bard-emacs-writing) |
