From e36d1554de4e395db7a91bb7dba06a10abe1c4a5 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Mon, 16 Sep 2024 22:47:39 +0300 Subject: [PATCH] mu4e: handle xapian single-threaded operation Provide user feedback when we need to wait for the indexing to finish. Suffix the version with "-st" when this is the case. --- mu4e/meson.build | 10 ++++++++-- mu4e/mu4e-main.el | 6 ++++-- mu4e/mu4e-server.el | 23 +++++++++++++++++++++-- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/mu4e/meson.build b/mu4e/meson.build index a2a22bbd..9fb00e66 100644 --- a/mu4e/meson.build +++ b/mu4e/meson.build @@ -16,14 +16,20 @@ # generate some build data for use in mu4e +version_extra='' +if get_option('xapian-single-threaded') + version_extra='-st' +endif + mu4e_meta = configure_file( input: 'mu4e-config.el.in', output: 'mu4e-config.el', install: true, install_dir: mu4e_lispdir, configuration: { - 'VERSION' : meson.project_version(), - 'MU_DOC_DIR' : join_paths(datadir, 'doc', 'mu'), + 'VERSION' : meson.project_version(), + 'MU_VERSION_EXTRA' : version_extra, + 'MU_DOC_DIR' : join_paths(datadir, 'doc', 'mu'), }) mu4e_pkg_desc = configure_file( diff --git a/mu4e/mu4e-main.el b/mu4e/mu4e-main.el index ffe22a58..3fab4023 100644 --- a/mu4e/mu4e-main.el +++ b/mu4e/mu4e-main.el @@ -1,6 +1,6 @@ ;;; mu4e-main.el --- The Main interface for mu4e -*- lexical-binding: t -*- -;; Copyright (C) 2011-2023 Dirk-Jan C. Binnema +;; Copyright (C) 2011-2024 Dirk-Jan C. Binnema ;; Author: Dirk-Jan C. Binnema ;; Maintainer: Dirk-Jan C. Binnema @@ -299,7 +299,9 @@ Otherwise, do nothing." "* " (propertize "mu4e" 'face 'mu4e-header-key-face) (propertize " - mu for emacs version " 'face 'mu4e-title-face) - (propertize mu4e-mu-version 'face 'mu4e-header-key-face) + (propertize (concat mu4e-mu-version + (if (mu4e--server-xapian-single-threaded-p) "-st" "")) + 'face 'mu4e-header-key-face) "\n\n" (propertize " Basics\n\n" 'face 'mu4e-title-face) (mu4e--main-action diff --git a/mu4e/mu4e-server.el b/mu4e/mu4e-server.el index fae83514..2122e834 100644 --- a/mu4e/mu4e-server.el +++ b/mu4e/mu4e-server.el @@ -188,6 +188,11 @@ for bookmarks and maildirs.") "Get the latest server query items." mu4e--server-query-items) +;; temporary +(defun mu4e--server-xapian-single-threaded-p() + "Are we using Xapian in single-threaded mode?" + (plist-get mu4e--server-props :xapian-single-threaded)) + ;;; Handling raw server data @@ -210,6 +215,9 @@ for bookmarks and maildirs.") mu4e--server-cookie-post) "Regular expression matching the length cookie. Match 1 will be the length (in hex).") + +(defvar mu4e--server-indexing nil "Currently indexing?") + (defun mu4e-running-p () "Whether mu4e is running. @@ -383,6 +391,11 @@ The server output is as follows: ;; get some info ((plist-get sexp :info) + ;; when indexing is finished, remove the block + (when (and (eq (plist-get sexp :info) 'index) + (eq (plist-get sexp :status) 'complete)) + (setq mu4e--server-indexing nil)) + (funcall mu4e-info-func sexp)) ;; get some data @@ -486,6 +499,7 @@ You cannot run the repl when mu4e is running (or vice-versa)." (proc (and (buffer-live-p buf) (get-buffer-process buf)))) (when proc (mu4e-message "shutting down") + (setq mu4e--server-indexing nil) (set-process-filter mu4e--server-process nil) (set-process-sentinel mu4e--server-process nil) (let ((delete-exited-processes t)) @@ -526,7 +540,11 @@ You cannot run the repl when mu4e is running (or vice-versa)." (defun mu4e--server-call-mu (form) "Call the mu server with some command FORM." - (unless (mu4e-running-p) (mu4e--server-start)) + (unless (mu4e-running-p) + (mu4e--server-start)) + ;; in single-threaded mode, mu can't accept our command right now. + (when (and (mu4e--server-xapian-single-threaded-p) mu4e--server-indexing) + (mu4e-warn "Cannot handle command while indexing, please retry later.")) (let* ((print-length nil) (print-level nil) (cmd (format "%S" form))) (mu4e-log 'to-server "%s" cmd) @@ -600,7 +618,8 @@ added or removed), since merely editing a message does not update the directory time stamp." (mu4e--server-call-mu `(index :cleanup ,(and cleanup t) - :lazy-check ,(and lazy-check t)))) + :lazy-check ,(and lazy-check t))) + (setq mu4e--server-indexing t)) ;; remember we're indexing. (defun mu4e--server-mkdir (path &optional update) "Create a new maildir-directory at filesystem PATH.