Function: message-change-subject

message-change-subject is an interactive and byte-compiled function defined in message.el.gz.

Signature

(message-change-subject &optional NEW-SUBJECT)

Documentation

Change subject to NEW-SUBJECT with "(was: <Old Subject>)" suffix.

If NEW-SUBJECT is nil, the user is prompted for the new subject, with the old subject in "future history".

Probably introduced at or before Emacs version 31.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/message.el.gz
;;; Suggested by Jonas Steverud  @  www.dtek.chalmers.se/~d4jonas/

(defun message-change-subject (&optional new-subject)
  "Change subject to NEW-SUBJECT with \"(was: <Old Subject>)\" 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")))))))))