org-ql icon indicating copy to clipboard operation
org-ql copied to clipboard

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

Open nmartin84 opened this issue 5 years ago • 19 comments

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:

nmartin84 avatar Nov 11 '20 20:11 nmartin84

Thanks, good idea.

alphapapa avatar Nov 12 '20 00:11 alphapapa

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.

yantar92 avatar Dec 29 '20 16:12 yantar92

@yantar92 I post something like that here : https://github.com/org-roam/org-roam/issues/1336

reyman avatar Dec 31 '20 14:12 reyman

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.

hyan46 avatar Jul 16 '21 05:07 hyan46

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

alphapapa avatar Jul 16 '21 10:07 alphapapa

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

alphapapa avatar Sep 22 '21 05:09 alphapapa

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.

akirak avatar Sep 20 '22 19:09 akirak

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

zeroset avatar Mar 14 '23 11:03 zeroset

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:

  • https://github.com/alphapapa/org-ql/compare/wip/dynamic-block-improvements
  • https://github.com/alphapapa/org-ql/commit/65a5ff7c9afa2d4188f82cc6d7e124dff522e002

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 avatar Mar 14 '23 11:03 alphapapa

See also this branch, which I think will be very useful: https://github.com/alphapapa/org-ql/commit/70cfee6d570875bd19cc1e2b711d2b51e9432c20

alphapapa avatar Mar 14 '23 11:03 alphapapa

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

Looks awesome, i will give it a try.

zeroset avatar Mar 14 '23 12:03 zeroset

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:

  • https://github.com/alphapapa/org-ql/compare/wip/dynamic-block-improvements
  • 65a5ff7

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 (https://github.com/alphapapa/org-ql/commit/65a5ff7c9afa2d4188f82cc6d7e124dff522e002#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 (https://github.com/alphapapa/org-ql/commit/65a5ff7c9afa2d4188f82cc6d7e124dff522e002#diff-4b3992feea362ab38c27e90987e7151d2d9d7f3f41e1ec4ee7973ca0ef00b969R387).

nickanderson avatar Feb 09 '24 05:02 nickanderson