* mu4e: don't balk on searches with no results and some cleanups

This commit is contained in:
djcb 2013-10-14 00:07:27 +03:00
parent 8be5e92709
commit 9abaf83fbd
3 changed files with 18 additions and 20 deletions

View File

@ -482,9 +482,6 @@ if provided, or at the end of the buffer otherwise."
(defconst mu4e~no-matches (purecopy "No matching messages found")) (defconst mu4e~no-matches (purecopy "No matching messages found"))
(defconst mu4e~end-of-results (purecopy "End of search results")) (defconst mu4e~end-of-results (purecopy "End of search results"))
(defun mu4e~headers-found-handler (count) (defun mu4e~headers-found-handler (count)
"Create a one line description of the number of headers found "Create a one line description of the number of headers found
after the end of the search results." after the end of the search results."
@ -497,11 +494,11 @@ after the end of the search results."
mu4e~no-matches mu4e~no-matches
mu4e~end-of-results))) mu4e~end-of-results)))
(insert (propertize str 'face 'mu4e-system-face 'intangible t)) (insert (propertize str 'face 'mu4e-system-face 'intangible t))
(unless (= 0 count) (unless (zerop count)
(mu4e-message "Found %d matching message%s" (mu4e-message "Found %d matching message%s"
count (if (= 1 count) "" "s")))) count (if (= 1 count) "" "s"))
;; highlight the first message ;; highlight the first message
(mu4e~headers-highlight (mu4e~headers-docid-at-point (point-min))) (mu4e~headers-highlight (mu4e~headers-docid-at-point (point-min)))))
;; run-hooks ;; run-hooks
(run-hooks 'mu4e-headers-found-hook))))) (run-hooks 'mu4e-headers-found-hook)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -732,8 +729,18 @@ after the end of the search results."
'field field) " "))) 'field field) " ")))
mu4e-headers-fields))) mu4e-headers-fields)))
(defvar mu4e-headers-mode-abbrev-table nil) (defvar mu4e-headers-mode-abbrev-table nil)
(defun mu4e~headers-auto-update ()
"Update the current headers buffer after indexing has brought
some changes, `mu4e-headers-auto-update' is non-nil and there is no
user-interaction ongoing."
(when (and mu4e-headers-auto-update ;; must be set
(zerop (mu4e-mark-marks-num)) ;; non active marks
(not (active-minibuffer-window))) ;; no user input
(with-current-buffer mu4e~headers-buffer
(mu4e-headers-rerun-search))))
(define-derived-mode mu4e-headers-mode special-mode (define-derived-mode mu4e-headers-mode special-mode
"mu4e:headers" "mu4e:headers"
"Major mode for displaying mu4e search results. "Major mode for displaying mu4e search results.
@ -746,16 +753,7 @@ after the end of the search results."
(set (make-local-variable 'hl-line-face) 'mu4e-header-highlight-face) (set (make-local-variable 'hl-line-face) 'mu4e-header-highlight-face)
;; maybe update the current headers upon indexing changes ;; maybe update the current headers upon indexing changes
(add-hook 'mu4e-index-updated-hook (add-hook 'mu4e-index-updated-hook 'mu4~headers-auto-update nil t)
(defun mu4e~headers-auto-update ()
"Update the current headers buffer after indexing has brought
some changes, `mu4e-headers-auto-update' is non-nil and there is no
user-interaction ongoing."
(when (and mu4e-headers-auto-update ;; must be set
(zerop (mu4e-mark-marks-num)) ;; non active marks
(not (active-minibuffer-window))) ;; no user input
(with-current-buffer mu4e~headers-buffer
(mu4e-headers-rerun-search)))) nil t)
(setq (setq
truncate-lines t truncate-lines t
buffer-undo-list t ;; don't record undo information buffer-undo-list t ;; don't record undo information

View File

@ -135,8 +135,7 @@ clicked."
(mu4e~main-action-str "\t* [U]pdate email & database\n" (mu4e~main-action-str "\t* [U]pdate email & database\n"
'mu4e-update-mail-show-window) 'mu4e-update-mail-show-window)
(mu4e~main-action-str "\t* [S]top update email\n"
'mu4e-interrupt-update-mail)
;; show the queue functions if `smtpmail-queue-dir' is defined ;; show the queue functions if `smtpmail-queue-dir' is defined
(if (file-directory-p smtpmail-queue-dir) (if (file-directory-p smtpmail-queue-dir)
(concat (concat

View File

@ -799,6 +799,7 @@ The messages are inserted into the process buffer."
;; - (optionally) check password requests ;; - (optionally) check password requests
(defvar mu4e~update-buffer-name nil (defvar mu4e~update-buffer-name nil
"Internal, store the name of the buffer process when updating.") "Internal, store the name of the buffer process when updating.")
(defun mu4e-update-mail-and-index (run-in-background) (defun mu4e-update-mail-and-index (run-in-background)
"Get a new mail by running `mu4e-get-mail-command'. If "Get a new mail by running `mu4e-get-mail-command'. If
run-in-background is non-nil (or called with prefix-argument), run run-in-background is non-nil (or called with prefix-argument), run