From 9fa122cc3194869ed58d278ca9d2910385bb7218 Mon Sep 17 00:00:00 2001 From: TEC Date: Mon, 20 Sep 2021 23:38:13 +0800 Subject: [PATCH] feat(mu4e): prompt for subject when absent Give the user a chance to set the subject when about to send a message without a subject line. --- modules/email/mu4e/config.el | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/email/mu4e/config.el b/modules/email/mu4e/config.el index 14bae6fca..0c8cf3a42 100644 --- a/modules/email/mu4e/config.el +++ b/modules/email/mu4e/config.el @@ -165,6 +165,21 @@ (when (fboundp 'make-xwidget) (add-to-list 'mu4e-view-actions '("xwidgets view" . mu4e-action-view-with-xwidget))) + ;; Detect empty subjects, and give users an opotunity to fill something in + (defun +mu4e-check-for-subject () + "Check that a subject is present, and prompt for a subject if not." + (save-excursion + (goto-char (point-min)) + (search-forward "--text follows this line--") + (re-search-backward "^Subject:") ; this should be present no matter what + (let ((subject (string-trim (substring (thing-at-point 'line) 8)))) + (when (string-empty-p subject) + (end-of-line) + (insert (read-string "Subject (optional): ")) + (message "Sending..."))))) + + (add-hook 'message-send-hook #'+mu4e-check-for-subject) + ;; The header view needs a certain amount of horizontal space to ;; actually show you all the information you want to see ;; so if the header view is entered from a narrow frame,