Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / a2 / 42ab771f3e69bc5eae75952ec76fcc39e4aed3
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 CB213418C25\r
6         for <notmuch@notmuchmail.org>; Tue, 27 Apr 2010 03:04:50 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.9\r
10 X-Spam-Level: \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 KhyjnYA-cAbB for <notmuch@notmuchmail.org>;\r
16         Tue, 27 Apr 2010 03:04:49 -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 5DEA94196F5       for\r
19  <notmuch@notmuchmail.org>; Tue, 27 Apr 2010 03:04:47 -0700 (PDT)\r
20 Received: by wwi18 with SMTP id 18so1073063wwi.26\r
21         for <notmuch@notmuchmail.org>; Tue, 27 Apr 2010 03:04:46 -0700 (PDT)\r
22 Received: by 10.216.93.2 with SMTP id k2mr7096854wef.56.1272362684331;\r
23         Tue, 27 Apr 2010 03:04:44 -0700 (PDT)\r
24 Received: from ut.hh.sledj.net (host83-217-165-81.dsl.vispa.com\r
25         [83.217.165.81])\r
26         by mx.google.com with ESMTPS id x1sm3859636wbx.1.2010.04.27.03.04.43\r
27         (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
28         Tue, 27 Apr 2010 03:04:43 -0700 (PDT)\r
29 Received: by ut.hh.sledj.net (Postfix, from userid 1000)\r
30         id 595C659413D; Tue, 27 Apr 2010 11:04:57 +0100 (BST)\r
31 From: dme@dme.org\r
32 To: notmuch@notmuchmail.org\r
33 Subject: [PATCH 2/2] emacs: Fix `notmuch-hello-insert-tags' to correctly draw\r
34         the tags.\r
35 Date: Tue, 27 Apr 2010 11:04:37 +0100\r
36 Message-Id: <1272362677-22492-2-git-send-email-dme@dme.org>\r
37 X-Mailer: git-send-email 1.7.0\r
38 In-Reply-To: <1272362677-22492-1-git-send-email-dme@dme.org>\r
39 References: <1272362677-22492-1-git-send-email-dme@dme.org>\r
40 X-BeenThere: notmuch@notmuchmail.org\r
41 X-Mailman-Version: 2.1.13\r
42 Precedence: list\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: Tue, 27 Apr 2010 10:04:51 -0000\r
53 \r
54 From: David Edmondson <dme@dme.org>\r
55 \r
56 The fix in 1e1871154341cdd3413fe3f32e3aae477826d815 broke end-of-row\r
57 wrapping when drawing the table of tags/saved searches. Fix that and\r
58 improve the readability of the matrix reflection code to hasten future\r
59 debugging.\r
60 ---\r
61 \r
62 Carl, this is a fix for a regression that I caused this morning when\r
63 fixing the line wrapping. Serves me right for doing more than was\r
64 really necessary in the previous patch. Sorry :-(\r
65 \r
66  emacs/notmuch-hello.el |   37 +++++++++++++++++++------------------\r
67  1 files changed, 19 insertions(+), 18 deletions(-)\r
68 \r
69 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
70 index 1b59ef1..6a1c56e 100644\r
71 --- a/emacs/notmuch-hello.el\r
72 +++ b/emacs/notmuch-hello.el\r
73 @@ -118,23 +118,24 @@\r
74    (+ (/ dividend divisor)\r
75       (if (> (% dividend divisor) 0) 1 0)))\r
76  \r
77 -(defun notmuch-hello-reflect (list width)\r
78 -  "Reflect a `width' wide matrix represented by `list' along the\r
79 +(defun notmuch-hello-reflect-generate-row (ncols nrows row list)\r
80 +  (let ((len (length list)))\r
81 +    (loop for col from 0 to (- ncols 1)\r
82 +         collect (let ((offset (+ (* nrows col) row)))\r
83 +                   (if (< offset len)\r
84 +                       (nth offset list)\r
85 +                     ;; Don't forget to insert an empty slot in the\r
86 +                     ;; output matrix if there is no corresponding\r
87 +                     ;; value in the input matrix.\r
88 +                     nil)))))\r
89 +\r
90 +(defun notmuch-hello-reflect (list ncols)\r
91 +  "Reflect a `ncols' wide matrix represented by `list' along the\r
92  diagonal."\r
93    ;; Not very lispy...\r
94 -  (let* ((len (length list))\r
95 -        (nrows (notmuch-hello-roundup len width)))\r
96 +  (let ((nrows (notmuch-hello-roundup (length list) ncols)))\r
97      (loop for row from 0 to (- nrows 1)\r
98 -         append (loop for col from 0 to (- width 1)\r
99 -                      ;; How could we calculate the offset just once\r
100 -                      ;; per inner-loop?\r
101 -                      if (< (+ (* nrows col) row) len)\r
102 -                      collect (nth (+ (* nrows col) row) list)\r
103 -                      else\r
104 -                      ;; Don't forget to insert an empty slot in the\r
105 -                      ;; output matrix if there is no corresponding\r
106 -                      ;; value in the input matrix.\r
107 -                      collect nil))))\r
108 +         append (notmuch-hello-reflect-generate-row ncols nrows row list))))\r
109  \r
110  (defun notmuch-hello-widget-search (widget &rest ignore)\r
111    (notmuch-search (widget-get widget\r
112 @@ -179,10 +180,10 @@ diagonal."\r
113                 ;; can just insert `(- widest (length name))' spaces -\r
114                 ;; the column separator is included in the button if\r
115                 ;; `(equal widest (length name)'.\r
116 -               (widget-insert (make-string (- widest (length name)) ? )))\r
117 -             (setq count (1+ count))\r
118 -             (if (eq (% count tags-per-line) 0)\r
119 -                 (widget-insert "\n"))))\r
120 +               (widget-insert (make-string (- widest (length name)) ? ))))\r
121 +           (setq count (1+ count))\r
122 +           (if (eq (% count tags-per-line) 0)\r
123 +               (widget-insert "\n")))\r
124           reordered-list)\r
125  \r
126      ;; If the last line was not full (and hence did not include a\r
127 -- \r
128 1.7.0\r
129 \r