1 Return-Path: <joyfulgirl@archlinux.us>
\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 B537D429E25
\r
6 for <notmuch@notmuchmail.org>; Sat, 29 Oct 2011 09:33:37 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\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 yA-kNWk-QIWV for <notmuch@notmuchmail.org>;
\r
16 Sat, 29 Oct 2011 09:33:37 -0700 (PDT)
\r
17 Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com
\r
18 [209.85.216.181]) (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 DC102431FB6
\r
21 for <notmuch@notmuchmail.org>; Sat, 29 Oct 2011 09:33:36 -0700 (PDT)
\r
22 Received: by qyk27 with SMTP id 27so5838408qyk.5
\r
23 for <notmuch@notmuchmail.org>; Sat, 29 Oct 2011 09:33:36 -0700 (PDT)
\r
24 Received: by 10.229.190.9 with SMTP id dg9mr179805qcb.246.1319906016094;
\r
25 Sat, 29 Oct 2011 09:33:36 -0700 (PDT)
\r
26 Received: from localhost (209-6-79-248.c3-0.abr-ubr1.sbo-abr.ma.cable.rcn.com.
\r
28 by mx.google.com with ESMTPS id du5sm20729174qab.14.2011.10.29.09.33.34
\r
29 (version=TLSv1/SSLv3 cipher=OTHER);
\r
30 Sat, 29 Oct 2011 09:33:35 -0700 (PDT)
\r
31 From: Ivy Foster <joyfulgirl@archlinux.us>
\r
32 To: notmuch@notmuchmail.org
\r
33 Subject: [Patch 2/3] Respect window margins in notmuch-hello.el
\r
34 Date: Sat, 29 Oct 2011 12:30:48 -0400
\r
35 Message-ID: <87k47nlpzb.fsf@nausicaa.localdomain>
\r
37 Content-Type: text/plain; charset=us-ascii
\r
38 X-BeenThere: notmuch@notmuchmail.org
\r
39 X-Mailman-Version: 2.1.13
\r
41 List-Id: "Use and development of the notmuch mail system."
\r
42 <notmuch.notmuchmail.org>
\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
44 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
46 List-Post: <mailto:notmuch@notmuchmail.org>
\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
49 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
50 X-List-Received-Date: Sat, 29 Oct 2011 16:33:37 -0000
\r
54 The following patch makes notmuch take window margins into
\r
55 account when calculating the width of the notmuch-hello
\r
56 window in Emacs. As a side benefit (so that I only had to
\r
57 write the code once), I've added a named function to return
\r
60 Folks using linum-mode should still probably get a copy of
\r
61 linum-off.el and disable linum for notmuch-hello, though,
\r
62 since it doesn't set the margin until after the buffer is
\r
63 done being created, causing text to overflow across the
\r
64 edge. Alternately, take a look at my next message, with yet
\r
71 Signed-off-by: Ivy Foster <joyfulgirl@archlinux.us>
\r
72 >From 0c1a0fa0858e3c22b416ce6bd9ad623198217d34 Mon Sep 17 00:00:00 2001
\r
73 From: Ivy Foster <joyfulgirl@archlinux.us>
\r
74 Date: Fri, 28 Oct 2011 23:18:14 -0400
\r
75 Subject: [PATCH 2/3] Respect margins in new named window-width function
\r
77 This patch removes a function which is duplicated
\r
78 several times in notmuch-hello.el, improving
\r
79 readability. Also, factors in window margins
\r
80 when calculating width.
\r
82 emacs/notmuch-hello.el | 28 ++++++++++++++++++----------
\r
83 1 files changed, 18 insertions(+), 10 deletions(-)
\r
85 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
\r
86 index 65fde75..1a213f0 100644
\r
87 --- a/emacs/notmuch-hello.el
\r
88 +++ b/emacs/notmuch-hello.el
\r
89 @@ -213,25 +213,27 @@ should be. Returns a cons cell `(tags-per-line width)'."
\r
91 ((integerp notmuch-column-control)
\r
93 - (/ (- (window-width) notmuch-hello-indent)
\r
94 + (/ (notmuch-hello-available-width)
\r
95 ;; Count is 9 wide (8 digits plus space), 1 for the space
\r
97 (+ 9 1 (max notmuch-column-control widest)))))
\r
99 ((floatp notmuch-column-control)
\r
100 - (let* ((available-width (- (window-width) notmuch-hello-indent))
\r
101 - (proposed-width (max (* available-width notmuch-column-control) widest)))
\r
102 - (floor available-width proposed-width)))
\r
103 + (let ((proposed-width (max
\r
104 + (* (notmuch-hello-available-width)
\r
105 + notmuch-column-control)
\r
107 + (floor (notmuch-hello-available-width) proposed-width)))
\r
111 - (/ (- (window-width) notmuch-hello-indent)
\r
112 + (/ (notmuch-hello-available-width)
\r
113 ;; Count is 9 wide (8 digits plus space), 1 for the space
\r
115 (+ 9 1 widest)))))))
\r
117 (cons tags-per-line (/ (max 1
\r
118 - (- (window-width) notmuch-hello-indent
\r
119 + (- (notmuch-hello-available-width)
\r
120 ;; Count is 9 wide (8 digits plus
\r
121 ;; space), 1 for the space after the
\r
123 @@ -458,7 +460,7 @@ Complete list of currently available key bindings:
\r
124 (widget-create 'editable-field
\r
125 ;; Leave some space at the start and end of the
\r
127 - :size (max 8 (- (window-width) notmuch-hello-indent
\r
128 + :size (max 8 (- (notmuch-hello-available-width)
\r
129 (length "Search: ")))
\r
130 :action (lambda (widget &rest ignore)
\r
131 (notmuch-hello-search (widget-value widget))))
\r
132 @@ -481,12 +483,13 @@ Complete list of currently available key bindings:
\r
133 ;; Don't let the search boxes be
\r
134 ;; less than 8 characters wide.
\r
136 - (- (window-width)
\r
138 + (notmuch-hello-available-width)
\r
139 ;; Leave some space
\r
140 ;; at the start and
\r
143 - (* 2 notmuch-hello-indent)
\r
144 + notmuch-hello-indent
\r
147 ;; `[save]' button. 6
\r
148 @@ -540,7 +543,7 @@ Complete list of currently available key bindings:
\r
149 (widget-insert "Edit saved searches with the `edit' button.\n"))
\r
150 (widget-insert "Hit RET or click on a saved search or tag name to view matching threads.\n")
\r
151 (widget-insert "`=' refreshes this screen. `s' jumps to the search box. `q' to quit.\n")
\r
152 - (let ((fill-column (- (window-width) notmuch-hello-indent)))
\r
153 + (let ((fill-column (notmuch-hello-available-width)))
\r
154 (center-region start (point))))
\r
157 @@ -558,6 +561,11 @@ Complete list of currently available key bindings:
\r
161 +(defun notmuch-hello-available-width ()
\r
162 + (let ((left-margin (or (car (window-margins)) 0))
\r
163 + (right-margin (or (cadr (window-margins)) 0)))
\r
164 + (- (window-width) left-margin right-margin notmuch-hello-indent)))
\r
168 (provide 'notmuch-hello)
\r