(defun dme:notmuch-show-next-open-with-tag (tag)
  (interactive)
  (let (more)
    (loop do (setq more (notmuch-show-goto-message-next))
          until (or (not more)
                    (and (notmuch-show-message-visible-p)
                         (member tag (notmuch-show-get-tags)))))))

Generated by David Edmondson using scpaste at Fri Jan 27 12:34:03 2012. GMT. (original)