mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 12:28:09 +01:00
emacs: Fix `notmuch-hello-insert-tags' to correctly draw the tags.
The fix in 1e18711543
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.
This commit is contained in:
parent
18d41192d2
commit
08561d8ae1
1 changed files with 19 additions and 18 deletions
|
@ -118,23 +118,24 @@
|
||||||
(+ (/ dividend divisor)
|
(+ (/ dividend divisor)
|
||||||
(if (> (% dividend divisor) 0) 1 0)))
|
(if (> (% dividend divisor) 0) 1 0)))
|
||||||
|
|
||||||
(defun notmuch-hello-reflect (list width)
|
(defun notmuch-hello-reflect-generate-row (ncols nrows row list)
|
||||||
"Reflect a `width' wide matrix represented by `list' along the
|
(let ((len (length list)))
|
||||||
diagonal."
|
(loop for col from 0 to (- ncols 1)
|
||||||
;; Not very lispy...
|
collect (let ((offset (+ (* nrows col) row)))
|
||||||
(let* ((len (length list))
|
(if (< offset len)
|
||||||
(nrows (notmuch-hello-roundup len width)))
|
(nth offset list)
|
||||||
(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
|
;; Don't forget to insert an empty slot in the
|
||||||
;; output matrix if there is no corresponding
|
;; output matrix if there is no corresponding
|
||||||
;; value in the input matrix.
|
;; value in the input matrix.
|
||||||
collect nil))))
|
nil)))))
|
||||||
|
|
||||||
|
(defun notmuch-hello-reflect (list ncols)
|
||||||
|
"Reflect a `ncols' wide matrix represented by `list' along the
|
||||||
|
diagonal."
|
||||||
|
;; Not very lispy...
|
||||||
|
(let ((nrows (notmuch-hello-roundup (length list) ncols)))
|
||||||
|
(loop for row from 0 to (- nrows 1)
|
||||||
|
append (notmuch-hello-reflect-generate-row ncols nrows row list))))
|
||||||
|
|
||||||
(defun notmuch-hello-widget-search (widget &rest ignore)
|
(defun notmuch-hello-widget-search (widget &rest ignore)
|
||||||
(notmuch-search (widget-get widget
|
(notmuch-search (widget-get widget
|
||||||
|
@ -179,10 +180,10 @@ diagonal."
|
||||||
;; can just insert `(- widest (length name))' spaces -
|
;; can just insert `(- widest (length name))' spaces -
|
||||||
;; the column separator is included in the button if
|
;; the column separator is included in the button if
|
||||||
;; `(equal widest (length name)'.
|
;; `(equal widest (length name)'.
|
||||||
(widget-insert (make-string (- widest (length name)) ? )))
|
(widget-insert (make-string (- widest (length name)) ? ))))
|
||||||
(setq count (1+ count))
|
(setq count (1+ count))
|
||||||
(if (eq (% count tags-per-line) 0)
|
(if (eq (% count tags-per-line) 0)
|
||||||
(widget-insert "\n"))))
|
(widget-insert "\n")))
|
||||||
reordered-list)
|
reordered-list)
|
||||||
|
|
||||||
;; If the last line was not full (and hence did not include a
|
;; If the last line was not full (and hence did not include a
|
||||||
|
|
Loading…
Reference in a new issue