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

:auto-category doesn't reflect updates in org-ql-view #167

Open
akirak opened this issue Dec 15, 2020 · 9 comments
Open

:auto-category doesn't reflect updates in org-ql-view #167

akirak opened this issue Dec 15, 2020 · 9 comments
Assignees
Milestone

Comments

@akirak
Copy link
Contributor

akirak commented Dec 15, 2020

I have the following entry in org-ql-views:

'("Maybe" "maybe.org" (level 1)
  :super-groups
  ((:auto-category)))

It groups top-level headings in maybe.org by categories.

When I update CATEGORY property of a heading in org-mode and refresh the view buffer using org-ql-view-refresh, the heading still remains in the previous category. This might be about cache expiration, but I haven't investigated the details. This is probably a bug.

@alphapapa
Copy link
Owner

When a buffer is modified, cached results for that buffer are no longer used, and the query is run in it anew. I don't know how the buffer could be modified without invalidating that buffer's cached results. Can you reproduce it in a clean Emacs config?

Note as well that grouping is a feature provided by org-super-agenda, so if there is a bug, it could be in either package, I guess.

@akirak
Copy link
Contributor Author

akirak commented Dec 15, 2020

It turns out that org-get-category returns the same value after the value is changed.

org-get-category is defined as follows, and it returns the correct result when force-refresh is set to t.

(org-get-category &optional POS FORCE-REFRESH)

@akirak
Copy link
Contributor Author

akirak commented Dec 15, 2020

In conclusion, this is not a bug with org-ql. It would be possible to work around this issue in org-super-agenda.el (in the following code), but I think org.el should invalidate the category cache whenever category is updated by org-set-property. In terms of performance, cache invalidation should occur only once per buffer, and not on every heading.

(org-super-agenda--def-auto-group category "their org-category property"
  :key-form (org-super-agenda--when-with-marker-buffer (org-super-agenda--get-marker item)
              (org-get-category))
  :header-form (concat "Category: " key))

@alphapapa
Copy link
Owner

Yeah, that seems like an oversight in Org.

@akirak
Copy link
Contributor Author

akirak commented Dec 16, 2020

Thanks, I'll consider if I can contribute to Org.

@akirak
Copy link
Contributor Author

akirak commented Dec 16, 2020

I looked into this issue again. I am sorry, but you will have to work on it.

org-agenda.el doesn't suffer from this issue, and grouping with :auto-category works in (non-ql) agenda buffers even when categories are changed. It turns out that org-refresh-category-properties is called inside org-agenda-prepare-buffers function.

Org Ql already has its own cache system which properly detects modification. Thus you would probably have to call org-refresh-category-properties to refresh the category cache inside/before org-ql--select, which would degrade performance to some extent.

Because performance is one of the selling points of this package, it would be better if category refreshing were done only when needed, but I don't know if it could be implemented in a simple way.

When there is no modification in the buffer, Org Ql will remain as fast as it is now.

@akirak akirak reopened this Dec 16, 2020
@alphapapa
Copy link
Owner

alphapapa commented Dec 16, 2020

I guess this will require a minor bit of infrastructure to do per-buffer preparation before running certain queries. Thanks for looking into it.

@alphapapa alphapapa self-assigned this Dec 16, 2020
@alphapapa alphapapa added this to the 0.6 milestone Dec 16, 2020
@alphapapa
Copy link
Owner

Deferring this to 0.7.

@alphapapa alphapapa modified the milestones: 0.6, 0.7 Jun 18, 2021
@alphapapa alphapapa modified the milestones: 0.7, 0.8 Mar 10, 2023
@alphapapa alphapapa modified the milestones: 0.8, Future Dec 16, 2023
@alphapapa
Copy link
Owner

Deferring again. With the org-element caching features now under active development in Org, the org-get-category function looks a bit different now. This issue should probably be retested and the potential solutions, if necessary, reevaluated.

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