1 Return-Path: <markwalters1009@gmail.com>
\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 1AD57431FDE
\r
6 for <notmuch@notmuchmail.org>; Sun, 11 May 2014 01:35:07 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,
\r
14 RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
15 Received: from olra.theworths.org ([127.0.0.1])
\r
16 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
17 with ESMTP id sHsNimsaWPZQ for <notmuch@notmuchmail.org>;
\r
18 Sun, 11 May 2014 01:35:02 -0700 (PDT)
\r
19 Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com
\r
20 [209.85.212.179]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
21 (No client certificate requested)
\r
22 by olra.theworths.org (Postfix) with ESMTPS id A000E431FC4
\r
23 for <notmuch@notmuchmail.org>; Sun, 11 May 2014 01:34:56 -0700 (PDT)
\r
24 Received: by mail-wi0-f179.google.com with SMTP id bs8so3127287wib.0
\r
25 for <notmuch@notmuchmail.org>; Sun, 11 May 2014 01:34:54 -0700 (PDT)
\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
27 h=from:to:cc:subject:date:message-id:in-reply-to:references;
\r
28 bh=IpMfDVDE2qHBwlzwRRn1AMd+cpFwdKfkM+Gl0aVpQ00=;
\r
29 b=e6gusMWkHSxbyWhRwiGh7JBf5lGhvG/F2QwcEq1IFypc+WxLH8NLZpUQ7qQraw+z/b
\r
30 /MnqGWYqva1elTGSm7AzZLCLdeZMZZBQz25lgRcJxTh8HoOURt2mXO3BFqSjnuS0tm/x
\r
31 xIPe7EArOe3kgTWgH0jrCB3mH+b/P1hR9dhSZElFlZ5qG9GQNrOV9Nej2iB54Cb6gyK2
\r
32 lVS2rIDht67IyDjN9hEFVKDATdmSFi0f1EH2GQmGkVYcbDzCtYR/OJaox2kJJ5g27wrq
\r
33 oZkwI760To0lR+X1OWIy6221bA7TwLb6xPWEFur1H0v46KxvWKurX5rOkVSVwNCHQR/k
\r
35 X-Received: by 10.194.175.70 with SMTP id by6mr16128915wjc.3.1399797294441;
\r
36 Sun, 11 May 2014 01:34:54 -0700 (PDT)
\r
37 Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])
\r
38 by mx.google.com with ESMTPSA id fi2sm9107958wib.2.2014.05.11.01.34.53
\r
39 for <multiple recipients>
\r
40 (version=TLSv1.2 cipher=RC4-SHA bits=128/128);
\r
41 Sun, 11 May 2014 01:34:53 -0700 (PDT)
\r
42 From: Mark Walters <markwalters1009@gmail.com>
\r
43 To: notmuch@notmuchmail.org
\r
44 Subject: [PATCH 4/7] emacs: hello: add a threads-and-messages function
\r
45 Date: Sun, 11 May 2014 09:34:39 +0100
\r
46 Message-Id: <1399797282-20389-5-git-send-email-markwalters1009@gmail.com>
\r
47 X-Mailer: git-send-email 1.7.10.4
\r
48 In-Reply-To: <1399797282-20389-1-git-send-email-markwalters1009@gmail.com>
\r
49 References: <1399797282-20389-1-git-send-email-markwalters1009@gmail.com>
\r
50 X-BeenThere: notmuch@notmuchmail.org
\r
51 X-Mailman-Version: 2.1.13
\r
53 List-Id: "Use and development of the notmuch mail system."
\r
54 <notmuch.notmuchmail.org>
\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
56 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
58 List-Post: <mailto:notmuch@notmuchmail.org>
\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
61 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
62 X-List-Received-Date: Sun, 11 May 2014 08:35:07 -0000
\r
64 This is an example of a possible display function. It displays the
\r
65 count for a search as messages/threads. This will be slow on a large
\r
66 search but could be useful for a small search.
\r
68 It also extends and renames the existing (unused)
\r
69 notmuch-saved-search-count function to count threads if wanted. The
\r
70 rename is done because the function is not saved-search specific.
\r
72 emacs/notmuch-hello.el | 30 +++++++++++++++++++++++++-----
\r
73 1 file changed, 25 insertions(+), 5 deletions(-)
\r
75 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
\r
76 index e11006b..6b2dedc 100644
\r
77 --- a/emacs/notmuch-hello.el
\r
78 +++ b/emacs/notmuch-hello.el
\r
79 @@ -90,8 +90,13 @@ (define-widget 'notmuch-saved-search-plist 'list
\r
80 (const :tag "Default" nil)
\r
81 (const :tag "Oldest-first" oldest-first)
\r
82 (const :tag "Newest-first" newest-first)))
\r
83 - (group :format "%v" :inline t (const :format "Display-function: " :display-function) (function :format "%v")))))
\r
85 + (group :format "%v" :inline t
\r
86 + (const :format "" :display-function)
\r
87 + (choice :tag " Display function"
\r
88 + (const :tag "Default (messages)" nil)
\r
89 + (function-item :tag "messages/threads"
\r
90 + notmuch-hello-display-count-threads-and-messages)
\r
93 (defcustom notmuch-saved-searches '((:name "inbox" :query "tag:inbox")
\r
94 (:name "unread" :query "tag:unread"))
\r
95 @@ -435,9 +440,6 @@ (defun notmuch-hello-widget-search (widget &rest ignore)
\r
97 :notmuch-search-oldest-first)))
\r
99 -(defun notmuch-saved-search-count (search)
\r
100 - (car (process-lines notmuch-command "count" search)))
\r
102 (defun notmuch-hello-tags-per-line (widest)
\r
103 "Determine how many tags to show per line and how wide they
\r
104 should be. Returns a cons cell `(tags-per-line width)'."
\r
105 @@ -487,6 +489,24 @@ (defun notmuch-hello-filtered-query (query filter)
\r
106 (concat "(" query ") and (" filter ")"))
\r
109 +(defun notmuch-hello-count (query &optional threads)
\r
110 + (let ((arg (if threads "--output=threads" "--output=messages")))
\r
111 + (string-to-number
\r
112 + (car (process-lines notmuch-command "count" arg query)))))
\r
114 +(defun notmuch-hello-display-count-threads-and-messages (&rest args)
\r
115 + "Display the saved search count as messages/threads.
\r
117 +This will be slow for large queries."
\r
118 + (let* ((current (plist-get args :current))
\r
119 + (query (plist-get current :query))
\r
120 + (messages (notmuch-hello-count query nil))
\r
121 + (threads (notmuch-hello-count query t))
\r
122 + (display (concat (notmuch-hello-nice-number messages)
\r
124 + (notmuch-hello-nice-number threads))))
\r
125 + (plist-put current :count display)))
\r
127 (defun notmuch-hello-batch-message-count (elem-plist options)
\r
128 "Update the message count for a saved search.
\r