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 6E2A54196F0
\r
6 for <notmuch@notmuchmail.org>; Tue, 27 Apr 2010 07:58:34 -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 UqFcgQP5OIGZ for <notmuch@notmuchmail.org>;
\r
16 Tue, 27 Apr 2010 07:58:32 -0700 (PDT)
\r
17 Received: from mail-wy0-f181.google.com (mail-wy0-f181.google.com
\r
19 by olra.theworths.org (Postfix) with ESMTP id DEAEB431FC1
\r
20 for <notmuch@notmuchmail.org>; Tue, 27 Apr 2010 07:58:31 -0700 (PDT)
\r
21 Received: by wyj26 with SMTP id 26so1549892wyj.26
\r
22 for <notmuch@notmuchmail.org>; Tue, 27 Apr 2010 07:58:31 -0700 (PDT)
\r
23 Received: by 10.216.90.17 with SMTP id d17mr271194wef.117.1272380310844;
\r
24 Tue, 27 Apr 2010 07:58:30 -0700 (PDT)
\r
25 Received: from ut.hh.sledj.net (gmp-ea-fw-1b.sun.com [192.18.8.1])
\r
26 by mx.google.com with ESMTPS id z3sm5974884wbs.10.2010.04.27.07.58.29
\r
27 (version=TLSv1/SSLv3 cipher=RC4-MD5);
\r
28 Tue, 27 Apr 2010 07:58:29 -0700 (PDT)
\r
29 Received: by ut.hh.sledj.net (Postfix, from userid 1000)
\r
30 id 9B2E259413B; Tue, 27 Apr 2010 15:58:43 +0100 (BST)
\r
32 To: notmuch@notmuchmail.org
\r
33 Subject: [PATCH] emacs: Allow tuning of the tag/saved search layout.
\r
34 Date: Tue, 27 Apr 2010 15:58:39 +0100
\r
35 Message-Id: <1272380319-2387-1-git-send-email-dme@dme.org>
\r
36 X-Mailer: git-send-email 1.7.0
\r
37 X-BeenThere: notmuch@notmuchmail.org
\r
38 X-Mailman-Version: 2.1.13
\r
40 List-Id: "Use and development of the notmuch mail system."
\r
41 <notmuch.notmuchmail.org>
\r
42 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
43 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
44 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
45 List-Post: <mailto:notmuch@notmuchmail.org>
\r
46 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
47 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
48 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
49 X-List-Received-Date: Tue, 27 Apr 2010 14:58:34 -0000
\r
51 From: David Edmondson <dme@dme.org>
\r
53 Add `notmuch-hello-tag-width', which has three potential sets of
\r
56 - t: automatically calculate the number of tags per line possible
\r
57 based on the tags to be shown and the window width,
\r
58 - an integer: a lower bound on the number of characters that will
\r
59 be used to display each tag,
\r
60 - a float: a fraction of the window width that is the lower bound
\r
61 on the number of characters that should be used for each tag.
\r
64 - if you would like two columns of tags, set this to 0.5.
\r
65 - if you would like a single column of tags, set this to 1.0.
\r
66 - if you would like tags to be 30 characters wide, set this to
\r
68 - if you don't want to worry about all of this nonsense, leave
\r
72 Carl, for 0.4. You mentioned that you might like to have a single
\r
73 column of tags/saved searches, but others appear to like multiple
\r
74 columns. So, make it configurable.
\r
76 emacs/notmuch-hello.el | 62 +++++++++++++++++++++++++++++++++++++++++++----
\r
77 1 files changed, 56 insertions(+), 6 deletions(-)
\r
79 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
\r
80 index 378d41c..f7703d9 100644
\r
81 --- a/emacs/notmuch-hello.el
\r
82 +++ b/emacs/notmuch-hello.el
\r
83 @@ -141,13 +141,63 @@ diagonal."
\r
84 (defun notmuch-saved-search-count (search)
\r
85 (car (process-lines notmuch-command "count" search)))
\r
87 +(defcustom notmuch-hello-tag-width t
\r
88 + "How wide should a tag be?
\r
90 +This variable has three potential sets of values:
\r
92 +- t: automatically calculate the number of tags per line possible
\r
93 + based on the tags to be shown and the window width,
\r
94 +- an integer: a lower bound on the number of characters that will
\r
95 + be used to display each tag,
\r
96 +- a float: a fraction of the window width that is the lower bound
\r
97 + on the number of characters that should be used for each tag.
\r
100 +- if you would like two columns of tags, set this to 0.5.
\r
101 +- if you would like a single column of tags, set this to 1.0.
\r
102 +- if you would like tags to be 30 characters wide, set this to
\r
104 +- if you don't want to worry about all of this nonsense, leave
\r
105 + this set to `t'."
\r
108 + (const :tag "Automatically calculated" t)
\r
109 + (integer :tag "Number of characters")
\r
110 + (float :tag "Fraction of window")))
\r
112 +(defun notmuch-hello-tags-per-line (widest)
\r
113 + "Determine how many tags to show per line and how wide they
\r
114 +should be. Returns a cons cell `(tags-per-line width)'."
\r
115 + (let ((tags-per-line
\r
117 + ((integerp notmuch-hello-tag-width)
\r
119 + (/ (- (window-width) notmuch-hello-indent)
\r
120 + ;; Count is 7 wide (6 digits plus space), 1 for the space
\r
121 + ;; after the name.
\r
122 + (+ 7 1 (max notmuch-hello-tag-width widest)))))
\r
124 + ((floatp notmuch-hello-tag-width)
\r
125 + (let* ((available-width (- (window-width) notmuch-hello-indent))
\r
126 + (proposed-width (max (* available-width notmuch-hello-tag-width) widest)))
\r
127 + (floor available-width proposed-width)))
\r
131 + (/ (- (window-width) notmuch-hello-indent)
\r
132 + ;; Count is 7 wide (6 digits plus space), 1 for the space
\r
133 + ;; after the name.
\r
134 + (+ 7 1 widest)))))))
\r
136 + (cons tags-per-line (/ (- (window-width) notmuch-hello-indent
\r
137 + (* tags-per-line (+ 7 1)))
\r
138 + tags-per-line))))
\r
140 (defun notmuch-hello-insert-tags (tag-alist widest target)
\r
141 - (let* ((tags-per-line (max 1
\r
142 - (/ (- (window-width) notmuch-hello-indent)
\r
143 - ;; Count is 7 wide (6 digits plus
\r
144 - ;; space), 1 for the space after the
\r
146 - (+ 7 1 widest))))
\r
147 + (let* ((tags-and-width (notmuch-hello-tags-per-line widest))
\r
148 + (tags-per-line (car tags-and-width))
\r
149 + (widest (cdr tags-and-width))
\r
151 (reordered-list (notmuch-hello-reflect tag-alist tags-per-line))
\r
152 ;; Hack the display of the buttons used.
\r