]> git.notmuchmail.org Git - notmuch/blobdiff - emacs/notmuch-hello.el
emacs: remove redundant notmuch-hello-trim
[notmuch] / emacs / notmuch-hello.el
index 1c0b18485296edaa44ef16b7e24ca5f5121f072a..b67a5e1993aabdf775604c11fe8374b890dd651c 100644 (file)
@@ -387,15 +387,9 @@ afterwards.")
                     (format "%s%03d" notmuch-hello-thousands-separator elem))
                   (cdr result)))))
 
-(defun notmuch-hello-trim (search)
-  "Trim whitespace."
-  (if (string-match "^[[:space:]]*\\(.*[^[:space:]]\\)[[:space:]]*$" search)
-      (match-string 1 search)
-    search))
-
 (defun notmuch-hello-search (&optional search)
   (unless (null search)
-    (setq search (notmuch-hello-trim search))
+    (setq search (string-trim search))
     (let ((history-delete-duplicates t))
       (add-to-history 'notmuch-search-history search)))
   (notmuch-search search notmuch-search-oldest-first))
@@ -589,8 +583,8 @@ 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 ? )))
+             (when (> column-indent 0)
+               (widget-insert (make-string column-indent ? )))
              (let* ((name (plist-get elem :name))
                     (query (plist-get elem :query))
                     (oldest-first (cl-case (plist-get elem :sort-order)
@@ -609,7 +603,7 @@ with `notmuch-hello-query-counts'."
                               name)
                (setq column-indent
                      (1+ (max 0 (- column-width (length name)))))))
-           (setq count (1+ count))
+           (cl-incf count)
            (when (eq (% count tags-per-line) 0)
              (setq column-indent 0)
              (widget-insert "\n")))
@@ -687,7 +681,6 @@ with `notmuch-hello-query-counts'."
     (define-key map (kbd "<C-tab>") 'widget-backward)
     map)
   "Keymap for \"notmuch hello\" buffers.")
-(fset 'notmuch-hello-mode-map notmuch-hello-mode-map)
 
 (define-derived-mode notmuch-hello-mode fundamental-mode "notmuch-hello"
   "Major mode for convenient notmuch navigation. This is your entry portal into notmuch.
@@ -890,8 +883,8 @@ Supports the following entries in OPTIONS as a plist:
    the same values as :filter. If :filter and :filter-count are specified, this
    will be used instead of :filter, not in conjunction with it."
   (widget-insert title ": ")
-  (if (and notmuch-hello-first-run (plist-get options :initially-hidden))
-      (add-to-list 'notmuch-hello-hidden-sections title))
+  (when (and notmuch-hello-first-run (plist-get options :initially-hidden))
+    (add-to-list 'notmuch-hello-hidden-sections title))
   (let ((is-hidden (member title notmuch-hello-hidden-sections))
        (start (point)))
     (if is-hidden
@@ -974,7 +967,7 @@ following:
   (let ((notmuch-hello-auto-refresh nil))
     (if no-display
        (set-buffer "*notmuch-hello*")
-      (switch-to-buffer "*notmuch-hello*")))
+      (pop-to-buffer-same-window "*notmuch-hello*")))
   ;; Install auto-refresh hook
   (when notmuch-hello-auto-refresh
     (add-hook 'window-configuration-change-hook