From 79dd15424b80aedba665a7f997776a65d971e3d7 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Wed, 21 Aug 2024 19:27:49 +0300 Subject: [PATCH] mu4e-compose: fix mu4e-compose-captured-message from sans-subject In some but not all cases, a missing subject yielded a description= without anything else. Let's avoid that. Fixes #2746. --- mu4e/mu4e-compose.el | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/mu4e/mu4e-compose.el b/mu4e/mu4e-compose.el index 760d2f4f..11ab2710 100644 --- a/mu4e/mu4e-compose.el +++ b/mu4e/mu4e-compose.el @@ -96,16 +96,19 @@ This multiplexes the `message-mode' hooks `message-send-actions', (defvar mu4e-captured-message) (defun mu4e-compose-attach-captured-message () "Insert the last captured message file as an attachment. -Messages are captured with `mu4e-action-capture-message'." + +Messages are expect to have been captured earlier with +`mu4e-action-capture-message'. Note: this is unrelated to +`org-mode' capturing." (interactive) (if-let* ((msg mu4e-captured-message) - (path (plist-get msg :path)) - (path (and (file-exists-p path) path))) - (mml-attach-file - path - "message/rfc822" - (or (plist-get msg :subject) "No subject") - "attachment") + (path (plist-get msg :path)) + (path (and (file-exists-p path) path)) + (descr (or (plist-get msg :subject) "")) + (descr + (if (and (stringp descr) (not (string-empty-p descr))) + descr "No subject"))) + (mml-attach-file path "message/rfc822" descr "attachment") (mu4e-warn "No valid message has been captured"))) ;; Go to bottom / top