Re: [PATCH] emacs: address completion, allow sender/recipient and filters
[notmuch-archives.git] / ce / c82f79ec0945fa3a1e3d34ebf9326c9a6c25e5
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 C6ECC4196F0\r
6         for <notmuch@notmuchmail.org>; Fri, 30 Apr 2010 05:42: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, RCVD_IN_DNSWL_NONE=-0.0001] 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 D423OXzmI6tm for <notmuch@notmuchmail.org>;\r
16         Fri, 30 Apr 2010 05:42:50 -0700 (PDT)\r
17 Received: from homiemail-a15.g.dreamhost.com (mailbigip.dreamhost.com\r
18         [208.97.132.5])\r
19         by olra.theworths.org (Postfix) with ESMTP id EB0AB431FC1\r
20         for <notmuch@notmuchmail.org>; Fri, 30 Apr 2010 05:42:49 -0700 (PDT)\r
21 Received: from localhost.localdomain (unknown [195.190.188.219])\r
22         (Authenticated sender: sebastian@sspaeth.de)\r
23         by homiemail-a15.g.dreamhost.com (Postfix) with ESMTPA id 94D0B76C06B; \r
24         Fri, 30 Apr 2010 05:42:48 -0700 (PDT)\r
25 From: Sebastian Spaeth <Sebastian@SSpaeth.de>\r
26 To: Notmuch developer list <notmuch@notmuchmail.org>\r
27 Subject: [PATCHv2] Restructure notmuch-hello-reflect\r
28 Date: Fri, 30 Apr 2010 14:42:45 +0200\r
29 Message-Id: <1272631365-27995-1-git-send-email-Sebastian@SSpaeth.de>\r
30 X-Mailer: git-send-email 1.7.0.4\r
31 In-Reply-To: <1272630482-27386-1-git-send-email-Sebastian@SSpaeth.de>\r
32 References: <1272630482-27386-1-git-send-email-Sebastian@SSpaeth.de>\r
33 X-BeenThere: notmuch@notmuchmail.org\r
34 X-Mailman-Version: 2.1.13\r
35 Precedence: list\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:42:50 -0000\r
46 \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
51 \r
52 Remove now unused notmuch-hello-reflect-generate-row function.\r
53 \r
54 Remove unused notmuch-hello-roundup function (which did exactly the\r
55 same as (ceiling divident divisor) anyway).\r
56 \r
57 Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>\r
58 ---\r
59  Just for the record, this is the final cleaned up version. \r
60  Still not sure if dme sees it as an improvement though :-)\r
61 \r
62  emacs/notmuch-hello.el |   37 +++++++++++++++----------------------\r
63  1 files changed, 15 insertions(+), 22 deletions(-)\r
64 \r
65 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
66 index 1358387..8dc8ff9 100644\r
67 --- a/emacs/notmuch-hello.el\r
68 +++ b/emacs/notmuch-hello.el\r
69 @@ -113,29 +113,22 @@\r
70             maximize (length (car elem)))\r
71        0))\r
72  \r
73 -(defun notmuch-hello-roundup (dividend divisor)\r
74 -  "Return the rounded up value of dividing `dividend' by `divisor'."\r
75 -  (+ (/ dividend divisor)\r
76 -     (if (> (% dividend divisor) 0) 1 0)))\r
77 -\r
78 -(defun notmuch-hello-reflect-generate-row (ncols nrows row list)\r
79 -  (let ((len (length list)))\r
80 -    (loop for col from 0 to (- ncols 1)\r
81 -         collect (let ((offset (+ (* nrows col) row)))\r
82 -                   (if (< offset len)\r
83 -                       (nth offset list)\r
84 -                     ;; Don't forget to insert an empty slot in the\r
85 -                     ;; output matrix if there is no corresponding\r
86 -                     ;; value in the input matrix.\r
87 -                     nil)))))\r
88 -\r
89  (defun notmuch-hello-reflect (list ncols)\r
90 -  "Reflect a `ncols' wide matrix represented by `list' along the\r
91 -diagonal."\r
92 -  ;; Not very lispy...\r
93 -  (let ((nrows (notmuch-hello-roundup (length list) ncols)))\r
94 -    (loop for row from 0 to (- nrows 1)\r
95 -         append (notmuch-hello-reflect-generate-row ncols nrows row list))))\r
96 +  "Reflect a `ncols' wide matrix `list' along diagonal."\r
97 +  (let* ((l (length list))\r
98 +         (brows (ceiling l ncols)) ;;#rows of new matrix\r
99 +         (bvector (make-vector l nil));;vector to be returned\r
100 +         offset)\r
101 +    (dotimes (pos l)\r
102 +      (aset bvector pos\r
103 +           (elt list (setq offset \r
104 +                            (cond ;;return row number if in first colum\r
105 +                             ((eq 0 (% pos ncols)) \r
106 +                              (setq offset (floor pos ncols)))\r
107 +                             ((>= (% l ncols) (% pos ncols)) \r
108 +                              (+ offset brows)) ;;add brows for first 'long'cols\r
109 +                             (t (1- (+ offset brows)))))))) ;;+ brows-1 for remainder\r
110 +    (append bvector nil)));; return bvector as list\r
111  \r
112  (defun notmuch-hello-widget-search (widget &rest ignore)\r
113    (notmuch-search (widget-get widget\r
114 -- \r
115 1.7.0.4\r
116 \r