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 EA42C4196F0
\r
6 for <notmuch@notmuchmail.org>; Tue, 4 May 2010 06:44:06 -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] 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 utXv58AdXvD8 for <notmuch@notmuchmail.org>;
\r
16 Tue, 4 May 2010 06:44:03 -0700 (PDT)
\r
17 Received: from mail-ww0-f53.google.com (mail-ww0-f53.google.com
\r
18 [74.125.82.53]) by olra.theworths.org (Postfix) with ESMTP id B3594431FC1 for
\r
19 <notmuch@notmuchmail.org>; Tue, 4 May 2010 06:44:03 -0700 (PDT)
\r
20 Received: by wwd20 with SMTP id 20so1161745wwd.26
\r
21 for <notmuch@notmuchmail.org>; Tue, 04 May 2010 06:44:02 -0700 (PDT)
\r
22 Received: by 10.227.138.11 with SMTP id y11mr1314782wbt.87.1272980642657;
\r
23 Tue, 04 May 2010 06:44:02 -0700 (PDT)
\r
24 Received: from ut.hh.sledj.net (gmp-ea-fw-1.sun.com [192.18.1.36])
\r
25 by mx.google.com with ESMTPS id z33sm28775993wbd.13.2010.05.04.06.44.00
\r
26 (version=TLSv1/SSLv3 cipher=RC4-MD5);
\r
27 Tue, 04 May 2010 06:44:01 -0700 (PDT)
\r
28 Received: by ut.hh.sledj.net (Postfix, from userid 1000)
\r
29 id D741D594121; Tue, 4 May 2010 14:44:40 +0100 (BST)
\r
30 From: David Edmondson <dme@dme.org>
\r
31 To: notmuch@notmuchmail.org
\r
32 Subject: [PATCH] emacs: Pretty print the numbers of matching messages.
\r
33 Date: Tue, 4 May 2010 14:44:39 +0100
\r
34 Message-Id: <1272980679-11193-1-git-send-email-dme@dme.org>
\r
35 X-Mailer: git-send-email 1.7.0
\r
36 X-BeenThere: notmuch@notmuchmail.org
\r
37 X-Mailman-Version: 2.1.13
\r
39 List-Id: "Use and development of the notmuch mail system."
\r
40 <notmuch.notmuchmail.org>
\r
41 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
42 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
43 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
44 List-Post: <mailto:notmuch@notmuchmail.org>
\r
45 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
46 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
47 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
48 X-List-Received-Date: Tue, 04 May 2010 13:44:07 -0000
\r
50 Insert a separator every three digits when outputting numbers. Allow
\r
51 the user to choose the separator by customizing
\r
52 `notmuch-decimal-separator'. Widen the space allocated for message
\r
55 emacs/notmuch-hello.el | 38 +++++++++++++++++++++++++++++++-------
\r
56 1 files changed, 31 insertions(+), 7 deletions(-)
\r
58 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
\r
59 index bf49bb1..a6e8a47 100644
\r
60 --- a/emacs/notmuch-hello.el
\r
61 +++ b/emacs/notmuch-hello.el
\r
62 @@ -91,6 +91,13 @@ So:
\r
63 (integer :tag "Number of characters")
\r
64 (float :tag "Fraction of window")))
\r
66 +(defcustom notmuch-decimal-separator ","
\r
67 + "The string used as a decimal separator.
\r
69 +Typically \",\" in the US and UK and \".\" in Europe."
\r
73 (defvar notmuch-hello-url "http://notmuchmail.org"
\r
74 "The `notmuch' web site.")
\r
76 @@ -103,6 +110,17 @@ So:
\r
77 notmuch-recent-searches-max)
\r
78 (setq notmuch-hello-recent-searches (butlast notmuch-hello-recent-searches))))
\r
80 +(defun notmuch-hello-nice-number (n)
\r
83 + (push (% n 1000) result)
\r
84 + (setq n (/ n 1000)))
\r
86 + (number-to-string (car result))
\r
87 + (mapcar (lambda (elem)
\r
88 + (format "%s%03d" notmuch-decimal-separator elem))
\r
91 (defun notmuch-hello-trim (search)
\r
93 (if (string-match "^[[:space:]]*\\(.*[^[:space:]]\\)[[:space:]]*$" search)
\r
94 @@ -180,9 +198,9 @@ should be. Returns a cons cell `(tags-per-line width)'."
\r
95 ((integerp notmuch-column-control)
\r
97 (/ (- (window-width) notmuch-hello-indent)
\r
98 - ;; Count is 7 wide (6 digits plus space), 1 for the space
\r
99 + ;; Count is 9 wide (8 digits plus space), 1 for the space
\r
101 - (+ 7 1 (max notmuch-column-control widest)))))
\r
102 + (+ 9 1 (max notmuch-column-control widest)))))
\r
104 ((floatp notmuch-column-control)
\r
105 (let* ((available-width (- (window-width) notmuch-hello-indent))
\r
106 @@ -192,12 +210,15 @@ should be. Returns a cons cell `(tags-per-line width)'."
\r
109 (/ (- (window-width) notmuch-hello-indent)
\r
110 - ;; Count is 7 wide (6 digits plus space), 1 for the space
\r
111 + ;; Count is 9 wide (8 digits plus space), 1 for the space
\r
113 - (+ 7 1 widest)))))))
\r
114 + (+ 9 1 widest)))))))
\r
116 (cons tags-per-line (/ (- (window-width) notmuch-hello-indent
\r
117 - (* tags-per-line (+ 7 1)))
\r
118 + ;; Count is 9 wide (8 digits plus
\r
119 + ;; space), 1 for the space after the
\r
121 + (* tags-per-line (+ 9 1)))
\r
124 (defun notmuch-hello-insert-tags (tag-alist widest target)
\r
125 @@ -218,7 +239,9 @@ should be. Returns a cons cell `(tags-per-line width)'."
\r
126 (let* ((name (car elem))
\r
128 (formatted-name (format "%s " name)))
\r
129 - (widget-insert (format "%6s " (notmuch-saved-search-count query)))
\r
130 + (widget-insert (format "%8s "
\r
131 + (notmuch-hello-nice-number
\r
132 + (string-to-number (notmuch-saved-search-count query)))))
\r
133 (if (string= formatted-name target)
\r
134 (setq found-target-pos (point-marker)))
\r
135 (widget-create 'push-button
\r
136 @@ -323,7 +346,8 @@ should be. Returns a cons cell `(tags-per-line width)'."
\r
137 :notify (lambda (&rest ignore)
\r
138 (notmuch-hello-update))
\r
139 :help-echo "Refresh"
\r
140 - (car (process-lines notmuch-command "count")))
\r
141 + (notmuch-hello-nice-number
\r
142 + (string-to-number (car (process-lines notmuch-command "count")))))
\r
143 (widget-insert " messages (that's not much mail).\n"))
\r
145 (let ((found-target-pos nil)
\r