-
Notifications
You must be signed in to change notification settings - Fork 110
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
Sort entries by due date when using org-ql-block #79
Comments
Thanks for the kind words. I'm glad it's helpful to you. Actually, there is no way to do that at the moment. That's an oversight on my part. I'll need to add additional arguments to the block function so |
Seconding the request |
No apologies needed! I will try to take a look at the code too 😄 |
Or maybe you can support the feature by adding a variable for a sorting strategy, like |
@akirak That's a good point. What do the rest of you think? |
I feel that it would be better to stick to built-in org-mode functions as much as possible. Otherwise, you may end up reimplementing the whole org-agenda.el from scratch. I believe that only the most performance-critical functions from org-agenda need to be reimplemented. |
@yantar92 The question here is only how to present the sorting argument in the block definition, not the implementation. In fact, org-ql is essentially a reimplementation of the agenda--that's the point, because org-agenda.el is very difficult to understand and modify, and nearly impossible to extend. |
I am ambivalent to either solution. But of course whichever method is easier to leverage upon the built in org mode functionality should be preferred, to make implementation easier. |
@jakejx Sorting is already implemented in org-ql. org-agenda sorting functions are not used. (If you're curious as to why, look at the code for the function The question here is whether to pass the sort argument like this, which is consistent with (setq org-agenda-custom-commands
'(("ces" "Custom: Agenda and Emacs SOMEDAY [#A] items"
((org-ql-block ('(and (todo "SOMEDAY")
(tags "Emacs")
(priority "A"))
:sort '(date priority todo)))
(agenda))))) or like this, which is more like org-agenda block settings: (setq org-agenda-custom-commands
'(("ces" "Custom: Agenda and Emacs SOMEDAY [#A] items"
((org-ql-block '(and (todo "SOMEDAY")
(tags "Emacs")
(priority "A"))
((org-ql-block-sort '(date priority todo))))
(agenda))))) I'm generally in favor of the first example, because it's consistent with |
(org-ql-block ('(and (todo "SOMEDAY")
(tags "Emacs")
(priority "A"))
:sort '(date priority todo))) This looks better than I expected. Actually, I now even prefer it over the other, because it allows easy migration to/from normal org-ql forms and requires less memorization of variable names.
Thanks, I'll take a look at it.
org-ql started out as a library for org-agenda-ng, which was an experiment by alphapapa to improve upon the API of org-agenda. org-agenda-ng was merged into org-ql. As he develops org-ql, it is becoming a practical alternative to org-agenda. |
In a view on Also, replacing |
I looked into making sorting in Org Agenda performs sorting based on a Anyway, I found the way to make However, I realized that changing the way So I've pushed this WIP branch: https://github.com/alphapapa/org-ql/tree/wip/issue-79 for 0.5. |
this could be another bug, but for me it serves as a workaround:
i have a dummy block before the
maybe this is related to #121, in the sense that there is some cleanup missing when initializing the agenda-buffer for org-ql. anyways, now i can sort the way i like :-) |
@bitclick I'm afraid that's not the case. As I explained in #79 (comment), org-ql blocks are not compatible with org-agenda sorting. You can test this for yourself as follows: In a clean Emacs instance:
(setq org-agenda-custom-commands
'(("A" "Today"
((todo "nothing here"
((org-agenda-sorting-strategy '(timestamp-down))))
(org-ql-block '(ts)
((org-ql-block-header "TEST")))))))
|
New to org-ql and org-super-agenda. I am trying to sort items by priority within a group defined by org-ql-block in org-agenda-custom-commands. Just saw this is still open. Does it mean I can not sort items within group of org-super-agenda with org-ql? I saw the doc of org-super-agenda said:
But I also saw a Reddit thread said:
So I am very confused: Is it possible to sort within a group of org-super-agenda (using |
Thanks for this work. I've been trying it out and found it tricky to properly declare org-agenda-custom-command so I'm pasting what I got working for others who make wander by. Pardon the spread-out syntax -- I had to do that to figure out what I kept doing wrong -- which was an incorrect combination of quoting. ("c" "<c>aptured things" ;; [1] key [2] description
org-ql-block ;; [3] function that select items
'( ;; [4] match/query expression
(property "CAPTURED") ;; arg1: org-query expression
:sort (priority date) ;; keyword arg
:header "xyzzy" ;; keyword arg
)
( ;; [5] list of extra settings
)
() ;; [6] list of files to export to
) ;; end of agenda entry definition |
Since this involves changing the format, what should probably be done is:
|
Retargeting this for 0.7. 0.6 has been delayed for too long. |
AFAICT I've been waiting for someone to confirm that it still works. At this point I should rebase it again first. |
Please see #459. My time is limited, so if someone else could test it and confirm that it works as expected, I'll document the changes and merge it. |
If trying out that branch and reporting back can help, I would gladly do it as soon as you get the time to rebase. |
@lyndhurst The PR #459 is rebased. Feel free to test it. Thanks. |
Thanks for the link, it is night time in my country, I will report back first thing in the morning. |
I had little time this morning, so I only installed the |
@alphapapa , I did some more testing, removing all the org-ql customizations and overrides I have in my config. And I get the same unexpected outcome. I have not tried any I created the following file:
And used this config: (setq org-agenda-files '("~/.local/share/org/tasks/test_test_testing_sort_feature.org"))
(setq org-agenda-custom-commands
'(("z" "Tests"
(
(org-ql-block '(scheduled)
(
(org-ql-block-header "Test SCHED")
(org-super-agenda-groups nil)
))
(org-ql-block '(or
(todo "TODO")
(scheduled)
)
(
(org-ql-block-header "Test OR")
(org-super-agenda-groups nil)
))
(org-ql-block '(and
(todo "TODO")
(scheduled)
)
(
(org-ql-block-header "Test AND")
(org-super-agenda-groups nil)
))
)))) Sorry for the unreadable file naming and ugly formatting, but, I used templates already set up in my config, and the formatting makes it easier for me to do a lot of changes quickly. Anyway, as you can see in the screenshot, Finally I have to specify that I am a Doom Emacs user and I switched to Emacs around 6 months ago, so I might be doing something wrong. Please let me know if I can do any more testing, or if you need additional info about the versions I have installed and so on.. |
@lyndhurst It looks like you're using the old argument style for org-ql-block. The reason this PR wasn't merged already is that it changes that. You need to use the new format. See #79 (comment) |
Thank you @alphapapa for the link. I had seen it before and wondered if there was a syntax mistake on my part. To be honest it took me a little while to get it to work. I think the main issue was that no errors are thrown when I make syntax mistakes, and I spent my time thinking I was stupid because the outcome did not make sense while actually I was stupid because I was not using Anyway, I added a little data to the test file to have more sorting material:
I managed to get a few blocks going with the following config: (setq org-agenda-files '("~/.local/share/org/tasks/test_test_testing_sort_feature.org"))
(setq org-agenda-custom-commands
'(("z" "Tests"
(
(org-ql-block '(scheduled
:sort (date)
:header "Test Date Sort")
)
(org-ql-block '(scheduled
:sort (priority)
:header "Test Priority Sort")
)
(org-ql-block '((or
(todo "TODO")
(scheduled))
:sort (date priority)
:header "Test OR Double Sort")
)
(org-ql-block '((or
(todo "TODO")
(scheduled))
:sort (priority date)
:header "Test OR Inverted Sort")
)
(org-ql-block '((and
(todo "TODO")
(scheduled))
:sort (priority)
:header "Test AND Filter")
)
)
))) It worked as I expected. Except maybe for the multiple sort criterias test blocks, it works fine, but the criterias have to be specified in the opposite order I would have expected: The last block is cut off, but not really interesting; it is a simple I also tried adding more options the the blocks:
(org-ql-block '((and
(todo "TODO")
(scheduled))
:sort (priority)
:header "Test AND Filter")
(org-super-agenda-groups nil)) It did not throw any error or unexpected results, but then I realized this testing file does not have anything to test groups on, so I am still unsure how to make that part of the new syntax work. I think this test shows that the sort functions, and basic functionalities work on my side. I would like to try with my regular blocks which are much more involved in terms of query filters, but it will take me a little more time to adjust them to the new syntax. I could do it tomorrow and let you know if it is of any interest. Please let me know if there is anything else I can do to help. |
I was wrong about not having anything to test groups on: this works: (org-ql-block '((or
(todo "TODO")
(scheduled))
:sort (priority date)
:header "Test OR Inverted Sort")
((org-super-agenda-groups '((:auto-planning))))
) And the blue header 'Test' that appears in every one of the screenshot's blocks are actually coming from my personal |
@lyndhurst I'm afraid that some of those blocks still have incorrect syntax. Here is what they should look like: (let ((org-agenda-files '("/tmp/test.org"))
(org-agenda-custom-commands
'(("z"
"Tests"
((org-ql-block '((scheduled)
:sort (date)
:header "Test Date Sort"))
(org-ql-block '((scheduled)
:sort (priority)
:header "Test Priority Sort"))
(org-ql-block '((or (todo "TODO") (scheduled))
:sort (date priority)
:header "Test OR Double Sort"))
(org-ql-block '((or (todo "TODO") (scheduled))
:sort (priority date)
:header "Test OR Inverted Sort"))
(org-ql-block '((and (todo "TODO") (scheduled))
:sort (priority)
:header "Test AND Filter")))))))
(org-agenda nil "z")) Note that that form can be evaluated as-is to test it, without changing the global bindings of those variables. I recommend using this pattern to test things with. Also, I recommend using
Please see the note in the changelog about the |
Thanks for the patience, I am not able to test further tonight, but the tests worked well in spite of the incorrect syntax. I will have another look tomorrow anyway. Sorry again about the formatting, I think it is the modal editing from evil-mode, but when testing and moving things around a lot I still have trouble with Elisp. I could format before posting though, that is a bit lazy on my part. For the last part on I may have to look at it again, because it took me a lot of error and trials to get the syntax to work (even if it is still off ;)), but I had the feeling the order I had to list the criterias in was the opposite of the one I would use in a sql GROUP BY for example. But I might be wrong, I will check again when trying to understand the correct syntax, and if it changes the results I get. Thanks again for the tips. |
No problem. There's no rush here.
No problem. I'm just sharing what I've learned.
Yes, I understood what you meant. What I wrote was an attempt to explain how that works.
You're right that it doesn't work exactly like SQL. It's actually more powerful, because you could write something like
I appreciate your help with testing these features. |
I took some time today to go over your last message with fresh rested eyes.
I just installed it, so I did not have time to write code yet, but, just playing around with it while testing more sorting blocks, it seems really fun to work with; maybe less select/cut/paste for me in the near future :)
I took the time to read your explanations more carefully, and went to the changelog too. The explanations are clear enough, it does require some focus though. I tinkered with my test file, and the reverse method, it seems like a very powerful tool giving the user a lot of control over the way their lists are displayed. I did not understand yesterday the fact that each element could be reversed independently within the sort method.
Yes, it might be challenging to explain that part to impatient readers (like me yesterday), or non-technical users. I would say simple examples to get the basic syntax and the general idea might be an interesting approach to get one started. Syntax can be a tough one as well at first, without your example right above, I might still be trying to make it work with some I am especially glad I went back over that part, this is valuable information. Thanks for that one as well. Anyway, I am not going to pollute the thread any more than necessary. I ran a few tests again, and everything works as expected now even Thanks for taking the time to show me the correct syntax, I was not too far off, I guess that is why my test blocks still worked yesterday. Let's say that When I first volunteered to do some testing, I had no idea what you needed from the tests, so please let me know if I can add anything else, especially now that I am all setup ! For example I was wondering, if it would help to keep using this branch in my everyday workflow see if anything unexpected occurs, or if that's it for now and I can switch back to |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
I could test it on my daily driver files and it worked flawlessly. Here is my config for reference:
Is that helpful ? |
@proudot Thanks, that's good to know. |
@alphapapa this is very useful to my workflow, so I am happy to help debugging this extensively. Can you explain what is needed to pass the bar for merging ? |
Whenever I have time to finish final tidying up and such. There are a number of PRs on my various projects, and I get to them when I can. |
Ho great ! I thought you needed more feedback before you consider it mature enough. My bad. Happy to help debugging stuff when needed. |
Hello, thank you for this wonderful package, it makes my custom agendas useable again!
I am in the process of porting some of my custom agenda commands I was wondering whether it was possible to sort my results based on the deadline. I tried using the conventional way of setting
org-agenda-sorting-strategy
, but I don't think it works. Here is what my agenda command looks likeIs setting the sorting strategy like this supported? Thanks!
The text was updated successfully, but these errors were encountered: