mu4e: improve update data
Update doccount after indexing.
This commit is contained in:
@ -385,7 +385,10 @@ The server output is as follows:
|
|||||||
((plist-get sexp :info)
|
((plist-get sexp :info)
|
||||||
(funcall mu4e-info-func sexp))
|
(funcall mu4e-info-func sexp))
|
||||||
|
|
||||||
;; get some data
|
;; get some data XXX generalize
|
||||||
|
((plist-get sexp :doccount)
|
||||||
|
(plist-put mu4e--server-props :doccount
|
||||||
|
(mu4e--server-plist-get sexp :doccount)))
|
||||||
((plist-get sexp :maildirs)
|
((plist-get sexp :maildirs)
|
||||||
(setq mu4e-maildir-list (mu4e--server-plist-get sexp :maildirs)))
|
(setq mu4e-maildir-list (mu4e--server-plist-get sexp :maildirs)))
|
||||||
|
|
||||||
@ -556,9 +559,16 @@ get at most MAX contacts."
|
|||||||
|
|
||||||
(defun mu4e--server-data (kind)
|
(defun mu4e--server-data (kind)
|
||||||
"Request data of some KIND.
|
"Request data of some KIND.
|
||||||
KIND is a symbol. Currently supported kinds: maildirs."
|
KIND is a symbol or a list of symbols. Currently supported kinds:
|
||||||
(mu4e--server-call-mu
|
`maildirs', `doccount'."
|
||||||
`(data :kind ,kind)))
|
(pcase kind
|
||||||
|
((pred (lambda (k) (memq k '(maildirs doccount))))
|
||||||
|
(mu4e--server-call-mu `(data :kind ,kind)))
|
||||||
|
((pred listp)
|
||||||
|
(when kind
|
||||||
|
(mu4e--server-data (car kind))
|
||||||
|
(mu4e--server-data (cdr kind))))
|
||||||
|
(_ (mu4e-error "Unexpected kind %s" kind))))
|
||||||
|
|
||||||
(defun mu4e--server-find (query threads sortfield sortdir maxnum skip-dups
|
(defun mu4e--server-find (query threads sortfield sortdir maxnum skip-dups
|
||||||
include-related)
|
include-related)
|
||||||
|
|||||||
@ -130,9 +130,9 @@ changed")
|
|||||||
If non-nil, this is a plist of the form:
|
If non-nil, this is a plist of the form:
|
||||||
\(
|
\(
|
||||||
:checked <number of messages processed> (checked whether up-to-date)
|
:checked <number of messages processed> (checked whether up-to-date)
|
||||||
:updated <number of messages updated/added
|
:updated <number of messages updated/added>
|
||||||
:cleaned-up <number of stale messages removed from store
|
:cleaned-up <number of stale messages removed from store>
|
||||||
:stamp <emacs (current-time) timestamp for the status)")
|
:stamp <emacs (current-time) timestamp for the status>")
|
||||||
|
|
||||||
(defconst mu4e-last-update-buffer "*mu4e-last-update*"
|
(defconst mu4e-last-update-buffer "*mu4e-last-update*"
|
||||||
"Name of buffer with cloned from the last update buffer.
|
"Name of buffer with cloned from the last update buffer.
|
||||||
|
|||||||
65
mu4e/mu4e.el
65
mu4e/mu4e.el
@ -1,6 +1,6 @@
|
|||||||
;;; mu4e.el --- Mu4e, the mu mail user agent -*- lexical-binding: t -*-
|
;;; mu4e.el --- Mu4e, the mu mail user agent -*- lexical-binding: t -*-
|
||||||
|
|
||||||
;; Copyright (C) 2011-2023 Dirk-Jan C. Binnema
|
;; Copyright (C) 2011-2024 Dirk-Jan C. Binnema
|
||||||
|
|
||||||
;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
@ -203,42 +203,47 @@ Otherwise, check requirements, then start mu4e. When successful, invoke
|
|||||||
(_ (mu4e-error "Error %d: %s" errcode errmsg))))
|
(_ (mu4e-error "Error %d: %s" errcode errmsg))))
|
||||||
|
|
||||||
(defun mu4e--update-status (info)
|
(defun mu4e--update-status (info)
|
||||||
"Update the status message with INFO."
|
"Update `mu4e-index-update-status' with INFO.
|
||||||
|
Return the former. As an additional side-effect, updates
|
||||||
|
doccount in server-properties."
|
||||||
(setq mu4e-index-update-status
|
(setq mu4e-index-update-status
|
||||||
`(:tstamp ,(current-time)
|
`(:tstamp ,(current-time)
|
||||||
:checked ,(plist-get info :checked)
|
:checked ,(or (plist-get info :checked) 0)
|
||||||
:updated ,(plist-get info :updated)
|
:updated ,(or (plist-get info :updated) 0)
|
||||||
:cleaned-up ,(plist-get info :cleaned-up))))
|
:cleaned-up ,(or (plist-get info :cleaned-up) 0)))
|
||||||
|
mu4e-index-update-status)
|
||||||
|
|
||||||
(defun mu4e--info-handler (info)
|
(defun mu4e--info-handler (info)
|
||||||
"Handler function for (:INFO ...) sexps received from server."
|
"Handler function for (:INFO ...) sexps received from server."
|
||||||
(let* ((type (plist-get info :info))
|
(let* ((type (plist-get info :info)))
|
||||||
(checked (plist-get info :checked))
|
|
||||||
(updated (plist-get info :updated))
|
|
||||||
(cleaned-up (plist-get info :cleaned-up)))
|
|
||||||
(cond
|
(cond
|
||||||
((eq type 'add) t) ;; do nothing
|
((eq type 'add) t) ;; do nothing
|
||||||
((eq type 'index)
|
((eq type 'index)
|
||||||
(if (eq (plist-get info :status) 'running)
|
(let* ((info (mu4e--update-status info))
|
||||||
(mu4e-index-message
|
(checked (plist-get info :checked))
|
||||||
"Indexing... checked %d, updated %d" checked updated)
|
(updated (plist-get info :updated))
|
||||||
(progn ;; i.e. 'complete
|
(cleaned-up (plist-get info :cleaned-up)))
|
||||||
(mu4e--update-status info)
|
(if (eq (plist-get info :status) 'running)
|
||||||
(mu4e-index-message
|
(mu4e-index-message
|
||||||
"%s completed; checked %d, updated %d, cleaned-up %d"
|
"Indexing... checked %d, updated %d"
|
||||||
(if mu4e-index-lazy-check "Lazy indexing" "Indexing")
|
checked updated)
|
||||||
checked updated cleaned-up)
|
(progn ;; i.e. 'complete
|
||||||
;; index done; grab updated queries
|
(mu4e-index-message
|
||||||
(mu4e--query-items-refresh)
|
"%s completed; checked %d, updated %d, cleaned-up %d"
|
||||||
(run-hooks 'mu4e-index-updated-hook)
|
(if mu4e-index-lazy-check "Lazy indexing" "Indexing")
|
||||||
;; backward compatibility...
|
checked updated cleaned-up)
|
||||||
(unless (zerop (+ updated cleaned-up))
|
;; index done; grab updated queries
|
||||||
mu4e-message-changed-hook)
|
(mu4e--query-items-refresh)
|
||||||
(unless (and (not (string= mu4e--contacts-tstamp "0"))
|
(run-hooks 'mu4e-index-updated-hook)
|
||||||
(zerop (plist-get info :updated)))
|
;; backward compatibility...
|
||||||
(mu4e--request-contacts-maybe)
|
(unless (zerop (+ updated cleaned-up))
|
||||||
(mu4e--server-data 'maildirs)) ;; update maildir list
|
mu4e-message-changed-hook)
|
||||||
(mu4e--main-redraw))))
|
(unless (and (not (string= mu4e--contacts-tstamp "0"))
|
||||||
|
(zerop (plist-get info :updated)))
|
||||||
|
(mu4e--request-contacts-maybe)
|
||||||
|
(mu4e--server-data '(maildirs doccount)))
|
||||||
|
;; update maildir list & doccount
|
||||||
|
(mu4e--main-redraw)))))
|
||||||
((plist-get info :message)
|
((plist-get info :message)
|
||||||
(mu4e-index-message "%s" (plist-get info :message))))))
|
(mu4e-index-message "%s" (plist-get info :message))))))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user