-
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
Refile and capture to result of a query #177
Comments
There are many possibilities like this that could be enabled by an A few notes about your code: (defun my/org-refile-to-monthly-review ()
(interactive)
(my/org-refile-to-query '(parent (string-equal (org-id-get) "b5fd67ea-2459-472f-836e-deb113602913")))) That will be a very slow query to execute, because it will have to call those functions on every heading. Org IDs are properties, so use the As well, it doesn't seem necessary to use a (defun my/org-parse-headline ()
"Parse headline at point and put in some more relevant information"
(--> (org-element-headline-parser (line-end-position))
(nth 1 it)
(plist-put it :entry-text
(concat
(buffer-file-name)
":"
(number-to-string (line-number-at-pos))
":"
(buffer-substring (line-beginning-position)
(line-end-position))))
(plist-put it :file-name (buffer-file-name))
(plist-put it :id (org-id-get-create))
(plist-put it :buffer (current-buffer)))) That function should not be necessary for refiling an entry. Look at the results returned by the |
alphapapa <[email protected]> writes:
There are many possibilities like this that could be enabled by an `org-ql` query. How best to integrate them is the question. In the future, some kind of `org-ql-tools` package might be called for. In the meantime, examples like this are probably best shown in documentation.
Ok, that makes sense. I guess I can send a PR to the examples.org file?
A few notes about your code:
Thanks for the feedback!
```el
(defun my/org-refile-to-monthly-review ()
(interactive)
(my/org-refile-to-query '(parent (string-equal (org-id-get) "b5fd67ea-2459-472f-836e-deb113602913"))))
```
That will be a very slow query to execute, because it will have to call those functions on every heading. Org IDs are properties, so use the `property` predicate, and it will be many times faster.
Ok, I will make sure to update the code.
As well, it doesn't seem necessary to use a `parent` query. Put the ID on the heading to which you want to refile the entry, and search for it directly using `property`. That way the query will return one result: the heading to be refiled to.
This is actually intentional but it isn't clearly communicated. The
entry with the above ID has 12 subtrees, one for every month. The idea
is that I can choose which of the subtrees I want to refile to.
That function should not be necessary for refiling an entry. Look at the results returned by the `elements-with-markers` action. All you need for the target is the marker.
I use that information to display text in the `completing-read' prompt.
The file name and line number provides important context and keeps the
entries unique. This needs to be computed for each matched entry so I
think I will keep the function.
|
Before submitting a PR, please post the finished code here.
Cool, thanks. |
FWIW, the refile idea should be covered by Line 93 in 4c1a4b1
A capture command is yet to be implemented, but the Org Capture API doesn't seem naturally suited to it (e.g. there doesn't appear to be a function that takes a marker argument to say "capture to here"). |
Adam Porter ***@***.***> writes:
A capture command is yet to be implemented, but the Org Capture API doesn't seem naturally suited to it (e.g. there doesn't appear to be a function that takes a marker argument to say "capture to here").
org-capture-templates may have target set to function that moves point
to capture location.
…--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
|
I'm not sure if this is in the scope of this project so I'm opening this issue to ask about that.
I have written a first implementation for refiling and capturing to the result of an org-ql query. This is useful for people who want more precise refiling or capturing. You can find the implementation here: https://github.com/Zetagon/literate-dotfiles/blob/master/config.org#refiling .
The code is probably not pull request ready, but if you'd like I can prepare a pull request. Otherwise I'll just leave it here in case somebody in the future looks for this functionality.
The text was updated successfully, but these errors were encountered: