Find all TODOS on non-namespaced pages

Hi! I have put namespaces to good use for really separate topics, where

  1. There is no contextual overlap and
  2. There may be redundant tags or pages

BUT, to make namespaces really work I need a way to exclude them from queries as well. How can I modify my standard TASK search, so that all namespaced pages are NOT included in the results?

{{query (task TODO DOING) }}

Assuming:

  • you talk about tasks on those pages, not tasks referencing those pages
  • you don’t want to exclude top level namespaces

You can use this advanced query:

#+BEGIN_QUERY
{:title [:h3 "Tasks without namespace"]
 :query [:find (pull ?b [*])
 :where
  [?b :block/marker ?marker]
  [(contains? #{"TODO" "DOING"} ?marker)]
  [?b :block/page ?p]
  (not [?p :block/namespace])
 ]
}
#+END_QUERY

If you need something more specific, let me know.

Siferiax, thanks a bunch, this works like a charm!

1 Like