-
Notifications
You must be signed in to change notification settings - Fork 118
Description
Hi,
First of all, Thank You Adam for such an amazing package. I'm just scratching the surface of it but I already see some interesting workflows that org-ql
can enable. Not only that but by reading the source code I've learnt a lot (I'm very new to Emacs, so lots to learn).
Awesome!
I noticed some strange behaviour when combining link
with or
. I've tried to reduce it to the simplest example to reproduce (it was an org-babel
file hence the current-buffer
; but Github does not allow for attaching of .org
files, neither understands what babel is):
* TODO Item 1
+ [[notmuch:id:one-message-id][One Message ID]]
+ [[notmuch:id:two-message-id][Two Message ID]]
* TODO Item 2
:PROPERTIES:
:EMAIL: [[notmuch:id:three-message-id][Three Message ID]]
:END:
+ [[notmuch:id:one-message-id][One Message ID]]
With the sample file above I try several things:
;; Expect Items 1 & 2. Does return items 1 & 2
(org-ql-select (current-buffer)
'(link "notmuch:id:one-message-id")
:action '(org-get-heading t t))
;; Expect Items 1 & 2. Does return items 1 & 2
(org-ql-select (current-buffer)
'(link :target "notmuch:id:one-message-id")
:action '(org-get-heading t t))
So the link
predicate works as expected. But strange things happen when you want to combine multiple link
predicates with either and
or or
:
;; Expect Item 1, returns nothing
(org-ql-select (current-buffer)
'(and (link "notmuch:id:one-message-id")
(link "notmuch:id:two-message-id"))
:action '(org-get-heading t t))
;; Expect Item 1, returns nothing
(org-ql-select (current-buffer)
'(and (link :target "notmuch:id:one-message-id")
(link :target "notmuch:id:two-message-id"))
:action '(org-get-heading t t))
And with or
:
;; Expect Items 1 & 2, returns Item 1
(org-ql-select (current-buffer)
'(or (link "notmuch:id:one-message-id")
(link "notmuch:id:three-message-id"))
:action '(org-get-heading t t))
;; Expect Items 1 & 2, returns Item 1
(org-ql-select (current-buffer)
'(or (link :target "notmuch:id:one-message-id")
(link :target "notmuch:id:three-message-id"))
:action '(org-get-heading t t))
So... I'm missing something; But according to my org-mode
I've already been at it for 2 hours without success!
Some more background. I use e-mail a lot, so much that more than half my org-mode
TODO items link to e-mails. So I wondered: Why not have a command that finds all TODO items that link to them? aka, backlinks from TODO to emails.
I use notmuch, so I think it is very easy: just combine notmuch-show-get-messages-ids
with a query (or (link :target "notmuch:id:....") (link...))
. And done. Except for the above. Now I realise (reading the code of org-sidebar) that this is probably a very underperforming way to do it, so I'll give it a go using regular expressions. Will be fun too :)
Nonetheless I'm really curious to understand why the above examples did not work.
I am on org-ql
0.6.1