I've ended up doing it in two discrete steps:
- open all buffers from the current (tree) search (may take a few seconds):
(defun notmuch-tree-show-all-messages ()
(interactive)
(goto-char (point-min))
(while (and (not (eobp)) (not (get-buffer (notmuch-tree-get-message-id))))
(notmuch-tree-show-message-out)
(previous-buffer)
(forward-line 1)))
- multi-occur only in the opened notmuch messages:
...