I would like to create a function that uses the refile interface to jump to a heading (C-u C-c C-w or 'Refile-Goto'), where I can enter the filename and Heading as arguments. Following instructions here - org-refile to a known fixed location , I have written the following function that successfully refiles subtrees with arguments.
;;Org-Refile with parameters (defun my/refile-params (file headline) (interactive) (let ((pos (save-excursion (find-file file) (org-find-exact-headline-in-buffer headline)))) (org-refile nil nil (list headline file nil pos)))) (map! :leader :desc "file away" "zf" (lambda () (interactive) (my/refile-params "~/orgnotes/casenotes.org" "Destination")))
I have created another function that successfully calls Refile-Goto, but requires manually enter the destination.
;;Org-Refile-Goto without parameters (defun my/refile-goto () (interactive) (setq current-prefix-arg '(4)) (call-interactively (org-refile))) (map! :leader :desc "file away" "zn" (lambda () (interactive) (my/refile-goto)))
All seems good, but when I combine the two as below, instead of just jumping, it refiles, and throws up a Wrong Type Argument error to boot.
;;Org-Refile-Goto with Parameters *Not Working* (defun my/refile-params-goto (file headline) (interactive) (setq current-prefix-arg '(4)) (call-interactively (my/refile-params file headline))) (map! :leader :desc "Go to @In-Progress" "zg" (lambda () (interactive) (my/refile-params-goto "~/orgnotes/casenotes.org" "Destination")))
All help greatly appreciated.
NB: Using doom, if that helps understanding the keyboard mapping. Including the mapping lines, as they include 'lambda', which is mysterious black magic to me, so I may be getting it wrong.