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

Unsure how to get "reverse" sort order in org-ql-search to work #292

Closed
balaji-dutt opened this issue Aug 1, 2022 · 7 comments
Closed

Comments

@balaji-dutt
Copy link

Hi,

I was recently looking for a way to get my org agenda view that uses org-ql to sort high priority items at the top, rather than the bottom. I came across #143 but despite a few attempts, it looks like I'm not understanding how to actually use this option.

Here is an extract from my .init.el for a custom org-agenda view:

    (setq org-agenda-custom-commands
          '(("d" "Grouped Agenda View"
             (
              ;; (agenda "" ((org-agenda-span 10)
              ;;             (org-agenda-start-on-weekday nil)
              ;;             (org-agenda-start-day "-7d")
              ;;             (org-agenda-entry-types '(:timestamp :sexp))))
              (org-ql-block '(todo "WIP")
                            ((org-ql-block-header "WIP"))
                            :sort '(date priority reverse))
              (org-ql-block '(or (todo "WAITING")
                                 (todo "HOLD"))
                            ((org-ql-block-header "On-Hold"))
                            :sort '(priority reverse date todo))
              (org-ql-block '(todo "TODO")
                            ((org-ql-block-header "Todo"))
                            :sort '(priority reverse date))
              (org-ql-block '(todo "MAYBE")
                            ((org-ql-block-header "Someday")))
              )

With the above config, this is what my org agenda view looks like:

image

Notice that in the WIP section the "#A" priority items are in the middle even though no item above it has a date estimate and in the TODO sections, the "#A" priority items are at the bottom.

I tried swapping the order of the commands, i.e, reverse priority date todo instead of priority reverse.. but that does not seem to change anything.

Can you please help me figure out what I'm doing wrong?

@alphapapa
Copy link
Owner

Did you try removing reverse?

@balaji-dutt
Copy link
Author

Hi @alphapapa I did try that. It still does not seem to entirely resolve the issue.

@alphapapa
Copy link
Owner

What does that mean?

@balaji-dutt
Copy link
Author

What does that mean?

Here is a snippet from my org-mode config where I have removed the reverse keyword from an org-agenda view:

  '(("d" "Grouped Agenda View"
     (
      ;; (agenda "" ((org-agenda-span 10)
      ;;             (org-agenda-start-on-weekday nil)
      ;;             (org-agenda-start-day "-7d")
      ;;             (org-agenda-entry-types '(:timestamp :sexp))))
      (org-ql-block '(todo "NEXT")
                     ((org-ql-block-header "Quick/Immediate Todo's"))
                     :sort '(date priority))
      (org-ql-block '(todo "WIP")
                     ((org-ql-block-header "WIP"))
                     :sort '(date priority))
      (org-ql-block '(or (todo "WAITING")
                         (todo "HOLD"))
                     ((org-ql-block-header "On-Hold"))
                     :sort '(priority date todo))
      (org-ql-block '(todo "TODO")
                     ((org-ql-block-header "Todo"))
                     :sort '(priority date))
      (org-ql-block '(todo "MAYBE")
                     ((org-ql-block-header "Someday")))
      )
     ;; (org-agenda-tag-filter-preset '("-ARCHIVE"))
     ;; ((org-agenda-compact-blocks t))
     ((org-agenda-block-separator 9472))
     )

Despite this change, when I set priorities for different items in my org-mode files, they do not seem to be sorted to appear at the top of the agenda list - see an example screenshot below:

Org-Agenda

@alphapapa
Copy link
Owner

It's hard to tell whether there's a bug here because there are so many parts and it's not reproducible. If you can put together a minimal working example using a clean Emacs configuration and a very simple input file, maybe we can figure out what's going on. I recommend using this script's sandbox feature to test this problem independently of your personal Emacs config: https://github.com/alphapapa/makem.sh

@alphapapa
Copy link
Owner

As well, there are several pieces of relevant information which you haven't reported in this issue. I recently added a bug reporting template, so please file a new issue and fill out the form so we'll have all the necessary information: https://github.com/alphapapa/org-ql/issues/new?assignees=alphapapa&labels=bug&projects=&template=bug_report.yml

@dev590t
Copy link

dev590t commented Jan 29, 2024

@balaji-dutt In title you write org-ql-search, but in your test, you use org-ql-block. I don't understand you have problem with which function.

About org-ql-block, It seem the sorting feature of org-ql-block isn't still merge into master:
#79 (comment)

Which branch do you use? Maybe you can test the branch https://github.com/alphapapa/org-ql/tree/wip/issue-79

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

3 participants