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 D4F8E429E55
\r
6 for <notmuch@notmuchmail.org>; Sun, 22 Jan 2012 00:56:43 -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 G8MVN0CvHFxS for <notmuch@notmuchmail.org>;
\r
16 Sun, 22 Jan 2012 00:56:43 -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 37F20429E54
\r
21 for <notmuch@notmuchmail.org>; Sun, 22 Jan 2012 00:56:43 -0800 (PST)
\r
22 Received: by werb10 with SMTP id b10so1658214wer.26
\r
23 for <notmuch@notmuchmail.org>; Sun, 22 Jan 2012 00:56:42 -0800 (PST)
\r
24 Received: by 10.216.136.23 with SMTP id v23mr1872636wei.48.1327222602028;
\r
25 Sun, 22 Jan 2012 00:56:42 -0800 (PST)
\r
26 Received: from localhost ([109.131.95.182])
\r
27 by mx.google.com with ESMTPS id cb8sm2331723wib.0.2012.01.22.00.56.41
\r
28 (version=TLSv1/SSLv3 cipher=OTHER);
\r
29 Sun, 22 Jan 2012 00:56:41 -0800 (PST)
\r
30 From: Pieter Praet <pieter@praet.org>
\r
31 To: Mark Anderson <MarkR.Anderson@amd.com>, Aaron Ecay <aaronecay@gmail.com>,
\r
32 David Edmondson <dme@dme.org>,
\r
33 Jameson Graef Rollins <jrollins@finestructure.net>
\r
34 Subject: [PATCH v4 2/3] emacs: `notmuch-show-buttonize-links' only
\r
35 `notmuch-show's a message if it exists
\r
36 Date: Sun, 22 Jan 2012 09:54:28 +0100
\r
37 Message-Id: <1327222469-29487-2-git-send-email-pieter@praet.org>
\r
38 X-Mailer: git-send-email 1.7.8.1
\r
39 In-Reply-To: <871uqsku4h.fsf@praet.org>
\r
40 References: <871uqsku4h.fsf@praet.org>
\r
41 Cc: Notmuch Mail <notmuch@notmuchmail.org>
\r
42 X-BeenThere: notmuch@notmuchmail.org
\r
43 X-Mailman-Version: 2.1.13
\r
45 List-Id: "Use and development of the notmuch mail system."
\r
46 <notmuch.notmuchmail.org>
\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
48 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
50 List-Post: <mailto:notmuch@notmuchmail.org>
\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
53 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
54 X-List-Received-Date: Sun, 22 Jan 2012 08:56:44 -0000
\r
56 * emacs/notmuch-show.el (notmuch-show-found-target-p): new predicate function
\r
57 that uses notmuch(1) 'count' to see if a query turns up any results.
\r
59 * emacs/notmuch-show.el (notmuch-show-if-found): new function that only shows
\r
60 a message/thread if present in the database and otherwise returns an error.
\r
62 * emacs/notmuch-show.el (notmuch-show-buttonize-links): some deduplication,
\r
63 and use new function `notmuch-show-if-found' instead of `notmuch-show'
\r
64 to prevent showing a blank screen for Message-Id's which aren't present
\r
67 emacs/notmuch-show.el | 31 +++++++++++++++++++++++--------
\r
68 1 files changed, 23 insertions(+), 8 deletions(-)
\r
70 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
71 index 57dd232..972ac79 100644
\r
72 --- a/emacs/notmuch-show.el
\r
73 +++ b/emacs/notmuch-show.el
\r
74 @@ -908,14 +908,17 @@ a corresponding notmuch search."
\r
77 (while (re-search-forward "id:\\(\"?\\)[^[:space:]\"]+\\1" end t)
\r
78 - ;; remove the overlay created by goto-address-mode
\r
79 - (remove-overlays (match-beginning 0) (match-end 0) 'goto-address t)
\r
80 - (make-text-button (match-beginning 0) (match-end 0)
\r
81 - 'action `(lambda (arg)
\r
82 - (notmuch-show ,(match-string-no-properties 0)))
\r
84 - 'help-echo "Mouse-1, RET: search for this message"
\r
85 - 'face goto-address-mail-face))))
\r
86 + (let ((message-id (match-string-no-properties 0))
\r
87 + (string-start (match-beginning 0))
\r
88 + (string-end (match-end 0)))
\r
89 + ;; remove the overlay created by goto-address-mode
\r
90 + (remove-overlays string-start string-end 'goto-address t)
\r
91 + (make-text-button string-start string-end
\r
92 + 'action `(lambda (arg)
\r
93 + (notmuch-show-if-found ,message-id))
\r
95 + 'help-echo "Mouse-1, RET: search for this message"
\r
96 + 'face goto-address-mail-face)))))
\r
99 (defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name crypto-switch)
\r
100 @@ -1005,6 +1008,18 @@ thread id. If a prefix is given, crypto processing is toggled."
\r
101 (notmuch-kill-this-buffer)
\r
102 (notmuch-show-worker thread-id parent-buffer query-context buffer-name process-crypto)))
\r
104 +(defun notmuch-show-found-target-p (target)
\r
105 + (let ((args `("count" ,target)))
\r
106 + (> (string-to-number
\r
107 + (with-output-to-string
\r
108 + (apply 'call-process notmuch-command nil standard-output nil args)))
\r
111 +(defun notmuch-show-if-found (target &rest args)
\r
112 + (if (notmuch-show-found-target-p target)
\r
113 + (notmuch-show target args)
\r
114 + (error "Can't find target: %s" target)))
\r
116 (defvar notmuch-show-stash-map
\r
117 (let ((map (make-sparse-keymap)))
\r
118 (define-key map "c" 'notmuch-show-stash-cc)
\r