X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=emacs%2Fnotmuch-hello.el;h=f10d98d2fa120c7862ed59b46d53a826f30cd9c5;hp=aad373d6fbbae7d1d52fc9bd3e1180833ea1fe4d;hb=9429141bb1b73a4e05b2f30d59c3c88bb87c2d43;hpb=3557acab6419c7b9ad9a19c5eb6c305b1184bcf8 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index aad373d6..f10d98d2 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -41,7 +41,7 @@ (defun notmuch-sort-saved-searches (alist) "Generate an alphabetically sorted saved searches alist." - (sort alist (lambda (a b) (string< (car a) (car b))))) + (sort (copy-sequence alist) (lambda (a b) (string< (car a) (car b))))) (defcustom notmuch-saved-search-sort-function nil "Function used to sort the saved searches for the notmuch-hello view. @@ -226,7 +226,7 @@ by an additional filter query. Similarly, the count of messages displayed next to the buttons can be generated by applying a different filter to the tag query. These filters are also supported for \"Customized queries section\" items." - :group 'notmuch + :group 'notmuch-hello :type '(repeat (choice (function-item notmuch-hello-insert-header) @@ -429,7 +429,8 @@ Such a list can be computed with `notmuch-hello-query-counts'." (let* ((widest (notmuch-hello-longest-label searches)) (tags-and-width (notmuch-hello-tags-per-line widest)) (tags-per-line (car tags-and-width)) - (widest (cdr tags-and-width)) + (column-width (cdr tags-and-width)) + (column-indent 0) (count 0) (reordered-list (notmuch-hello-reflect searches tags-per-line)) ;; Hack the display of the buttons used. @@ -441,32 +442,25 @@ Such a list can be computed with `notmuch-hello-query-counts'." (mapc (lambda (elem) ;; (not elem) indicates an empty slot in the matrix. (when elem + (if (> column-indent 0) + (widget-insert (make-string column-indent ? ))) (let* ((name (first elem)) (query (second elem)) - (msg-count (third elem)) - (formatted-name (format "%s " name))) + (msg-count (third elem))) (widget-insert (format "%8s " (notmuch-hello-nice-number msg-count))) - (if (string= formatted-name notmuch-hello-target) + (if (string= name notmuch-hello-target) (setq found-target-pos (point-marker))) (widget-create 'push-button :notify #'notmuch-hello-widget-search :notmuch-search-terms query - formatted-name) - (unless (eq (% count tags-per-line) (1- tags-per-line)) - ;; If this is not the last tag on the line, insert - ;; enough space to consume the rest of the column. - ;; Because the button for the name is `(1+ (length - ;; name))' long (due to the trailing space) we can - ;; just insert `(- widest (length name))' spaces - the - ;; column separator is included in the button if - ;; `(equal widest (length name)'. - (widget-insert (make-string (max 1 - (- widest (length name))) - ? ))))) + name) + (setq column-indent + (1+ (max 0 (- column-width (length name))))))) (setq count (1+ count)) - (if (eq (% count tags-per-line) 0) - (widget-insert "\n"))) + (when (eq (% count tags-per-line) 0) + (setq column-indent 0) + (widget-insert "\n"))) reordered-list) ;; If the last line was not full (and hence did not include a @@ -695,16 +689,16 @@ Supports the following entries in OPTIONS as a plist: (notmuch-hello-update)) "hide")) (widget-insert "\n") - (let (target-pos - (searches (apply 'notmuch-hello-query-counts query-alist options))) - (when (and (not is-hidden) - (or (not (plist-get options :hide-if-empty)) - searches)) - (widget-insert "\n") - (setq target-pos - (notmuch-hello-insert-buttons searches)) - (indent-rigidly start (point) notmuch-hello-indent) - target-pos)))) + (let (target-pos) + (when (not is-hidden) + (let ((searches (apply 'notmuch-hello-query-counts query-alist options))) + (when (or (not (plist-get options :hide-if-empty)) + searches) + (widget-insert "\n") + (setq target-pos + (notmuch-hello-insert-buttons searches)) + (indent-rigidly start (point) notmuch-hello-indent)))) + target-pos))) (defun notmuch-hello-insert-tags-section (&optional title &rest options) "Insert a section displaying all tags with message counts.