Skip to content
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

Set scope to tree or region #41

Open
hubisan opened this issue Aug 27, 2019 · 3 comments
Open

Set scope to tree or region #41

hubisan opened this issue Aug 27, 2019 · 3 comments

Comments

@hubisan
Copy link

hubisan commented Aug 27, 2019

Org-map-entries has a scope argument that determines the scope of the command.

It supports the following values among others:

tree    The subtree started with the entry at point
region  The entries within the active region, if any

Can this be done with org-ql (limit the headlines parsed to a subtree or region)?

@hubisan
Copy link
Author

hubisan commented Aug 28, 2019

I found a working solution:

(with-current-buffer (org-get-indirect-buffer)
  (org-narrow-to-subtree)
  ;; (narrow-to-region)
  (org-ql (current-buffer) nil :narrow t :action (org-get-outline-path t))
  (kill-current-buffer))

Can this be added with a keyword :scope with values tree and region?

@alphapapa
Copy link
Owner

Hi,

For region, :narrow t already does that.

For tree, I am thinking about how to best implement more complex search targets. See notes at https://github.com/alphapapa/org-ql/blob/master/notes.org#a-outline-path-in-buffers-files-arg It should probably also accept markers, or maybe (buffer . pos) cells. It will require some refactoring in a few places, so I'll probably do that for version 0.3 or something like that.

Thanks.

@alphapapa alphapapa self-assigned this Aug 29, 2019
@hubisan
Copy link
Author

hubisan commented Aug 29, 2019

Sounds promising. This is actually close to the capturing templates target element syntax.

So BUFFERS-FILES can be one of the following expression or an expression which evaluates to a list of files, buffers or one of the following expressions:

  • Outline path (olp "file or buffer name" "Level 1 heading" "Level 2" ...)
    Search the subtree of parent heading matching outline path in file or buffer.
  • ID (id "file or buffer name" "id_name")
    Search the subtree of parent heading matching ID in file or buffer.
  • Point (point "file or buffer name" point)
    Search the subtree at point in file or buffer.
  • Marker (marker #<marker>):
    Search the subtree at marker.

Maybe in addition:

  • Bookmark (bookmark "file or buffer name" "bookmark name")
    Search the subtree at bookmark.
  • Function (function (lambda () (...)))
    Search the subtree at the location returned by function)

An example:

(org-ql (buffer
         "~/org/ideas.org"
         (olp "~/org/inbox.org" "Emacs" "Ideas")
         (id "~/org/someday.org" "ideas")
         (point "~/org/tickler.org" 312))
  (todo "NEXT"))

To include the parent an option could be added:

(olp "~/org/inbox.org" "Emacs" "Ideas" :parent t)

And thx a lot for making org-ql.

@alphapapa alphapapa added this to the 0.5 milestone Jan 3, 2020
@alphapapa alphapapa modified the milestones: 0.5, 0.6 Nov 20, 2020
@alphapapa alphapapa modified the milestones: 0.6, Future Jun 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants