[PATCHv2] Restructure notmuch-hello-reflect
authorSebastian Spaeth <Sebastian@SSpaeth.de>
Fri, 30 Apr 2010 12:42:45 +0000 (14:42 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:37:00 +0000 (09:37 -0800)
ce/c82f79ec0945fa3a1e3d34ebf9326c9a6c25e5 [new file with mode: 0644]

diff --git a/ce/c82f79ec0945fa3a1e3d34ebf9326c9a6c25e5 b/ce/c82f79ec0945fa3a1e3d34ebf9326c9a6c25e5
new file mode 100644 (file)
index 0000000..087df08
--- /dev/null
@@ -0,0 +1,116 @@
+Return-Path: <Sebastian@SSpaeth.de>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id C6ECC4196F0\r
+       for <notmuch@notmuchmail.org>; Fri, 30 Apr 2010 05:42:50 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.9\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5\r
+       tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=ham\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id D423OXzmI6tm for <notmuch@notmuchmail.org>;\r
+       Fri, 30 Apr 2010 05:42:50 -0700 (PDT)\r
+Received: from homiemail-a15.g.dreamhost.com (mailbigip.dreamhost.com\r
+       [208.97.132.5])\r
+       by olra.theworths.org (Postfix) with ESMTP id EB0AB431FC1\r
+       for <notmuch@notmuchmail.org>; Fri, 30 Apr 2010 05:42:49 -0700 (PDT)\r
+Received: from localhost.localdomain (unknown [195.190.188.219])\r
+       (Authenticated sender: sebastian@sspaeth.de)\r
+       by homiemail-a15.g.dreamhost.com (Postfix) with ESMTPA id 94D0B76C06B; \r
+       Fri, 30 Apr 2010 05:42:48 -0700 (PDT)\r
+From: Sebastian Spaeth <Sebastian@SSpaeth.de>\r
+To: Notmuch developer list <notmuch@notmuchmail.org>\r
+Subject: [PATCHv2] Restructure notmuch-hello-reflect\r
+Date: Fri, 30 Apr 2010 14:42:45 +0200\r
+Message-Id: <1272631365-27995-1-git-send-email-Sebastian@SSpaeth.de>\r
+X-Mailer: git-send-email 1.7.0.4\r
+In-Reply-To: <1272630482-27386-1-git-send-email-Sebastian@SSpaeth.de>\r
+References: <1272630482-27386-1-git-send-email-Sebastian@SSpaeth.de>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 30 Apr 2010 12:42:50 -0000\r
+\r
+This function was "not lispy" according to a comment by dme, and it\r
+also relied on a helper function that used 'cl code. Do away with all\r
+that and provide a hopefully lispy solution that relies on elisp only\r
+to "reflect" a (possibly non-square) matrix along it's diagonal.\r
+\r
+Remove now unused notmuch-hello-reflect-generate-row function.\r
+\r
+Remove unused notmuch-hello-roundup function (which did exactly the\r
+same as (ceiling divident divisor) anyway).\r
+\r
+Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>\r
+---\r
+ Just for the record, this is the final cleaned up version. \r
+ Still not sure if dme sees it as an improvement though :-)\r
+\r
+ emacs/notmuch-hello.el |   37 +++++++++++++++----------------------\r
+ 1 files changed, 15 insertions(+), 22 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
+index 1358387..8dc8ff9 100644\r
+--- a/emacs/notmuch-hello.el\r
++++ b/emacs/notmuch-hello.el\r
+@@ -113,29 +113,22 @@\r
+           maximize (length (car elem)))\r
+       0))\r
\r
+-(defun notmuch-hello-roundup (dividend divisor)\r
+-  "Return the rounded up value of dividing `dividend' by `divisor'."\r
+-  (+ (/ dividend divisor)\r
+-     (if (> (% dividend divisor) 0) 1 0)))\r
+-\r
+-(defun notmuch-hello-reflect-generate-row (ncols nrows row list)\r
+-  (let ((len (length list)))\r
+-    (loop for col from 0 to (- ncols 1)\r
+-        collect (let ((offset (+ (* nrows col) row)))\r
+-                  (if (< offset len)\r
+-                      (nth offset list)\r
+-                    ;; Don't forget to insert an empty slot in the\r
+-                    ;; output matrix if there is no corresponding\r
+-                    ;; value in the input matrix.\r
+-                    nil)))))\r
+-\r
+ (defun notmuch-hello-reflect (list ncols)\r
+-  "Reflect a `ncols' wide matrix represented by `list' along the\r
+-diagonal."\r
+-  ;; Not very lispy...\r
+-  (let ((nrows (notmuch-hello-roundup (length list) ncols)))\r
+-    (loop for row from 0 to (- nrows 1)\r
+-        append (notmuch-hello-reflect-generate-row ncols nrows row list))))\r
++  "Reflect a `ncols' wide matrix `list' along diagonal."\r
++  (let* ((l (length list))\r
++         (brows (ceiling l ncols)) ;;#rows of new matrix\r
++         (bvector (make-vector l nil));;vector to be returned\r
++         offset)\r
++    (dotimes (pos l)\r
++      (aset bvector pos\r
++          (elt list (setq offset \r
++                            (cond ;;return row number if in first colum\r
++                             ((eq 0 (% pos ncols)) \r
++                              (setq offset (floor pos ncols)))\r
++                             ((>= (% l ncols) (% pos ncols)) \r
++                              (+ offset brows)) ;;add brows for first 'long'cols\r
++                             (t (1- (+ offset brows)))))))) ;;+ brows-1 for remainder\r
++    (append bvector nil)));; return bvector as list\r
\r
+ (defun notmuch-hello-widget-search (widget &rest ignore)\r
+   (notmuch-search (widget-get widget\r
+-- \r
+1.7.0.4\r
+\r