emacs/var/elfeed/db/data/ba/ba7191507eac05fe003b5011813bb66ad7a70215
2022-01-03 12:49:32 -06:00

1 line
2.7 KiB
Plaintext

<!-- SC_OFF --><div class="md"><p>I tried to make <code>org-refile-copy</code> do more of the things I&#39;d like to by wrapping it in a function like below, alas without success so far.</p> <pre><code>(defun paf/refile-ai-targets () &quot;Does an org-refile-copy of an AI, with some linking and side-effects. This does add a link to the original =AI= in the new task, as well as mark the =AI= as done, and change the refiled target to a =TODO=.&quot; (interactive) (let* ((orig-marker (save-excursion (org-back-to-heading) (point-marker))) ;; make sure the to-be-filed entry has an ID (orig-id (org-id-get-create))) (progn (let ((org-refile-keep t)) (org-refile nil nil nil &quot;Move AI&quot;)) ;; Now we are back at the orig location, so force change the ID ;; (as it has been copied) (org-id-get-create t) ;; t =&gt; force change (org-todo &#39;done) ;; Now take a link with the new forced ID, ;; go to the refiled location, and modify the ;; refiled entry. (let ((orig-link (org-store-link nil))) (org-refile-goto-last-stored) (org-todo &quot;TODO&quot;) (org-entry-put (point) &quot;AI&quot; orig-link))) ;; Now move back to where we started to not jar the user (hypb:goto-marker orig-marker))) </code></pre> <p>However it does not seem to work reliably. When I run it, just after launching Emacs, it fails in the <code>org-refile-goto-last-stored</code> by claiming the bookmark it needs to create is in a buffer that is not backed by a file. I am not sure how to figure out which buffer that could be.</p> <p>If I then do <code>M-x bookmark-jump</code> and select the <code>org-refile-last-stored</code> it does go to the right place, and after that, the function seems to work. It does not display the window that asks for the refile text though.</p> <p>Regular <code>org-refile-copy</code> works flawlessly before and after this. </p> <p>did I misunderstand something basic in how to use these interactive functions in a programmatic way ? I am not quite sure about the marker and location handling (I played a bit with <code>save-excursion</code> but it seems to not hold across <code>org-refile-copy</code> calls) and am quite a noob in elisp...</p> <p>The code I use is here: <a href="https://github.com/pascalfleury/emacs-config#implement-my-own-ai-refiling">https://github.com/pascalfleury/emacs-config#implement-my-own-ai-refiling</a> which is a pointer into my whole config too.</p> </div><!-- SC_ON --> &#32; submitted by &#32; <a href="https://www.reddit.com/user/paf-paf-paf"> /u/paf-paf-paf </a> <br/> <span><a href="https://www.reddit.com/r/orgmode/comments/pnj1tl/empowering_orgrefile_with_issues/">[link]</a></span> &#32; <span><a href="https://www.reddit.com/r/orgmode/comments/pnj1tl/empowering_orgrefile_with_issues/">[comments]</a></span>