1 Return-Path: <pieter@praet.org>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 89F22431FAE
\r
6 for <notmuch@notmuchmail.org>; Mon, 16 Jan 2012 08:54:04 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id b4QTJ0gVJRJG for <notmuch@notmuchmail.org>;
\r
16 Mon, 16 Jan 2012 08:53:58 -0800 (PST)
\r
17 Received: from mail-we0-f181.google.com (mail-we0-f181.google.com
\r
18 [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 39B15431FAF
\r
21 for <notmuch@notmuchmail.org>; Mon, 16 Jan 2012 08:53:58 -0800 (PST)
\r
22 Received: by werb13 with SMTP id b13so6495wer.26
\r
23 for <notmuch@notmuchmail.org>; Mon, 16 Jan 2012 08:53:57 -0800 (PST)
\r
24 Received: by 10.216.138.101 with SMTP id z79mr4223907wei.7.1326732835435;
\r
25 Mon, 16 Jan 2012 08:53:55 -0800 (PST)
\r
26 Received: from localhost ([109.131.75.86])
\r
27 by mx.google.com with ESMTPS id ek1sm12346829wib.10.2012.01.16.08.53.50
\r
28 (version=TLSv1/SSLv3 cipher=OTHER);
\r
29 Mon, 16 Jan 2012 08:53:50 -0800 (PST)
\r
30 From: Pieter Praet <pieter@praet.org>
\r
31 To: David Edmondson <dme@dme.org>,
\r
32 Jameson Graef Rollins <jrollins@finestructure.net>
\r
33 Subject: [PATCH v2] emacs: `notmuch-show-buttonize-links' only `notmuch-show's
\r
34 a message if it exists
\r
35 Date: Mon, 16 Jan 2012 17:51:59 +0100
\r
36 Message-Id: <1326732719-23493-1-git-send-email-pieter@praet.org>
\r
37 X-Mailer: git-send-email 1.7.8.1
\r
38 In-Reply-To: <87lip7a8yh.fsf@praet.org>
\r
39 References: <87lip7a8yh.fsf@praet.org>
\r
40 Cc: Notmuch Mail <notmuch@notmuchmail.org>
\r
41 X-BeenThere: notmuch@notmuchmail.org
\r
42 X-Mailman-Version: 2.1.13
\r
44 List-Id: "Use and development of the notmuch mail system."
\r
45 <notmuch.notmuchmail.org>
\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
47 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
49 List-Post: <mailto:notmuch@notmuchmail.org>
\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
52 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
53 X-List-Received-Date: Mon, 16 Jan 2012 16:54:04 -0000
\r
55 * emacs/notmuch-show.el (notmuch-show-found-target-p): new predicate function
\r
56 that uses notmuch(1) 'count' to see if a query turns up any results.
\r
58 * emacs/notmuch-show.el (notmuch-show-if-found): new function that only shows
\r
59 a message/thread if present in the database and otherwise returns an error.
\r
61 * emacs/notmuch-show.el (notmuch-show-buttonize-links): some deduplication,
\r
62 and use new function `notmuch-show-if-found' instead of `notmuch-show'
\r
63 to prevent showing a blank screen for Message-Id's which aren't present
\r
68 v2: (corrections by David Edmondson [1])
\r
70 - `notmuch-show-found-target-p' : removed useless `substring'.
\r
71 - `notmuch-show-if-found' : remove redundant `format'.
\r
73 ... and added a missing closing paren due to badly splitting up the
\r
76 [1] id:"cun7h0r50v6.fsf@hotblack-desiato.hh.sledj.net"
\r
79 emacs/notmuch-show.el | 31 +++++++++++++++++++++++--------
\r
80 1 files changed, 23 insertions(+), 8 deletions(-)
\r
82 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
83 index f101d76..7a79d06 100644
\r
84 --- a/emacs/notmuch-show.el
\r
85 +++ b/emacs/notmuch-show.el
\r
86 @@ -803,14 +803,17 @@ a corresponding notmuch search."
\r
89 (while (re-search-forward "id:\\(\"?\\)[^[:space:]\"]+\\1" end t)
\r
90 - ;; remove the overlay created by goto-address-mode
\r
91 - (remove-overlays (match-beginning 0) (match-end 0) 'goto-address t)
\r
92 - (make-text-button (match-beginning 0) (match-end 0)
\r
93 - 'action `(lambda (arg)
\r
94 - (notmuch-show ,(match-string-no-properties 0)))
\r
96 - 'help-echo "Mouse-1, RET: search for this message"
\r
97 - 'face goto-address-mail-face))))
\r
98 + (let ((message-id (match-string-no-properties 0))
\r
99 + (string-start (match-beginning 0))
\r
100 + (string-end (match-end 0)))
\r
101 + ;; remove the overlay created by goto-address-mode
\r
102 + (remove-overlays string-start string-end 'goto-address t)
\r
103 + (make-text-button string-start string-end
\r
104 + 'action `(lambda (arg)
\r
105 + (notmuch-show-if-found ,message-id))
\r
107 + 'help-echo "Mouse-1, RET: search for this message"
\r
108 + 'face goto-address-mail-face)))))
\r
111 (defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name crypto-switch)
\r
112 @@ -903,6 +906,18 @@ thread id. If a prefix is given, crypto processing is toggled."
\r
113 (notmuch-kill-this-buffer)
\r
114 (notmuch-show-worker thread-id parent-buffer query-context buffer-name process-crypto)))
\r
116 +(defun notmuch-show-found-target-p (target)
\r
117 + (let ((args `("count" ,target)))
\r
118 + (> (string-to-number
\r
119 + (with-output-to-string
\r
120 + (apply 'call-process notmuch-command nil standard-output nil args)))
\r
123 +(defun notmuch-show-if-found (target &rest args)
\r
124 + (if (notmuch-show-found-target-p target)
\r
125 + (notmuch-show target args)
\r
126 + (error "Can't find target: %s" target)))
\r
128 (defvar notmuch-show-stash-map
\r
129 (let ((map (make-sparse-keymap)))
\r
130 (define-key map "c" 'notmuch-show-stash-cc)
\r