From 17c08b71bdb90c9faa0478f2d3ff1d360cd8cd48 Mon Sep 17 00:00:00 2001 From: Charlotte Van Petegem Date: Wed, 29 Mar 2023 17:22:15 +0200 Subject: [PATCH] Switch back to only using unmodified completing-read for contexts --- modules/graphical/mail/default.nix | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/modules/graphical/mail/default.nix b/modules/graphical/mail/default.nix index db343e08..13938bc7 100644 --- a/modules/graphical/mail/default.nix +++ b/modules/graphical/mail/default.nix @@ -149,7 +149,6 @@ in (message-send-mail-function 'message-send-mail-with-sendmail "Use sendmail to send mail instead internal smtp") (message-cite-reply-position 'below "Bottom posting is the correct way to reply to email") :config - (remove-hook 'mu4e-main-mode-hook 'evil-collection-mu4e-update-main-view) (setq mu4e-contexts (list ${lib.concatStringsSep "\n" (map mkAccountConfig (lib.attrValues hmConfig.accounts.email.accounts))})) (add-to-list 'mu4e-bookmarks @@ -210,15 +209,19 @@ in ) ;; Never actually quit mu4e, just close the current buffer (making sure the modeline is still visible) (defalias 'mu4e-quit 'kill-this-buffer) - (defun chvp--mu4e-read-option (prompt options) - (let* ((prompt (mu4e-format "%s" prompt)) - (choice (completing-read prompt (cl-mapcar #'car options) nil t)) - (chosen-el (cl-find-if (lambda (option) (equal choice (car option))) options))) - (if chosen-el - (cdr chosen-el) - (mu4e-warn "Unknown option: '%s'" choice))) - ) - (defalias 'mu4e-read-option 'chvp--mu4e-read-option) + (define-advice mu4e--context-ask-user + (:around (orig-fun &rest args) mu4e--context-ask-user-completing-read) + "Replace `mu4e-read-option` by general-purpose completing-read" + (cl-letf (((symbol-function 'mu4e-read-option) + (lambda (prompt options) + (let* ((prompt (mu4e-format "%s" prompt)) + (choice (completing-read prompt (cl-mapcar #'car options) nil t)) + (chosen-el (cl-find-if (lambda (option) (equal choice (car option))) options))) + (if chosen-el + (cdr chosen-el) + (mu4e-warn "Unknown option: '%s'" choice)))))) + (apply orig-fun args))) + (remove-hook 'mu4e-main-mode-hook 'evil-collection-mu4e-update-main-view) (mu4e 'background) :general (lmap "m" '(mu4e :which-key "mail"))