[PATCH 2/3] emacs: `notmuch-show-buttonize-links' only `notmuch-show's a message if it exists

Pieter Praet pieter at praet.org
Mon Jan 16 08:49:42 PST 2012


On Mon, 16 Jan 2012 11:43:25 +0000, David Edmondson <dme at dme.org> wrote:
> On Thu, 12 Jan 2012 18:23:44 +0100, Pieter Praet <pieter at 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


More information about the notmuch mailing list