]> git.notmuchmail.org Git - notmuch/blobdiff - emacs/notmuch-hello.el
emacs: Improve `notmuch-hello' display on ttys.
[notmuch] / emacs / notmuch-hello.el
index f892ff736a74a5c7864d87f9e4f984e9343ec3d7..02017ce59a0ea1fa107aea832b770405274eb429 100644 (file)
@@ -86,8 +86,9 @@ Finally this can be a function that will be called for each tag and
 should return a filter for that tag, or nil to hide the tag."
   :type '(choice (const :tag "All messages" nil)
                 (const :tag "Unread messages" "tag:unread")
-                (const :tag "Custom filter" string)
-                (const :tag "Custom filter function" function))
+                (string :tag "Custom filter"
+                        :value "tag:unread")
+                (function :tag "Custom filter function"))
   :group 'notmuch)
 
 (defcustom notmuch-hello-hide-tags nil
@@ -131,10 +132,12 @@ So:
          (integer :tag "Number of characters")
          (float :tag "Fraction of window")))
 
-(defcustom notmuch-decimal-separator ","
-  "The string used as a decimal separator.
+(defcustom notmuch-hello-thousands-separator " "
+  "The string used as a thousands separator.
 
-Typically \",\" in the US and UK and \".\" in Europe."
+Typically \",\" in the US and UK and \".\" or \" \" in Europe.
+The latter is recommended in the SI/ISO 31-0 standard and by the
+International Bureau of Weights and Measures."
   :group 'notmuch
   :type 'string)
 
@@ -154,8 +157,9 @@ Typically \",\" in the US and UK and \".\" in Europe."
 (defvar notmuch-hello-recent-searches nil)
 
 (defun notmuch-hello-remember-search (search)
-  (if (not (member search notmuch-hello-recent-searches))
-      (push search notmuch-hello-recent-searches))
+  (setq notmuch-hello-recent-searches
+       (delete search notmuch-hello-recent-searches))
+  (push search notmuch-hello-recent-searches)
   (if (> (length notmuch-hello-recent-searches)
         notmuch-recent-searches-max)
       (setq notmuch-hello-recent-searches (butlast notmuch-hello-recent-searches))))
@@ -169,7 +173,7 @@ Typically \",\" in the US and UK and \".\" in Europe."
     (apply #'concat
      (number-to-string (car result))
      (mapcar (lambda (elem)
-             (format "%s%03d" notmuch-decimal-separator elem))
+             (format "%s%03d" notmuch-hello-thousands-separator elem))
             (cdr result)))))
 
 (defun notmuch-hello-trim (search)
@@ -295,15 +299,17 @@ should be. Returns a cons cell `(tags-per-line width)'."
                               :notify #'notmuch-hello-widget-search
                               :notmuch-search-terms query
                               formatted-name)
-               ;; 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)))
-                                           ? ))))
+               (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)))
+                                             ? )))))
            (setq count (1+ count))
            (if (eq (% count tags-per-line) 0)
                (widget-insert "\n")))