diff options
| author | Craig Jennings <c@cjennings.net> | 2025-07-16 11:02:05 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2025-07-16 11:02:05 -0500 |
| commit | 28b125ceacde81d14588dadbeb1eba86cbf863f3 (patch) | |
| tree | 6ccbb51b43bd63ca8c7744a6708b21be56e5ba27 /modules/test-code.el | |
| parent | d050b214838b205b56ebb5b460976e90601f13cd (diff) | |
| download | dotemacs-28b125ceacde81d14588dadbeb1eba86cbf863f3.tar.gz dotemacs-28b125ceacde81d14588dadbeb1eba86cbf863f3.zip | |
wip cj/move-org-branch-to-roam
Diffstat (limited to 'modules/test-code.el')
| -rw-r--r-- | modules/test-code.el | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/modules/test-code.el b/modules/test-code.el index aa4ec607..e718094a 100644 --- a/modules/test-code.el +++ b/modules/test-code.el @@ -8,6 +8,76 @@ ;;; Code: +;; ------------------------ Org-Branch To Org-Roam-Node ------------------------ + +;; (defun cj/move-org-branch-to-roam () +;; (interactive) +;; (when (eq (org-element-type (org-element-at-point)) 'headline) +;; (let* ((headline-components (org-heading-components)) +;; (title (nth 4 headline-components))) +;; (setq cj/point (point)) +;; (org-cut-subtree) +;; ;; Switch to org-roam buffer, fill in new node's title +;; ;; Pass the current headline title as the default value +;; (org-roam-node-insert +;; :immediate-finish t +;; :no-edit t +;; :region (cons (point) +;; (save-excursion +;; (insert title) +;; (point)))) +;; (newline) +;; ;; Paste the 'cut' subtree and save buffer +;; (org-yank) +;; (save-buffer) +;; ;; Go back to the initial buffer and position +;; (switch-to-buffer (other-buffer)) +;; (goto-char cj/point)))) + +(defun cj/move-org-branch-to-roam () + (interactive) + (when (eq (org-element-type (org-element-at-point)) 'headline) + (let* ((headline-components (org-heading-components)) + (title (nth 4 headline-components))) + (setq cj/point (point)) + (org-cut-subtree) + ;; Switch to org-roam buffer, fill in new node's title. + (org-roam-node-insert + :immediate-finish t + :no-edit t + ;; Pass the current headline title as the default value. + :region (cons (point) + (save-excursion + (insert title) + (point)))) + (newline) + ;; Paste the 'cut' subtree and save buffer. + (org-yank) + (save-buffer) + ;; Go back to the initial buffer and position. + (switch-to-buffer (other-buffer)) + (goto-char cj/point) + ;; Kill the org-roam link leftover. + (kill-whole-line)))) + +;; (defun cj/move-org-branch-to-roam () +;; (interactive) +;; (when (eq (org-element-type (org-element-at-point)) 'headline) +;; ;; Save position to come back after branch cut +;; (setq cj/point (point)) +;; ;; Cut the whole subtree +;; (org-cut-subtree) +;; ;; Switch to org-roam buffer, prompt for new node's title +;; (org-roam-node-insert) +;; (newline) +;; ;; Paste the 'cut' subtree and save buffer +;; (org-yank) +;; (save-buffer) +;; ;; Go back to the initial buffer and position +;; (switch-to-buffer (other-buffer)) +;; (goto-char cj/point))) + +;; --------------------------------- Org Noter --------------------------------- (use-package org-noter :after (:any org pdf-view) |
