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

[FEATURE] Add :file header argument to org-ql dynamic blocks #151

Open
Zyrohex opened this issue Nov 11, 2020 · 17 comments
Open

[FEATURE] Add :file header argument to org-ql dynamic blocks #151

Zyrohex opened this issue Nov 11, 2020 · 17 comments
Assignees

Comments

@Zyrohex
Copy link

Zyrohex commented Nov 11, 2020

Dynamic blocks are great, could we add :file (or :from if you want to stay consistent with your documentation) as a header argument to specify what files org-ql searches?

Example:

#+BEGIN: org-ql :query "todo: priority:A,B" :columns (todo (priority "P") deadline heading) :sort (deadline priority) :take 7 :ts-format "%Y-%m-%d %H:%M :file org-agenda-files"
| Todo | P | Deadline         | Heading                               |
|------+---+------------------+---------------------------------------|
| TODO | A | 2017-07-07 00:00 | Take over the world                   |
| TODO | B | 2017-07-10 00:00 | Renew membership in supervillain club |
| TODO | A | 2017-07-15 00:00 | Take over the universe                |
| TODO | B | 2017-07-21 00:00 | Internet                              |
| TODO | A | 2017-08-01 00:00 | Spaceship lease                       |
| TODO | A |                  | Skype with president of Antarctica    |
| TODO | B |                  | Take over Mars                        |
#+END:
@alphapapa alphapapa self-assigned this Nov 12, 2020
@alphapapa alphapapa added this to the 0.5 milestone Nov 12, 2020
@alphapapa
Copy link
Owner

Thanks, good idea.

@yantar92
Copy link
Contributor

One good example how this feature can be used is automatic backlinks. It becomes trivial to list all the headings containing links to current heading.

@reyman
Copy link

reyman commented Dec 31, 2020

@yantar92 I post something like that here : org-roam/org-roam#1336

@hyan46
Copy link

hyan46 commented Jul 16, 2021

I would love to see this! My personal need is just to be able to select the options of either using the org-agenda-files or current-buffer. These two options are enough for me. Specifying the file could give more freedom but this is not necessary to me. My entire purpose is to put the dynamic blocks to create a daily, weekly, or monthly review template by querying my org-agenda-files.

@alphapapa
Copy link
Owner

This should probably depend on the fixes discussed in #228.

@alphapapa
Copy link
Owner

Retargeting this for 0.7. 0.6 has been delayed for too long.

@akirak
Copy link
Contributor

akirak commented Sep 20, 2022

I'm looking forward to this feature coming. I also noticed that clocktable dynamic blocks has scope parameter. You may or may not want to follow its interface.

@alphapapa alphapapa modified the milestones: 0.7, 0.8 Mar 10, 2023
@zeroset
Copy link

zeroset commented Mar 14, 2023

Any news about this feature? Would be awesome in combination with org roam and todo lists.

@alphapapa
Copy link
Owner

Actually, yes. I pushed a WIP branch with some improvements, including adding a :from argument to the blocks that can accept a list of filename strings:

It also includes some other small improvements, like using relative timestamps for and adding a planning column.

Feel free to try it out and let me know what you think. It could probably go into a v0.8-pre commit soon.

@alphapapa
Copy link
Owner

See also this branch, which I think will be very useful: 70cfee6

@zeroset
Copy link

zeroset commented Mar 14, 2023

See also this branch, which I think will be very useful: 70cfee6

Looks awesome, i will give it a try.

@alphapapa alphapapa removed this from the 0.8 milestone Dec 16, 2023
@nickanderson
Copy link

Actually, yes. I pushed a WIP branch with some improvements, including adding a :from argument to the blocks that can accept a list of filename strings:

It also includes some other small improvements, like using relative timestamps for and adding a planning column.

Feel free to try it out and let me know what you think. It could probably go into a v0.8-pre commit soon.

Ah, great I have been wanting dynamic blocks that source from other files. I added ((pred functionp) (funcall from)) so that :from could be a function (65a5ff7#diff-4b3992feea362ab38c27e90987e7151d2d9d7f3f41e1ec4ee7973ca0ef00b969R309). It doesn't seem to want to use id links for the headlines. Swapping out (format-element element) for link does make it use the id link, but it sticks it in the first column only (65a5ff7#diff-4b3992feea362ab38c27e90987e7151d2d9d7f3f41e1ec4ee7973ca0ef00b969R387).

@Fackelmann
Copy link

Any updates on that branch? This feature would be really useful for people with multiple agenda files and would bring org-ql closer to parity with Obsidian's dataview.

@alphapapa
Copy link
Owner

Any updates on that branch? This feature would be really useful for people with multiple agenda files and would bring org-ql closer to parity with Obsidian's dataview.

Hi,

If you mean the branch at https://github.com/alphapapa/org-ql/compare/wip/dynamic-block-improvements, then I'd be glad to hear any feedback from anyone who'd like to test it. It should probably be rebased, though. Maybe I can do that this weekend...

@nickanderson
Copy link

I would try to make time to test it. I have been using the elisp from here #239 (comment) with success for about 9 months.

@kofm
Copy link

kofm commented Nov 17, 2024

Hi,
thank you @alphapapa for working on this, I think it'll be very useful for many workflows.

I tried to test the branch (https://github.com/alphapapa/org-ql/compare/wip/dynamic-block-improvements) but I can't a find a way to make it work. Should the :from header also accept a simple string with the file name?

With either:
#+BEGIN: org-ql :from org-directory :query "todo:"
#+BEGIN: org-ql :from "~/nextcloud/org" :query "todo:"
#+BEGIN: org-ql :from ("~/nextcloud/org/refile.org" "~/nextcloud/org/job.org") :query "todo:"

I get:
Debugger entered--Lisp error: (error "Please avoid it") error("Please avoid it") pcase--u1(((or (match x126 quote effort)) (match element app cdr-safe (and (pred consp) (app car-safe _comparator-or-num) (app cdr-safe ...)))) ...

Looking at the debugger it seems that the :from header is correctly picked up:
org-ql-select(("~/nextcloud/org/refile.org" "~/nextcloud/org/job.org") (todo) :action element-with-markers :narrow nil :sort nil)

PS:

The code in #239 works correctly

@alphapapa
Copy link
Owner

@kofm The branch needs to be rebased. I don't know if I'll have time to work on this in the next few weeks. You might want to use the code from #239 for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants