Thanks much @glucas, I've worked your solution into my final one. The key information was knowing the format of the RFLOC. I did experiment with
providing a list of filename and headline text, but I was missing those other elements, and the extra nil. This is what I ended up with:
(defun jay/refile-to (file headline)
"Move current headline to specified location"
(let ((pos (save-excursion
(find-file file)
(org-find-exact-headline-in-buffer headline))))
(org-refile nil nil (list headline file nil pos))))
(defun jay/refile-to-bookmarks ()
"Move current headline to bookmarks"
(interactive)
(org-mark-ring-push)
(jay/refile-to "~/Org/bookmarks.org" "New")
(org-mark-ring-goto))
The doc for save-excursion
states that we will be returned to the location that we started from, but it does not seem to work that way. It leaves me in the target destination, which might be proper for the general refile-to
, but I wanted to just have it move the line and remain where I was so I save and restore within refile-to-bookmark
.
The workflow that this is meant for is that I start with a list of HTML links that come from my script for reading RSS feeds. I originally had the script produce maildir files for mu4e, but found myself just following the links to a browser anyway and then bookmarking the ones of interest, so now I just generate a list of ** [[uri][title]]
lines. After I follow the link from emacs to the uzbl browser, instead of bookmarking (which generates the same form of lines) I use this command to move the link to my bookmarks.org after setting tags. Just a bit faster since I also use the org speed-commands, t
to tag and b
for this command. I'm happy now and love to learn more elisp!