-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
org-ql-refile
makes assumptions about org-refile-targets
that conflict with the latter's docstring
#487
Comments
org-ql-refile
makes assumptions about org-refile-targets
that conflict with the latter's doctoringorg-ql-refile
makes assumptions about org-refile-targets
that conflict with the latter's docstring
Hi, Thanks for the well-written bug report. Sounds like an oversight, indeed. I'll fix it when I get time, or patches welcome in the meantime. |
I don't feel competent enough to suggest a patch, but I'm thinking something like this minimal fix might suffice? (defun org-ql-refile (marker)
"Refile current entry to MARKER (interactively, one selected with `org-ql').
Interactive completion uses files listed in `org-refile-targets',
which see (but only the files are used)."
(interactive (let ((buffers-files (delete-dups
;; Always include the current buffer.
(cons (current-buffer)
(cl-loop for (files-spec . _candidate-spec) in org-refile-targets
append (cl-typecase files-spec
(null (list (current-buffer)))
(symbol
(cond ((fboundp files-spec)
(pcase (funcall files-spec)
((and (pred stringp) file) (list file))
((and (pred listp) files) files)))
((boundp files-spec)
(pcase files-spec
((and (pred stringp) file) (list file))
((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))
(marker-buffer marker))))
(org-refile nil nil
;; The RFLOC argument:
(list
;; Name
(org-with-point-at marker
(nth 4 (org-heading-components)))
;; File
(buffer-file-name buffer)
;; nil
nil
;; Position
marker)))) |
|
Would this be better? (defun org-ql-refile (marker)
"Refile current entry to MARKER (interactively, one selected with `org-ql').
Interactive completion uses files listed in `org-refile-targets',
which see (but only the files are used)."
(interactive (let ((buffers-files (delete-dups
;; Always include the current buffer.
(cons (current-buffer)
(cl-loop for (files-spec . _candidate-spec) in org-refile-targets
append (cl-typecase files-spec
(null (list (current-buffer)))
(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)))
(list files-spec)))))))
(list (org-ql-completing-read buffers-files :prompt "Refile to: "))))
(let ((buffer (or (buffer-base-buffer (marker-buffer marker))
(marker-buffer marker))))
(org-refile nil nil
;; The RFLOC argument:
(list
;; Name
(org-with-point-at marker
(nth 4 (org-heading-components)))
;; File
(buffer-file-name buffer)
;; nil
nil
;; Position
marker)))) |
Probably so. The best way to move forward would be to submit a pull request. :) |
OS/platform
macOS
Emacs version and provenance
GNU Emacs 29.4 (build 2, aarch64-apple-darwin21.6.0, NS appkit-2113.65 Version 12.7.4 (Build 21H1123)) of 2024-08-19
Using
emacs-plus
Emacs command
/opt/homebrew/bin/emacs -Q
Org version and provenance
Org mode version 9.6.15 (release_9.6.15 @ /opt/homebrew/Cellar/emacs-plus@29/29.4/share/emacs/29.4/lisp/org/)
org-ql package version and provenance
Version: 0.9-pre, acquired using straight via use-package
Actions taken
I called
org-ql-refile
on an org-mode heading.Observed results
Saw the following error:
Expected results
In my config,
+org-dump
is a variable whose value is a particular directory not among myorg-agenda-files
. I did not expectorg-ql-refile
would expect it to be a function. The variable appears in my configuration of the variableorg-refile-targets
, whose value in my config is as follows:Backtrace
Etc.
By stepping through a call to
org-ql-refile
my understanding is thatorg-ql-refile
is assuming that the car of each cons cell inorg-refile-targets
is a function (as far as I can tell, that's what this line suggests). But the docstring fororg-refile-targets
gives the user the option to use either a variable or a function:For now I'm just defining a function which outputs the current value of
+org-dump
. Perhaps that's the correct approach, but the documentation suggests that there's nothing wrong with my having a cons cell whose car is a variable. Indeed,org-refile
works just fine in my system when+org-dump
is just a variable.The text was updated successfully, but these errors were encountered: