[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

org-refile using the ID of the target

From: Jack Bauer
Subject: org-refile using the ID of the target
Date: Tue, 6 Apr 2021 16:55:13 -0300

I take a lot of notes using MobileOrg in my phone, and after syncing, they go into in.org (my gtd "in basket"). From there, I do the capturing process.

Thing is, sometimes there's a *lot* of notes that I just want to refile to the "Notes" subtree from the corresponding project/context. A quick way to do that would be nice.

My idea was to use the org-speed-commands-user to have a single key to press for each category of note. I'd add entries like

("Q" (my/org-refile-to-id <ID of Notes-subtree from project Q> "TODO")

("W" (my/org-refile-to-id <ID of Notes-subtree from project W> "DONE")

("E" (my/org-refile-to-id <ID of Notes-subtree from project E> "")

At first, I tried using org-refile, but couldn't find a way to tell it to refile to a specific subtree (eg, using its id).

Then I started hackstumbling around. So far, what I could come up with was:

(defun my/org-refile-to-id (id &optional todo)                                                                                                                                                 
  "Refile current subtree to subtree with ID."                                                                                                                                                 
   (list (read-string "ID: ")))                                                                                                                                                                
  (when todo (org-todo todo))                                                                                                                                                                  
  (let ((anchor (ignore-errors (org-id-get-create))))                                                                                                                                          
    (org-id-goto id)                                                                                                                                                                           
    (zap-to-char 1 (string-to-char " "))                                                                                                                                                       
    (move-beginning-of-line nil)                                                                                                                                                               
    (if anchor                                                                                                                                                                                 
        (org-id-goto anchor)                                                                                                                                                                   
     (message "This was the last one."))))                                                                                                                                                     

It feels kinda messy, though.

Any advice would be more than welcome!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]