Re: [PATCH] emacs: display tags in notmuch-show's header-line with links to search
[notmuch-archives.git] / 63 / 5570130b70d19d9a97773ed224093b6951cd62
1 Return-Path: <sojkam1@fel.cvut.cz>\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 BE106431FB6\r
6         for <notmuch@notmuchmail.org>; Wed, 26 Jan 2011 05:07:13 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         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 mfj8blWFGAG0 for <notmuch@notmuchmail.org>;\r
16         Wed, 26 Jan 2011 05:07:13 -0800 (PST)\r
17 Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36])\r
18         by olra.theworths.org (Postfix) with ESMTP id 2369F431FB5\r
19         for <notmuch@notmuchmail.org>; Wed, 26 Jan 2011 05:07:13 -0800 (PST)\r
20 Received: from localhost (unknown [192.168.200.4])\r
21         by max.feld.cvut.cz (Postfix) with ESMTP id 79FE919F3327;\r
22         Wed, 26 Jan 2011 14:07:11 +0100 (CET)\r
23 X-Virus-Scanned: IMAP AMAVIS\r
24 Received: from max.feld.cvut.cz ([192.168.200.1])\r
25         by localhost (styx.feld.cvut.cz [192.168.200.4]) (amavisd-new,\r
26         port 10044)\r
27         with ESMTP id APQ4JujjJ-pM; Wed, 26 Jan 2011 14:07:10 +0100 (CET)\r
28 Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34])\r
29         by max.feld.cvut.cz (Postfix) with ESMTP id DA67319F3329;\r
30         Wed, 26 Jan 2011 14:07:09 +0100 (CET)\r
31 Received: from steelpick.2x.cz (note-sojka.felk.cvut.cz [147.32.86.30])\r
32         (Authenticated sender: sojkam1)\r
33         by imap.feld.cvut.cz (Postfix) with ESMTPSA id DF4DA15C031;\r
34         Wed, 26 Jan 2011 14:07:09 +0100 (CET)\r
35 Received: from wsh by steelpick.2x.cz with local (Exim 4.72)\r
36         (envelope-from <sojkam1@fel.cvut.cz>)\r
37         id 1Pi55Z-0001ti-AN; Wed, 26 Jan 2011 14:07:09 +0100\r
38 From: Michal Sojka <sojkam1@fel.cvut.cz>\r
39 To: notmuch@notmuchmail.org\r
40 Subject: [PATCH] new: Print progress estimates only when we have sufficient\r
41         information\r
42 Date: Wed, 26 Jan 2011 14:06:57 +0100\r
43 Message-Id: <1296047217-7266-1-git-send-email-sojkam1@fel.cvut.cz>\r
44 X-Mailer: git-send-email 1.7.2.3\r
45 In-Reply-To: <1295603977-14326-5-git-send-email-sojkam1@fel.cvut.cz>\r
46 References: <1295603977-14326-5-git-send-email-sojkam1@fel.cvut.cz>\r
47 X-BeenThere: notmuch@notmuchmail.org\r
48 X-Mailman-Version: 2.1.13\r
49 Precedence: list\r
50 List-Id: "Use and development of the notmuch mail system."\r
51         <notmuch.notmuchmail.org>\r
52 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
54 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
55 List-Post: <mailto:notmuch@notmuchmail.org>\r
56 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
57 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
58         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
59 X-List-Received-Date: Wed, 26 Jan 2011 13:07:13 -0000\r
60 \r
61 Without this patch, it might happen that the remaining time or processing\r
62 rate were calculated just after start where nothing was processed yet.\r
63 This resulted into division by a very small number (or zero) and the\r
64 printed information was of little value.\r
65 \r
66 Instead of printing nonsenses we print only that the operation is in\r
67 progress. The estimates will be printed later, after there is enough data.\r
68 ---\r
69  notmuch-new.c |   18 +++++++++++-------\r
70  1 files changed, 11 insertions(+), 7 deletions(-)\r
71 \r
72 diff --git a/notmuch-new.c b/notmuch-new.c\r
73 index fa7a76d..8f64b25 100644\r
74 --- a/notmuch-new.c\r
75 +++ b/notmuch-new.c\r
76 @@ -117,15 +117,19 @@ generic_print_progress (const char *action, const char *object,\r
77      printf ("%s %d ", action, processed);\r
78  \r
79      if (total) {\r
80 -       double time_remaining;\r
81 -\r
82 -       time_remaining = ((total - processed) / rate_overall);\r
83 -       printf ("of %d %s (", total, object);\r
84 -       notmuch_time_print_formatted_seconds (time_remaining);\r
85 -       printf (" remaining).\033[K\r");\r
86 +       printf ("of %d %s", total, object);\r
87 +       if (processed > 0 && elapsed_overall > 0.5) {\r
88 +           double time_remaining = ((total - processed) / rate_overall);\r
89 +           printf (" (");\r
90 +           notmuch_time_print_formatted_seconds (time_remaining);\r
91 +           printf (" remaining)");\r
92 +       }\r
93      } else {\r
94 -       printf ("%s (%d %s/sec.)\033[K\r", object, (int) rate_overall, object);\r
95 +       printf ("%s", object);\r
96 +       if (elapsed_overall > 0.5)\r
97 +           printf (" (%d %s/sec.)", (int) rate_overall, object);\r
98      }\r
99 +    printf (".\033[K\r");\r
100  \r
101      fflush (stdout);\r
102  }\r
103 -- \r
104 1.7.2.3\r
105 \r