1 Return-Path: <dme@dme.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 3697A409C6C
\r
6 for <notmuch@notmuchmail.org>; Wed, 19 May 2010 01:54:21 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5
\r
12 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=ham
\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 DVBbEFGN3wH6 for <notmuch@notmuchmail.org>;
\r
16 Wed, 19 May 2010 01:54:07 -0700 (PDT)
\r
17 Received: from mail-ew0-f213.google.com (mail-ew0-f213.google.com
\r
19 by olra.theworths.org (Postfix) with ESMTP id BCE7E418C34
\r
20 for <notmuch@notmuchmail.org>; Wed, 19 May 2010 01:53:44 -0700 (PDT)
\r
21 Received: by mail-ew0-f213.google.com with SMTP id 5so1814149ewy.0
\r
22 for <notmuch@notmuchmail.org>; Wed, 19 May 2010 01:53:44 -0700 (PDT)
\r
23 Received: by 10.213.0.212 with SMTP id 20mr3641464ebc.43.1274259224392;
\r
24 Wed, 19 May 2010 01:53:44 -0700 (PDT)
\r
25 Received: from ut.hh.sledj.net (host83-217-165-81.dsl.vispa.com
\r
27 by mx.google.com with ESMTPS id 16sm3528987ewy.11.2010.05.19.01.53.42
\r
28 (version=TLSv1/SSLv3 cipher=RC4-MD5);
\r
29 Wed, 19 May 2010 01:53:43 -0700 (PDT)
\r
30 Received: by ut.hh.sledj.net (Postfix, from userid 1000)
\r
31 id C69545940AD; Wed, 19 May 2010 08:03:45 +0100 (BST)
\r
32 From: David Edmondson <dme@dme.org>
\r
33 To: notmuch@notmuchmail.org
\r
34 Subject: [PATCH 11/13] emacs: Pretty print the numbers of matching messages.
\r
35 Date: Wed, 19 May 2010 08:03:38 +0100
\r
36 Message-Id: <1274252620-1249-12-git-send-email-dme@dme.org>
\r
37 X-Mailer: git-send-email 1.7.1
\r
38 In-Reply-To: <1274252620-1249-1-git-send-email-dme@dme.org>
\r
39 References: <1274252620-1249-1-git-send-email-dme@dme.org>
\r
40 X-BeenThere: notmuch@notmuchmail.org
\r
41 X-Mailman-Version: 2.1.13
\r
43 List-Id: "Use and development of the notmuch mail system."
\r
44 <notmuch.notmuchmail.org>
\r
45 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
46 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
47 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
48 List-Post: <mailto:notmuch@notmuchmail.org>
\r
49 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
50 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
51 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
52 X-List-Received-Date: Wed, 19 May 2010 08:54:21 -0000
\r
54 Insert a separator every three digits when outputting numbers. Allow
\r
55 the user to choose the separator by customizing
\r
56 `notmuch-decimal-separator'. Widen the space allocated for message
\r
59 emacs/notmuch-hello.el | 38 +++++++++++++++++++++++++++++++-------
\r
60 1 files changed, 31 insertions(+), 7 deletions(-)
\r
62 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
\r
63 index 538785f..7ade0eb 100644
\r
64 --- a/emacs/notmuch-hello.el
\r
65 +++ b/emacs/notmuch-hello.el
\r
66 @@ -91,6 +91,13 @@ So:
\r
67 (integer :tag "Number of characters")
\r
68 (float :tag "Fraction of window")))
\r
70 +(defcustom notmuch-decimal-separator ","
\r
71 + "The string used as a decimal separator.
\r
73 +Typically \",\" in the US and UK and \".\" in Europe."
\r
77 (defvar notmuch-hello-url "http://notmuchmail.org"
\r
78 "The `notmuch' web site.")
\r
80 @@ -103,6 +110,17 @@ So:
\r
81 notmuch-recent-searches-max)
\r
82 (setq notmuch-hello-recent-searches (butlast notmuch-hello-recent-searches))))
\r
84 +(defun notmuch-hello-nice-number (n)
\r
87 + (push (% n 1000) result)
\r
88 + (setq n (/ n 1000)))
\r
90 + (number-to-string (car result))
\r
91 + (mapcar (lambda (elem)
\r
92 + (format "%s%03d" notmuch-decimal-separator elem))
\r
95 (defun notmuch-hello-trim (search)
\r
97 (if (string-match "^[[:space:]]*\\(.*[^[:space:]]\\)[[:space:]]*$" search)
\r
98 @@ -180,9 +198,9 @@ should be. Returns a cons cell `(tags-per-line width)'."
\r
99 ((integerp notmuch-column-control)
\r
101 (/ (- (window-width) notmuch-hello-indent)
\r
102 - ;; Count is 7 wide (6 digits plus space), 1 for the space
\r
103 + ;; Count is 9 wide (8 digits plus space), 1 for the space
\r
105 - (+ 7 1 (max notmuch-column-control widest)))))
\r
106 + (+ 9 1 (max notmuch-column-control widest)))))
\r
108 ((floatp notmuch-column-control)
\r
109 (let* ((available-width (- (window-width) notmuch-hello-indent))
\r
110 @@ -192,12 +210,15 @@ should be. Returns a cons cell `(tags-per-line width)'."
\r
113 (/ (- (window-width) notmuch-hello-indent)
\r
114 - ;; Count is 7 wide (6 digits plus space), 1 for the space
\r
115 + ;; Count is 9 wide (8 digits plus space), 1 for the space
\r
117 - (+ 7 1 widest)))))))
\r
118 + (+ 9 1 widest)))))))
\r
120 (cons tags-per-line (/ (- (window-width) notmuch-hello-indent
\r
121 - (* tags-per-line (+ 7 1)))
\r
122 + ;; Count is 9 wide (8 digits plus
\r
123 + ;; space), 1 for the space after the
\r
125 + (* tags-per-line (+ 9 1)))
\r
128 (defun notmuch-hello-insert-tags (tag-alist widest target)
\r
129 @@ -218,7 +239,9 @@ should be. Returns a cons cell `(tags-per-line width)'."
\r
130 (let* ((name (car elem))
\r
132 (formatted-name (format "%s " name)))
\r
133 - (widget-insert (format "%6s " (notmuch-saved-search-count query)))
\r
134 + (widget-insert (format "%8s "
\r
135 + (notmuch-hello-nice-number
\r
136 + (string-to-number (notmuch-saved-search-count query)))))
\r
137 (if (string= formatted-name target)
\r
138 (setq found-target-pos (point-marker)))
\r
139 (widget-create 'push-button
\r
140 @@ -323,7 +346,8 @@ should be. Returns a cons cell `(tags-per-line width)'."
\r
141 :notify (lambda (&rest ignore)
\r
142 (notmuch-hello-update))
\r
143 :help-echo "Refresh"
\r
144 - (car (process-lines notmuch-command "count")))
\r
145 + (notmuch-hello-nice-number
\r
146 + (string-to-number (car (process-lines notmuch-command "count")))))
\r
147 (widget-insert " messages (that's not much mail).\n"))
\r
149 (let ((found-target-pos nil)
\r