-
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
Library-provided org-agenda-skip-function
builder?
#377
Comments
"E.L.K." ***@***.***> writes:
The `org-ql` is great for filtering the agenda, but as far as I can see it does not provide "out of the box" method to build filters suitable to be used in `org-agenda-skip-function`.
So I suggest to add one:
...
Another approach that also utilizes cache is https://github.com/yantar92/emacs-config/blob/master/config.org#archiving
|
That's because it's designed to replace Nevertheless, So I'm not opposed to offering a feature like this, for circumstances in which An important caveat to note is that using yantar92's code example is an interesting way to use a cache to avoid re-running the same skip function more than necessary; I'd probably decline to add that to I'd also recommend writing this feature with a function rather than a macro, as generally there's no need for it to be one. Finally, the function that rewrites the query's symbols should take the |
Please take a look: It's now a function, not a macro (now it requires lexical bindings). Also it now converts by referring (defun org-ql-agenda-skip-if (query)
(cl-labels (
;; recurses into list form and replaces all predicates which are
;; registered in org-ql-predicates
(replace-predicate-names (form)
(if (listp form)
(let* ((fn (car form))
(as-predicate (alist-get fn org-ql-predicates))
(rest (cdr form)))
(cons
(if as-predicate
(plist-get as-predicate :fn)
fn)
;; also replace for all args
(mapcar #'replace-predicate-names rest))
)
form))
(next-headline () (save-excursion
(or (outline-next-heading)
(point-max)))))
(let ((updated-query (replace-predicate-names query)))
(lambda ()
(save-excursion
;; org-ql predicates work best on the start of heading
(outline-back-to-heading)
;; if condition matched, go to next headline
(when (eval updated-query)
(next-headline))))))) |
For my case, using provided function speeds up generating (actually _re_generating, first generating still rather slow) big weekly agenda 5-7 times, so maybe some optimizations are lost, but still this is much faster than what I had before. And also |
The
org-ql
is great for filtering the agenda, but as far as I can see it does not provide "out of the box" method to build filters suitable to be used inorg-agenda-skip-function
.So I suggest to add one:
This macro takes form, and adds "org-ql--predicate-" prefix to any symbol in function position except of "and", "or" and "not".
The usage is pretty straighforward:
test file:
The text was updated successfully, but these errors were encountered: