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

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

Date: Mon, 16 Jan 2012 11:43:25 +0000

To: Pieter Praet, Jameson Graef Rollins

Cc: Notmuch Mail

From: David Edmondson


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).

> +(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.

> +(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.
part-000.sig (application/pgp-signature)

Thread: