From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id BD178429E4D for ; Mon, 16 Jan 2012 03:43:30 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zlpP47owpJcj for ; Mon, 16 Jan 2012 03:43:30 -0800 (PST) Received: from mail-we0-f181.google.com (mail-we0-f181.google.com [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id EC163429E4A for ; Mon, 16 Jan 2012 03:43:29 -0800 (PST) Received: by werh12 with SMTP id h12so1356403wer.26 for ; Mon, 16 Jan 2012 03:43:28 -0800 (PST) Received: by 10.216.139.205 with SMTP id c55mr4753005wej.31.1326714208573; Mon, 16 Jan 2012 03:43:28 -0800 (PST) Received: from hotblack-desiato.hh.sledj.net (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25]) by mx.google.com with ESMTPS id l8sm19011984wiy.5.2012.01.16.03.43.26 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 16 Jan 2012 03:43:27 -0800 (PST) Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000) id 4B4AA9FD88; Mon, 16 Jan 2012 11:43:25 +0000 (GMT) To: Pieter Praet , Jameson Graef Rollins Subject: Re: [PATCH 2/3] emacs: `notmuch-show-buttonize-links' only `notmuch-show's a message if it exists In-Reply-To: <1326389025-18877-2-git-send-email-pieter@praet.org> References: <874nw0ltwz.fsf@praet.org> <1326389025-18877-1-git-send-email-pieter@praet.org> <1326389025-18877-2-git-send-email-pieter@praet.org> User-Agent: Notmuch/0.11+64~g42e8f66 (http://notmuchmail.org) Emacs/24.0.92.1 (x86_64-pc-linux-gnu) From: David Edmondson Date: Mon, 16 Jan 2012 11:43:25 +0000 Message-ID: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Cc: Notmuch Mail X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Jan 2012 11:43:30 -0000 --=-=-= Content-Type: text/plain On Thu, 12 Jan 2012 18:23:44 +0100, Pieter Praet 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. --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEARECAAYFAk8UDV0ACgkQaezQq/BJZRYJCwCdEkfK7yTRdmrdlrPEFZ46S66t R0oAnAuXhl6ns+eRsCE2Om9JDH49pCe+ =BLek -----END PGP SIGNATURE----- --=-=-=--