Switch back to only using unmodified completing-read for contexts

This commit is contained in:
Charlotte Van Petegem 2023-03-29 17:22:15 +02:00
parent 3c4835eb7c
commit 17c08b71bd
No known key found for this signature in database
GPG key ID: 019E764B7184435A

View file

@ -149,7 +149,6 @@ in
(message-send-mail-function 'message-send-mail-with-sendmail "Use sendmail to send mail instead internal smtp") (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") (message-cite-reply-position 'below "Bottom posting is the correct way to reply to email")
:config :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))})) (setq mu4e-contexts (list ${lib.concatStringsSep "\n" (map mkAccountConfig (lib.attrValues hmConfig.accounts.email.accounts))}))
(add-to-list (add-to-list
'mu4e-bookmarks 'mu4e-bookmarks
@ -210,15 +209,19 @@ in
) )
;; Never actually quit mu4e, just close the current buffer (making sure the modeline is still visible) ;; Never actually quit mu4e, just close the current buffer (making sure the modeline is still visible)
(defalias 'mu4e-quit 'kill-this-buffer) (defalias 'mu4e-quit 'kill-this-buffer)
(defun chvp--mu4e-read-option (prompt options) (define-advice mu4e--context-ask-user
(let* ((prompt (mu4e-format "%s" prompt)) (:around (orig-fun &rest args) mu4e--context-ask-user-completing-read)
(choice (completing-read prompt (cl-mapcar #'car options) nil t)) "Replace `mu4e-read-option` by general-purpose completing-read"
(chosen-el (cl-find-if (lambda (option) (equal choice (car option))) options))) (cl-letf (((symbol-function 'mu4e-read-option)
(if chosen-el (lambda (prompt options)
(cdr chosen-el) (let* ((prompt (mu4e-format "%s" prompt))
(mu4e-warn "Unknown option: '%s'" choice))) (choice (completing-read prompt (cl-mapcar #'car options) nil t))
) (chosen-el (cl-find-if (lambda (option) (equal choice (car option))) options)))
(defalias 'mu4e-read-option 'chvp--mu4e-read-option) (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) (mu4e 'background)
:general :general
(lmap "m" '(mu4e :which-key "mail")) (lmap "m" '(mu4e :which-key "mail"))