summaryrefslogtreecommitdiff
path: root/mu4e
diff options
context:
space:
mode:
authorDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2019-07-28 14:28:01 +0300
committerDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2019-07-30 08:51:04 +0300
commit26dca831c6d71d9416c9f6876165cd014fb01e82 (patch)
treeff7a58b8b575a7a660537bad8dead15ea5781bbb /mu4e
parent8f24b4103a6d423689407d4c70ac97907ecb0ed4 (diff)
mu4e: automatically rebuild database when possible
Diffstat (limited to 'mu4e')
-rw-r--r--mu4e/mu4e-proc.el35
-rw-r--r--mu4e/mu4e-utils.el17
2 files changed, 26 insertions, 26 deletions
diff --git a/mu4e/mu4e-proc.el b/mu4e/mu4e-proc.el
index 7ddbe80..7cad766 100644
--- a/mu4e/mu4e-proc.el
+++ b/mu4e/mu4e-proc.el
@@ -253,13 +253,14 @@ Start the process if needed."
(unless (file-executable-p mu4e-mu-binary)
(mu4e-error (format "`mu4e-mu-binary' (%S) not found" mu4e-mu-binary)))
(let* ((process-connection-type nil) ;; use a pipe
- (args '("server"))
- (args (append args (when mu4e-mu-home
- (list (concat "--muhome=" mu4e-mu-home))))))
+ (args '("server"))
+ (args (append args (when mu4e-mu-home (list (concat "--muhome=" mu4e-mu-home)))))
+ (args (append args (list (concat "--maildir=" mu4e-maildir)))))
(setq mu4e~proc-buf "")
+ (message "%S" args)
(setq mu4e~proc-process (apply 'start-process
mu4e~proc-name mu4e~proc-name
- mu4e-mu-binary args))
+ mu4e-mu-binary args))
;; register a function for (:info ...) sexps
(unless mu4e~proc-process
(mu4e-error "Failed to start the mu4e backend"))
@@ -293,23 +294,19 @@ Start the process if needed."
(setq mu4e~proc-buf "") ;; clear any half-received sexps
(cond
((eq status 'signal)
- (cond
- ((or(eq code 9) (eq code 2)) (message nil))
- ;;(message "the mu server process has been stopped"))
- (t (error (format "mu server process received signal %d" code)))))
+ (cond
+ ((or(eq code 9) (eq code 2)) (message nil))
+ ;;(message "the mu server process has been stopped"))
+ (t (error (format "mu server process received signal %d" code)))))
((eq status 'exit)
- (cond
- ((eq code 0)
- (message nil)) ;; don't do anything
- ((eq code 11)
- (error "Database is locked by another process"))
- ((eq code 15)
- (error "Database needs upgrade; try `mu index --rebuild'"))
- ((eq code 19)
- (error "Database empty; try indexing some messages"))
- (t (error "Mu server process ended with exit code %d" code))))
+ (cond
+ ((eq code 0)
+ (message nil)) ;; don't do anything
+ ((eq code 19)
+ (error "Database is locked by another process"))
+ (t (error "Mu server process ended with exit code %d" code))))
(t
- (error "Something bad happened to the mu server process")))))
+ (error "Something bad happened to the mu server process")))))
(defun mu4e~docid-msgid-param (docid-or-msgid)
"Construct a backend parameter based on DOCID-OR-MSGID."
diff --git a/mu4e/mu4e-utils.el b/mu4e/mu4e-utils.el
index ae43a33..abb83fa 100644
--- a/mu4e/mu4e-utils.el
+++ b/mu4e/mu4e-utils.el
@@ -802,17 +802,20 @@ When successful, call FUNC (if non-nil) afterwards."
(lambda (props)
(setq mu4e~server-props props) ;; save props from the server
(let ((version (plist-get props :version))
- (doccount (plist-get props :doccount)))
+ (doccount (plist-get props :doccount)))
(mu4e~check-requirements)
(when func (funcall func))
+ (when (zerop doccount)
+ (mu4e-message "Store is empty; (re)indexing. This can take a while.");
+ (mu4e-update-index))
(when (and mu4e-update-interval (null mu4e~update-timer))
- (setq mu4e~update-timer
- (run-at-time
- 0 mu4e-update-interval
- (lambda () (mu4e-update-mail-and-index
- mu4e-index-update-in-background)))))
+ (setq mu4e~update-timer
+ (run-at-time
+ 0 mu4e-update-interval
+ (lambda () (mu4e-update-mail-and-index
+ mu4e-index-update-in-background)))))
(mu4e-message "Started mu4e with %d message%s in store"
- doccount (if (= doccount 1) "" "s"))))))
+ doccount (if (= doccount 1) "" "s"))))))
;; wake up server
(mu4e~proc-ping)
;; maybe request the list of contacts, automatically refresh after