Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id CB213418C25 for ; Tue, 27 Apr 2010 03:04:50 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.9 X-Spam-Level: X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9] autolearn=ham Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KhyjnYA-cAbB for ; Tue, 27 Apr 2010 03:04:49 -0700 (PDT) Received: from mail-ww0-f53.google.com (mail-ww0-f53.google.com [74.125.82.53]) by olra.theworths.org (Postfix) with ESMTP id 5DEA94196F5 for ; Tue, 27 Apr 2010 03:04:47 -0700 (PDT) Received: by wwi18 with SMTP id 18so1073063wwi.26 for ; Tue, 27 Apr 2010 03:04:46 -0700 (PDT) Received: by 10.216.93.2 with SMTP id k2mr7096854wef.56.1272362684331; Tue, 27 Apr 2010 03:04:44 -0700 (PDT) Received: from ut.hh.sledj.net (host83-217-165-81.dsl.vispa.com [83.217.165.81]) by mx.google.com with ESMTPS id x1sm3859636wbx.1.2010.04.27.03.04.43 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 27 Apr 2010 03:04:43 -0700 (PDT) Received: by ut.hh.sledj.net (Postfix, from userid 1000) id 595C659413D; Tue, 27 Apr 2010 11:04:57 +0100 (BST) From: dme@dme.org To: notmuch@notmuchmail.org Subject: [PATCH 2/2] emacs: Fix `notmuch-hello-insert-tags' to correctly draw the tags. Date: Tue, 27 Apr 2010 11:04:37 +0100 Message-Id: <1272362677-22492-2-git-send-email-dme@dme.org> X-Mailer: git-send-email 1.7.0 In-Reply-To: <1272362677-22492-1-git-send-email-dme@dme.org> References: <1272362677-22492-1-git-send-email-dme@dme.org> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Apr 2010 10:04:51 -0000 From: David Edmondson The fix in 1e1871154341cdd3413fe3f32e3aae477826d815 broke end-of-row wrapping when drawing the table of tags/saved searches. Fix that and improve the readability of the matrix reflection code to hasten future debugging. --- Carl, this is a fix for a regression that I caused this morning when fixing the line wrapping. Serves me right for doing more than was really necessary in the previous patch. Sorry :-( emacs/notmuch-hello.el | 37 +++++++++++++++++++------------------ 1 files changed, 19 insertions(+), 18 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 1b59ef1..6a1c56e 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -118,23 +118,24 @@ (+ (/ dividend divisor) (if (> (% dividend divisor) 0) 1 0))) -(defun notmuch-hello-reflect (list width) - "Reflect a `width' wide matrix represented by `list' along the +(defun notmuch-hello-reflect-generate-row (ncols nrows row list) + (let ((len (length list))) + (loop for col from 0 to (- ncols 1) + collect (let ((offset (+ (* nrows col) row))) + (if (< offset len) + (nth offset list) + ;; Don't forget to insert an empty slot in the + ;; output matrix if there is no corresponding + ;; value in the input matrix. + nil))))) + +(defun notmuch-hello-reflect (list ncols) + "Reflect a `ncols' wide matrix represented by `list' along the diagonal." ;; Not very lispy... - (let* ((len (length list)) - (nrows (notmuch-hello-roundup len width))) + (let ((nrows (notmuch-hello-roundup (length list) ncols))) (loop for row from 0 to (- nrows 1) - append (loop for col from 0 to (- width 1) - ;; How could we calculate the offset just once - ;; per inner-loop? - if (< (+ (* nrows col) row) len) - collect (nth (+ (* nrows col) row) list) - else - ;; Don't forget to insert an empty slot in the - ;; output matrix if there is no corresponding - ;; value in the input matrix. - collect nil)))) + append (notmuch-hello-reflect-generate-row ncols nrows row list)))) (defun notmuch-hello-widget-search (widget &rest ignore) (notmuch-search (widget-get widget @@ -179,10 +180,10 @@ diagonal." ;; can just insert `(- widest (length name))' spaces - ;; the column separator is included in the button if ;; `(equal widest (length name)'. - (widget-insert (make-string (- widest (length name)) ? ))) - (setq count (1+ count)) - (if (eq (% count tags-per-line) 0) - (widget-insert "\n")))) + (widget-insert (make-string (- widest (length name)) ? )))) + (setq count (1+ count)) + (if (eq (% count tags-per-line) 0) + (widget-insert "\n"))) reordered-list) ;; If the last line was not full (and hence did not include a -- 1.7.0