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

Sorting entries in helm-org-ql #101

Open
akirak opened this issue Mar 7, 2020 · 7 comments
Open

Sorting entries in helm-org-ql #101

akirak opened this issue Mar 7, 2020 · 7 comments
Milestone

Comments

@akirak
Copy link
Contributor

akirak commented Mar 7, 2020

I am using helm-org-ql-source in this project, and now I'd rather want to display items in a way where lower-level items are shown first. Is it possible to sort entries in helm-org-ql?

@alphapapa
Copy link
Owner

An argument could easily be added to helm-org-ql-source to pass a sorting argument to org-ql-select.

(cl-defun helm-org-ql-source (buffers-files &key (name "helm-org-ql"))

@akirak
Copy link
Contributor Author

akirak commented Mar 8, 2020

I added :sort argument to org-ql-select in helm-org-ql.el, but it didn't work. It must be because the action returns a heading text, not an element.

@alphapapa
Copy link
Owner

alphapapa commented Mar 8, 2020

Oops, you're right, sorry for sending you down the wrong path there.

I guess what we should do is, when a sorting argument is given, use the element action, and then map the helm-org-ql--heading across the results (which will require going to each result's buffer and position). We could do that regardless of whether there's a sorting argument, but I want the Helm command to be as fast and responsive as possible, so I'd prefer to not go through that extra work when sorting isn't used.

@akirak
Copy link
Contributor Author

akirak commented Mar 9, 2020

Thank you for your comment.

I also wonder if it is possible to skip subtrees (##89) in helm-org-ql. It probably should be optional, but it will have a great impact on sorting performance, since it reduces the number of items.

@alphapapa
Copy link
Owner

It would have to be optional, yes.

@akirak
Copy link
Contributor Author

akirak commented Mar 10, 2020

Maybe you can parse elements and generate outlines in a single path. With candidate-transformer, filtered-candidate-transformer, or filter-one-by-one of the helm source, you can store both the headline and the element in a single cell. Parsing elements would be a performance cost anyway, so you would want to avoid it when sorting is unused.

helm-source is indeed an interesting read. You may be able to change the sorting method after dispatching a helm session using candidate-transformer.

@alphapapa
Copy link
Owner

Yeah, there are a lot of possibilities. I generally try not to get too fancy with Helm sources' options. I used transformers for sorting in org-rifle, but something changed and it broke (not sure whether due to a change in Helm, Org, or my own code). Sometimes Helm changes without warning, as well, and I try to minimize chances of breakage due to something that's out of my control.

@alphapapa alphapapa added this to the Future milestone Apr 7, 2020
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