Re: [feature request] emacs: use `notmuch insert` for FCC
[notmuch-archives.git] / 6f / e353d2ceab11381238ca4ba5edeceb4dec36da
1 Return-Path: <jani@nikula.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 0C41C431FB6\r
6         for <notmuch@notmuchmail.org>; Tue, 17 Apr 2012 02:35:34 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \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 tAQk57ICccCb for <notmuch@notmuchmail.org>;\r
16         Tue, 17 Apr 2012 02:35:33 -0700 (PDT)\r
17 Received: from mail-qa0-f43.google.com (mail-qa0-f43.google.com\r
18         [209.85.216.43]) (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 580F5431FAE\r
21         for <notmuch@notmuchmail.org>; Tue, 17 Apr 2012 02:35:33 -0700 (PDT)\r
22 Received: by qadb15 with SMTP id b15so259245qad.2\r
23         for <notmuch@notmuchmail.org>; Tue, 17 Apr 2012 02:35:32 -0700 (PDT)\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
25         d=google.com; s=20120113;\r
26         h=from:to:subject:in-reply-to:references:user-agent:date:message-id\r
27         :mime-version:content-type:x-gm-message-state;\r
28         bh=Mr8EorY1W/3t/hs/Z/pGrpY83ajsjC3EiE41/4l04wc=;\r
29         b=ei7gmmbMzmdON5JvYvKxLTMc0iWAxOYjwpn0L7BJ0FXtr6k4GAFIUSmjbNZekZs5jP\r
30         SVpXeIti1v9Jc2CFvMqHC0tmsOEb00xAzNtjsuVq5QxEWB9bsjCFQI1iGRUrbW8jJVf1\r
31         /YWMxFx4KOhCQfsrJ61tUZpEo98C2AfldnIsHS/uzpIB52aVfu0hVDFqVpCdmdJGDFXO\r
32         gNpIck569gi/9990p2BXkhPuHlDYA4fhro38DDjj0sQZ8jAgteOWGJTHRp9IOprjzctV\r
33         ZRyL5NQrwMeFKNFmpJMmW4fNhFlgfacT8bTWakUAOFO5hADCYblRb4yrU8M8AOSCj2wL\r
34         5Yqg==\r
35 Received: by 10.229.137.3 with SMTP id u3mr6301746qct.20.1334655332663;\r
36         Tue, 17 Apr 2012 02:35:32 -0700 (PDT)\r
37 Received: from localhost (nikula.org. [92.243.24.172])\r
38         by mx.google.com with ESMTPS id dm8sm39266459qab.18.2012.04.17.02.35.31\r
39         (version=SSLv3 cipher=OTHER); Tue, 17 Apr 2012 02:35:31 -0700 (PDT)\r
40 From: Jani Nikula <jani@nikula.org>\r
41 To: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>, notmuch@notmuchmail.org\r
42 Subject: Re: [RFC PATCH 3/4] emacs: add notmuch hello refresh hook to display\r
43         message count change\r
44 In-Reply-To: <874nsioh5g.fsf@gmail.com>\r
45 References:\r
46  <bcfdc0d1969997e89e5abe0b320d77ee2109796a.1334651669.git.jani@nikula.org>\r
47         <c2449d9a081e5f013da4349368f4be291d03724e.1334651669.git.jani@nikula.org>\r
48         <874nsioh5g.fsf@gmail.com>\r
49 User-Agent: Notmuch/0.11.1+222~ga47a98c (http://notmuchmail.org) Emacs/23.1.1\r
50         (i686-pc-linux-gnu)\r
51 Date: Tue, 17 Apr 2012 09:35:28 +0000\r
52 Message-ID: <87ehrmvgyn.fsf@nikula.org>\r
53 MIME-Version: 1.0\r
54 Content-Type: text/plain; charset=us-ascii\r
55 X-Gm-Message-State:\r
56  ALoCoQnn36pr8RGzDkZ0gNy32A/W1hunjH/fHlgPf39zhd9u97DIEjwjFIdgzfwHOwmbZxyCELsu\r
57 X-BeenThere: notmuch@notmuchmail.org\r
58 X-Mailman-Version: 2.1.13\r
59 Precedence: list\r
60 List-Id: "Use and development of the notmuch mail system."\r
61         <notmuch.notmuchmail.org>\r
62 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
63         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
64 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
65 List-Post: <mailto:notmuch@notmuchmail.org>\r
66 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
67 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
68         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
69 X-List-Received-Date: Tue, 17 Apr 2012 09:35:34 -0000\r
70 \r
71 On Tue, 17 Apr 2012 13:13:15 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:\r
72 > Jani Nikula <jani@nikula.org> writes:\r
73\r
74 > > Add a notmuch hello refresh hook to display a message about change in\r
75 > > message count in the database since the notmuch-hello buffer was last\r
76 > > refreshed manually (no-display is nil).\r
77\r
78 > I like this idea.  But IMO we should avoid another call to notmuch\r
79 > count.  Notmuch-hello buffer already displays the message count on the\r
80 > first line.  I would propose to implement this functionality not as a\r
81 > hook but as part of the section which outputs the first line.  We can\r
82 > add an option to disable it if you prefer but I do not think it is\r
83 > needed.  This is less flexible than a hook, but IMO it is not a big\r
84 > issue.\r
85 \r
86 And what if someone has disabled the header section but would want the\r
87 message? Also, you'd have to pass no-display there too. IMHO one call to\r
88 notmuch count is not a big issue, especially for an optional feature.\r
89 And having it as a hook very nicely isolates the feature from everything\r
90 else.\r
91 \r
92 Jani.\r
93 \r
94 \r
95\r
96 > Regards,\r
97 >   Dmitry\r
98\r
99 > > ---\r
100 > >  emacs/notmuch-hello.el |   23 +++++++++++++++++++++++\r
101 > >  1 files changed, 23 insertions(+), 0 deletions(-)\r
102 > >\r
103 > > diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
104 > > index 0596bbe..13da146 100644\r
105 > > --- a/emacs/notmuch-hello.el\r
106 > > +++ b/emacs/notmuch-hello.el\r
107 > > @@ -148,6 +148,7 @@ International Bureau of Weights and Measures."\r
108 > >  (defcustom notmuch-hello-refresh-hook nil\r
109 > >    "Functions called after updating a `notmuch-hello' buffer."\r
110 > >    :type 'hook\r
111 > > +  :options '(notmuch-hello-refresh-status-message)\r
112 > >    :group 'notmuch-hello\r
113 > >    :group 'notmuch-hooks)\r
114 > >  \r
115 > > @@ -729,6 +730,28 @@ following:\r
116 > >      (let ((fill-column (- (window-width) notmuch-hello-indent)))\r
117 > >        (center-region start (point)))))\r
118 > >  \r
119 > > +(defvar notmuch-hello-refresh-count 0\r
120 > > +  "Number of messages in the database when `notmuch-hello' was last run.\r
121 > > +\r
122 > > +Used internally by `notmuch-hello-refresh-status-message'.")\r
123 > > +\r
124 > > +(defun notmuch-hello-refresh-status-message (no-display)\r
125 > > +  "Hook to display a status message when refreshing notmuch-hello buffer."\r
126 > > +  (unless no-display\r
127 > > +    (let* ((new-count\r
128 > > +       (string-to-number (car (process-lines notmuch-command "count"))))\r
129 > > +      (diff-count (- new-count notmuch-hello-refresh-count)))\r
130 > > +      (if (= notmuch-hello-refresh-count 0)\r
131 > > +     (message "You have %s messages."\r
132 > > +              (notmuch-hello-nice-number new-count))\r
133 > > +   (if (not (= diff-count 0))\r
134 > > +       (if (>= diff-count 0)\r
135 > > +           (message "You have %s more messages since last refresh."\r
136 > > +                    (notmuch-hello-nice-number diff-count))\r
137 > > +         (message "You have %s fewer messages since last refresh."\r
138 > > +                  (notmuch-hello-nice-number (- diff-count))))))\r
139 > > +      (setq notmuch-hello-refresh-count new-count))))\r
140 > > +\r
141 > >  ;;;###autoload\r
142 > >  (defun notmuch-hello (&optional no-display)\r
143 > >    "Run notmuch and display saved searches, known tags, etc."\r
144 > > -- \r
145 > > 1.7.1\r
146 > >\r
147 > > _______________________________________________\r
148 > > notmuch mailing list\r
149 > > notmuch@notmuchmail.org\r
150 > > http://notmuchmail.org/mailman/listinfo/notmuch\r