From 72da29f68cfd85e2431c29f8d7c8e106e3810976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Date: Mon, 29 Apr 2019 10:24:40 +0100 Subject: [PATCH 1/2] mu4e-update: further generalise the password regexp If you are using a system like "pass" to manage credentials you will get a different form of error as you need a passphrase. Attempt to catch the various forms. While we are it also fix a doc change which was missed when mu4e--get-mail-password-regexp was changed. --- mu4e/mu4e-update.el | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mu4e/mu4e-update.el b/mu4e/mu4e-update.el index bdebf4378..805d2ab37 100644 --- a/mu4e/mu4e-update.el +++ b/mu4e/mu4e-update.el @@ -144,7 +144,11 @@ If non-nil, this is a plist of the form: "Height of the mu4e message retrieval/update buffer.") (defvar mu4e--get-mail-ask-password "mu4e get-mail: Enter password: " "Query string for `mu4e-get-mail-command' password.") -(defvar mu4e--get-mail-password-regexp "^Remote: Enter password: $" +(defvar mu4e--get-mail-password-regexp + (rx (: bol + (zero-or-more (in alnum "_: ")) + (or "P" "p") "ass" (or "word" "phrase") ":" + (zero-or-one " ") eol)) "Regexp for a `mu4e-get-mail-command' password query.") @@ -153,7 +157,7 @@ If non-nil, this is a plist of the form: Currently the filter only checks if the command asks for a password by matching the output against -`mu4e~get-mail-password-regexp'. The messages are inserted into +`mu4e--get-mail-password-regexp'. The messages are inserted into the process buffer. Also scrolls to the final line, and update the progress From 330a6ee5da39ec09020accdac7a73351b79a5132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Date: Thu, 14 Apr 2022 10:28:20 +0100 Subject: [PATCH 2/2] mu4e: attempt to surface hung updates in the UI This is an attempt to give a passive indication of hung email collections by exposing a status on the main page. The typical failure case for me is an expired ssh key session leading to background update hanging because non-interactive sessions shouldn't interrupt the user for key information. I also occasionally see mbsync hanging during collection and just never exiting. At least this way I could see an update started many hours ago and never completed. However it's apparent that there are other notification and logging mechanisms which such a thing should maybe use but none seemed to be good fits. I'm open to a cleaner way to implement this even if it's just in user hooks. --- mu4e/mu4e-main.el | 8 ++++++-- mu4e/mu4e-update.el | 8 ++++++-- mu4e/mu4e-vars.el | 2 ++ mu4e/mu4e.el | 2 ++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/mu4e/mu4e-main.el b/mu4e/mu4e-main.el index 7e9743749..c167c5915 100644 --- a/mu4e/mu4e-main.el +++ b/mu4e/mu4e-main.el @@ -306,8 +306,12 @@ When REFRESH is non nil refresh infos from server." (lambda()(interactive) (mu4e-context-switch)(revert-buffer))) - (mu4e--main-action-str "\t* [U]pdate email & database\n" - 'mu4e-update-mail-and-index) + (mu4e--main-action-str (concat + "\t* [U]pdate email & database " + (when mu4e~update-status + (format "(%s)" mu4e~update-status)) + "\n") + 'mu4e-update-mail-and-index) ;; show the queue functions if `smtpmail-queue-dir' is defined (if (file-directory-p smtpmail-queue-dir) diff --git a/mu4e/mu4e-update.el b/mu4e/mu4e-update.el index 805d2ab37..04a98d8f9 100644 --- a/mu4e/mu4e-update.el +++ b/mu4e/mu4e-update.el @@ -170,8 +170,10 @@ throbber." (process-send-string proc (concat (read-passwd mu4e--get-mail-ask-password) "\n")) - ;; TODO kill process? - (mu4e-error "Unrecognized password request"))) + (setq mu4e~update-status + (format "authorisation failed @ %s" (format-time-string "%H:%M"))) + (mu4e-error "Unrecognized password request") + (kill-process proc))) (when (process-buffer proc) (let ((inhibit-read-only t) (procwin (get-buffer-window (process-buffer proc)))) @@ -281,6 +283,8 @@ run in the background; otherwise, pop up a window." (make-progress-reporter (mu4e-format "Retrieving mail...")))) (set-process-sentinel proc 'mu4e--update-sentinel-func) + (setq mu4e~update-status + (concat "started update @ " (format-time-string "%H:%M"))) ;; if we're running in the foreground, handle password requests (unless run-in-background (process-put proc 'x-interactive (not run-in-background)) diff --git a/mu4e/mu4e-vars.el b/mu4e/mu4e-vars.el index 8a23ee6d8..877ab2544 100644 --- a/mu4e/mu4e-vars.el +++ b/mu4e/mu4e-vars.el @@ -371,6 +371,8 @@ header-view, not including, for instance, the message body.") ;;; Run-time variables / constants ;;;; Main +(defvar mu4e~update-status nil + "The current update status of the mail collection.") ;;;; Other diff --git a/mu4e/mu4e.el b/mu4e/mu4e.el index 61217aae8..502af2068 100644 --- a/mu4e/mu4e.el +++ b/mu4e/mu4e.el @@ -216,6 +216,8 @@ invoke (if mu4e-index-lazy-check "Lazy indexing" "Indexing") checked updated cleaned-up) (run-hooks 'mu4e-index-updated-hook) + (setq mu4e~update-status (format "index complete @ %s" + (format-time-string "%H:%M"))) ;; backward compatibility... (unless (zerop (+ updated cleaned-up)) mu4e-message-changed-hook)