Fix org-ql-refile so that it handles all possible values for org-refile-targets

As per the documentation of `org-refile-targets`, each specification of the files in a given cons cell can be a list of files "or a symbol whose function or variable value will be used..." This ensures `org-refile-targets` can handle the case where the specification is a symbol with a variable value.
This commit is contained in:
apc 2025-02-11 21:03:13 -05:00 committed by GitHub
parent 98c62ab0a6
commit 95dd23ee92
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -117,9 +117,12 @@ which see (but only the files are used)."
(cl-loop for (files-spec . _candidate-spec) in org-refile-targets
append (cl-typecase files-spec
(null (list (current-buffer)))
(symbol (pcase (funcall files-spec)
(function (pcase (funcall files-spec)
((and (pred stringp) file) (list file))
((and (pred listp) files) files)))
(symbol (pcase (eval files-spec)
((and (pred stringp) file) (list file))
((and (pred listp) files) files)))
((and (pred listp) files) files)))
(list files-spec)))))))
(list (org-ql-completing-read buffers-files :prompt "Refile to: "))))
(let ((buffer (or (buffer-base-buffer (marker-buffer marker))
@ -136,7 +139,6 @@ which see (but only the files are used)."
nil
;; Position
marker))))
;;;###autoload
(defun org-ql-find-in-agenda ()
"Call `org-ql-find' on `org-agenda-files'."