Created
April 6, 2021 19:45
-
-
Save rafaelbeirigo/0bc86c167b9383fd074720c180b79671 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun my/org-refile-to-id (id &optional todo) | |
"Refile current subtree to subtree with ID." | |
(interactive (list (read-string "ID: "))) | |
(when todo (org-todo todo)) | |
(org-cut-subtree) | |
(let ((anchor (ignore-errors (org-id-get-create)))) | |
(org-id-goto id) | |
(org-insert-heading-respect-content) | |
(org-demote-subtree) | |
(org-yank) | |
(exchange-point-and-mark) | |
(zap-to-char 1 (string-to-char " ")) | |
(move-beginning-of-line nil) | |
(if anchor | |
(org-id-goto anchor) | |
(message "This was the last one.")))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment