From 6743a7d747b1045b98b289e00c824c7995a386e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= Date: Tue, 11 Nov 2025 13:07:18 +0100 Subject: [PATCH] Add current subject to future history in `message-change-subject' * lisp/gnus/message.el (message-change-subject): Read the new subject with the old subject in the "future history". * etc/NEWS (minutes): Announce the feature. (Bug#79815) --- etc/NEWS | 3 ++ lisp/gnus/message.el | 67 ++++++++++++++++++++++++-------------------- 2 files changed, 40 insertions(+), 30 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index ef2c54efcde..ea4c4cea09f 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1769,6 +1769,9 @@ honored if it was already set. +++ *** 'message-strip-subject-re' now matches case-insensitively. +--- +*** 'message-change-subject' inserts current subject to "future history". + ** Sendmail --- diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index 18a3e0a9fde..0f90a098a3f 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -2400,36 +2400,43 @@ Leading \"Re: \" is not stripped by this function. Use the function ;;; Suggested by Jonas Steverud @ www.dtek.chalmers.se/~d4jonas/ -(defun message-change-subject (new-subject) - "Ask for NEW-SUBJECT header, append (was: )." - (interactive - (list - (read-from-minibuffer "New subject: ")) - message-mode) - (cond ((and (not (or (null new-subject) ; new subject not empty - (zerop (string-width new-subject)) - (string-match "^[ \t]*$" new-subject)))) - (save-excursion - (let ((old-subject - (save-restriction - (message-narrow-to-headers) - (message-fetch-field "Subject")))) - (cond ((not old-subject) - (error "No current subject")) - ((not (string-match - (concat "^[ \t]*" - (regexp-quote new-subject) - "[ \t]*$") - old-subject)) ; yes, it really is a new subject - ;; delete eventual Re: prefix - (setq old-subject - (message-strip-subject-re old-subject)) - (message-goto-subject) - (delete-line) - (insert (concat "Subject: " - new-subject - " (was: " - old-subject ")\n"))))))))) +(defun message-change-subject (&optional new-subject) + "Change subject to NEW-SUBJECT with \"(was: )\" suffix. +If NEW-SUBJECT is nil, the user is prompted for the new subject, with +the old subject in \"future history\"." + (interactive nil message-mode) + (let ((old-subject (save-restriction + (message-narrow-to-headers) + (message-fetch-field "Subject")))) + (if (not old-subject) + (error "No current subject") + (let ((new-subject (or new-subject + (read-from-minibuffer "New subject: " + nil nil nil nil + old-subject)))) + (cond + ;; Abort on empty subject. + ((or (null new-subject) + (zerop (string-width new-subject)) + (string-match "^[ \t]*$" new-subject)) + (message "Subject empty")) + ;; Abort on unchanged subject. + ((string-match + (concat "^[ \t]*" + (regexp-quote new-subject) + "[ \t]*$") + old-subject) + (message "Subject unchanged")) + ;; Otherwise, proceed. + (t + (save-excursion + (message-goto-subject) + (delete-line) + (insert (concat "Subject: " + new-subject + " (was: " + (message-strip-subject-re old-subject) + ")\n"))))))))) (defun message-mark-inserted-region (beg end &optional verbatim) "Mark some region in the current article with enclosing tags.