On Mon, 16 Jan 2012 11:43:25 +0000, David Edmondson <dme@dme.org> wrote: > On Thu, 12 Jan 2012 18:23:44 +0100, Pieter Praet <pieter@praet.org> wrote: > > + (make-text-button string-start string-end > > 'action `(lambda (arg) > > - (notmuch-show ,(match-string-no-properties 0))) > > + (notmuch-show-if-found ,message-id)) > > I like this, but wonder idly about the performance impact (not enough to > suggest denying it, though). > Hardly noticable (if at all) AFAICT, but yeah, it *does* cost one extra notmuch(1) invocation at every `push-button' event... Still, rather that than potentially dumping users in a blank screen IMO. Can't think of a better solution ATM. > > +(defun notmuch-show-found-target-p (target) > > + (let ((args `("count" ,target))) > > + (> (string-to-number (substring > > + (with-output-to-string > > + (apply 'call-process notmuch-command nil standard-output nil args)) > > + 0 -1)) 0))) > > `substring' seems unnecessary, presuming that it's to get rid of the > carriage return. > Correct. Mindless proactiveness, I guess :) Removed. > > +(defun notmuch-show-if-found (target &rest args) > > + (if (notmuch-show-found-target-p target nil) > > + (notmuch-show target args) > > + (error (format "Can't find target: %s" target)))) > > `error' will format strings without help. Idem. Patch follows. Peace -- Pieter