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 696AA431FAF for ; Mon, 16 Jan 2012 08:51:34 -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 va+ZZVWus2Oj for ; Mon, 16 Jan 2012 08:51:28 -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 4AA1B431FAE for ; Mon, 16 Jan 2012 08:51:28 -0800 (PST) Received: by werb13 with SMTP id b13so3677wer.26 for ; Mon, 16 Jan 2012 08:51:27 -0800 (PST) Received: by 10.216.139.25 with SMTP id b25mr2635152wej.28.1326732687026; Mon, 16 Jan 2012 08:51:27 -0800 (PST) Received: from localhost ([109.131.75.86]) by mx.google.com with ESMTPS id fy5sm35020711wib.7.2012.01.16.08.51.25 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 16 Jan 2012 08:51:26 -0800 (PST) From: Pieter Praet To: David Edmondson , 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: 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+78~g6c58370 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-unknown-linux-gnu) Date: Mon, 16 Jan 2012 17:49:42 +0100 Message-ID: <87lip7a8yh.fsf@praet.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 16:51:34 -0000 On Mon, 16 Jan 2012 11:43:25 +0000, David Edmondson wrote: > 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). > 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