Ihor Radchenko <yanta...@posteo.net> writes:

> Kristoffer Balintona <krisbalint...@gmail.com> writes:
>> Grouping email tasks by thread might make it easier to stumble upon such
>> stale todos, but if simply forget that a thread has associated todo(s),
>> then those stale todos would remain.

> So, by using agenda and apropriate scheduling/refiling, I can make sure
> that nothing that should be done is lost, while "wishlist" things are
> not overwhelming me.

True, but for the less orderly among us, I suspect backlinks might still
be helpful. :)

I'm already 200 lines of code and commentary into doing that for mu4e,
but your message somehow made me realize that half of it could be done
in a much simpler and partly better way with:

  (defun my/mu4e-org-agenda (msg)
    "Do an Org agenda search for items linking to MSG."
    (let* ((msgid (mu4e-message-field msg :message-id))
           ;; Local binding for this search
           (org-search-view-force-full-words nil)) 
      (org-search-view nil msgid)))

  (add-to-list 'mu4e-view-actions ; Shortcut: `a'
               '("agenda search" . my/mu4e-org-agenda) t) 

This adds a custom action to the mu4e message view so that pressing `a
a' launches an agenda search for entries linking to the viewed message
(i.e. containing its message-id).

What it doesn't do, however, is indicate whether a message is linked
from Org *before* you run the action. Maybe that can be done by some
function used by org-search-view, but I suspect it would be too slow for
headers view, since the agenda search would need to be run for each of
hundreds of headings, and headers view should refresh immediately. So
maybe I'm not wasting my time completely.

Yours,
Christian

Reply via email to