1 Return-Path: <Sebastian@SSpaeth.de>
\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 4DCCA4196F0
\r
6 for <notmuch@notmuchmail.org>; Fri, 30 Apr 2010 05:28:09 -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 IsYj7+fZUC61 for <notmuch@notmuchmail.org>;
\r
16 Fri, 30 Apr 2010 05:28:08 -0700 (PDT)
\r
17 Received: from homiemail-a23.g.dreamhost.com (caiajhbdccac.dreamhost.com
\r
19 by olra.theworths.org (Postfix) with ESMTP id 7A2CF431FC1
\r
20 for <notmuch@notmuchmail.org>; Fri, 30 Apr 2010 05:28:08 -0700 (PDT)
\r
21 Received: from localhost.localdomain (unknown [195.190.188.219])
\r
22 (Authenticated sender: sebastian@sspaeth.de)
\r
23 by homiemail-a23.g.dreamhost.com (Postfix) with ESMTPA id EAB114B006D;
\r
24 Fri, 30 Apr 2010 05:28:05 -0700 (PDT)
\r
25 From: Sebastian Spaeth <Sebastian@SSpaeth.de>
\r
26 To: Notmuch developer list <notmuch@notmuchmail.org>
\r
27 Subject: [PATCH] Restructure notmuch-hello-reflect
\r
28 Date: Fri, 30 Apr 2010 14:28:02 +0200
\r
29 Message-Id: <1272630482-27386-1-git-send-email-Sebastian@SSpaeth.de>
\r
30 X-Mailer: git-send-email 1.7.0.4
\r
31 In-Reply-To: <1272623637-23951-1-git-send-email-Sebastian@SSpaeth.de>
\r
32 References: <1272623637-23951-1-git-send-email-Sebastian@SSpaeth.de>
\r
33 X-BeenThere: notmuch@notmuchmail.org
\r
34 X-Mailman-Version: 2.1.13
\r
36 List-Id: "Use and development of the notmuch mail system."
\r
37 <notmuch.notmuchmail.org>
\r
38 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
39 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
40 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
41 List-Post: <mailto:notmuch@notmuchmail.org>
\r
42 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
43 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
44 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
45 X-List-Received-Date: Fri, 30 Apr 2010 12:28:09 -0000
\r
47 This function was "not lispy" according to a comment by dme, and it
\r
48 also relied on a helper function that used 'cl code. Do away with all
\r
49 that and provide a hopefully lispy solution that relies on elisp only
\r
50 to "reflect" a (possibly non-square) matrix along it's diagonal.
\r
52 Remove now unused notmuch-hello-reflect-generate-row function.
\r
54 Remove unused notmuch-hello-roundup function (which did exactly the
\r
55 same as (ceiling divident divisor) anyway).
\r
57 Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
\r
59 emacs/notmuch-hello.el | 36 ++++++++++++++----------------------
\r
60 1 files changed, 14 insertions(+), 22 deletions(-)
\r
62 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
\r
63 index 1358387..1999858 100644
\r
64 --- a/emacs/notmuch-hello.el
\r
65 +++ b/emacs/notmuch-hello.el
\r
66 @@ -113,29 +113,21 @@
\r
67 maximize (length (car elem)))
\r
70 -(defun notmuch-hello-roundup (dividend divisor)
\r
71 - "Return the rounded up value of dividing `dividend' by `divisor'."
\r
72 - (+ (/ dividend divisor)
\r
73 - (if (> (% dividend divisor) 0) 1 0)))
\r
75 -(defun notmuch-hello-reflect-generate-row (ncols nrows row list)
\r
76 - (let ((len (length list)))
\r
77 - (loop for col from 0 to (- ncols 1)
\r
78 - collect (let ((offset (+ (* nrows col) row)))
\r
79 - (if (< offset len)
\r
81 - ;; Don't forget to insert an empty slot in the
\r
82 - ;; output matrix if there is no corresponding
\r
83 - ;; value in the input matrix.
\r
86 (defun notmuch-hello-reflect (list ncols)
\r
87 - "Reflect a `ncols' wide matrix represented by `list' along the
\r
89 - ;; Not very lispy...
\r
90 - (let ((nrows (notmuch-hello-roundup (length list) ncols)))
\r
91 - (loop for row from 0 to (- nrows 1)
\r
92 - append (notmuch-hello-reflect-generate-row ncols nrows row list))))
\r
93 + "Transpose a `ncols' wide matrix `list' along diagonal."
\r
94 + (let ((brows (ceiling (length list) ncols)) ;;#rows of new matrix
\r
96 + (setq bvector (make-vector (length list) nil));;vector to be returned
\r
97 + (dotimes (pos (length list))
\r
99 + (elt list (setq offset
\r
100 + (cond ;;return row number if in first colum
\r
101 + ((eq 0 (% pos ncols))
\r
102 + (setq offset (floor pos ncols)))
\r
103 + ((>= (% (length list) ncols) (% pos ncols))
\r
104 + (+ offset brows)) ;;add brows for first 'long'cols
\r
105 + (t (1- (+ offset brows)))))))) ;;+ brows-1 for remainder
\r
106 + (append bvector nil)));; return bvector as list
\r
108 (defun notmuch-hello-widget-search (widget &rest ignore)
\r
109 (notmuch-search (widget-get widget
\r