org-ql-select with custom predicate does not refresh cache between searches #485
-
OS/platformopenSUSE Leap 15.6 Emacs version and provenanceEmacs 29.4 - installed through openSUSE repository Emacs commandKRunner -> "emacs" Org version and provenanceorg version 9.6.15 - builtin to emacs org-ql package version and provenance20240222.200 Actions takenBefore meetings I like to pull in topics I need to discuss with meeting attendees. I capture topics with a "topic" tag and a TARGET property that describes who this topic needs to be discussed with. See below:
I wrote a custom org-ql predicate to search for items where the TARGET property matches a name:
I then use this predicate in a simple function (simplified for a reprex here):
Observed resultsThe function inserts Bob's topics for both names IF the topics are found in a separate org file and the org-ql-search scope is set to "org-agenda-files":
If the topics are found in the same org file where they are supposed to be inserted and the org-ql-search scope is set to "current-buffer" it works correctly:
I am completely guessing here that the items for Bob were returned both times because of a caching issue between searches. That does not explain why it works when the search is within current buffer though. I'm really at a loss of what to do about it or anything else I could test to find the source of the problem. Expected resultsThe result should be:
BacktraceNo response Etc.No response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hello, Before debugging your code, I can't help but notice that your scenario:
...is virtually identical to that of the custom predicates tutorial:
And that your predicate is essentially the same as the first example in the tutorial: (org-ql-defpred person (name)
"Search for entries with the \"person\" property being NAME."
:body (property "person" name)) ...but with superfluous code: (org-ql-defpred target (name)
"Search for entries where the \"TARGET\" property matches the supplied name."
:body (and (property "TARGET")
(string-match name (org-entry-get (point) "TARGET")))) So my first suggestion would be to read that tutorial and follow the code examples there as closely as possible. If you do all that and still can reproduce a problem, you'll need to reproduce it in a clean Emacs configuration, e.g. using https://github.com/alphapapa/with-emacs.sh and provide a recipe that works in a clean environment. |
Beta Was this translation helpful? Give feedback.
-
By the way, a problem in your code appears to be that you have quoted the query expression, rather than backquoting it and unquoting the |
Beta Was this translation helpful? Give feedback.
By the way, a problem in your code appears to be that you have quoted the query expression, rather than backquoting it and unquoting the
name
variable, so the name from thedolist
is not inserted into the query expression. See(info "(elisp) Backquote")
.