]> git.cworth.org Git - notmuch-wiki/commitdiff
emacstips: add code to check for empty subject
authorDavid Miguel Susano Pinto <carandraug+dev@gmail.com>
Mon, 6 Nov 2023 17:03:51 +0000 (17:03 +0000)
committerDavid Miguel Susano Pinto <carandraug+dev@gmail.com>
Mon, 6 Nov 2023 17:03:51 +0000 (17:03 +0000)
emacstips.mdwn

index 19c354ac3520775e0c840dc4a320808642d6bf11..288690c0c165211436bb7c9348544d91b2dd8d58 100644 (file)
@@ -936,6 +936,21 @@ it recognise English and Portuguese terms:
                   "\\b\\(attach\\|attachment\\|attached\\|anexo\\|anexado\\)\\b")
 
 
+## Avoid forgetting the subject
+
+It happens that we forget to enter the Subject line, particularly when
+we leave that to the end.  It's easy to write a function that checks
+whether the Subject is empty, and add it to `message-send-hook` to get
+confirmation:
+
+    (defun my-notmuch-mua-empty-subject-check ()
+      "Request confirmation before sending a message with empty subject"
+      (when (and (null (message-field-value "Subject"))
+                 (not (y-or-n-p "Subject is empty, send anyway? ")))
+        (error "Sending message cancelled: empty subject.")))
+    (add-hook 'message-send-hook 'my-notmuch-mua-empty-subject-check)
+
+
 ## Applying patches to git repositories
 
 The `notmuch-extract-thread-patches` and