From: Toby Speight <streapadair@gmx.net>
Subject: message-change-subject-interactively (was: message-subject-re)
Date: 05 Sep 2001 16:02:44 +0100 [thread overview]
Message-ID: <s8u1yhy92j.fsf_-_@suilven.cam.eu.citrix.com> (raw)
In-Reply-To: <m3n14i3ejt.fsf@multivac.cwru.edu>
[-- Attachment #1: Type: text/plain, Size: 242 bytes --]
0> In article <m3n14i3ejt.fsf@multivac.cwru.edu>,
0> Paul R. Jarc <URL:mailto:prj@po.cwru.edu> ("Paul") wrote:
Paul> ... I'd like "(was:.*" to be removed from the Subject: in
Paul> responses. Maybe a hook is in order?
Here's what I use:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-emacs-lisp, Size: 3378 bytes --]
(defun message-change-subject-interactively (&optional new-subj) ;gnus-subject-interactive
"Change the Subject, bracketing with \"(was...)\" if necessary."
(interactive "*")
(undo-boundary)
(save-excursion
(save-restriction
(message-narrow-to-headers-or-head)
(let* ((subject (message-fetch-field "Subject"))
(case-fold-search t))
(if (null subject)
(setq new-subj (read-from-minibuffer "New Subject: "))
;; There was already a subject
(when (string-match "\\s-+\\'" subject) ; remove trailing spaces
(setq subject (replace-match "" t t subject)))
(if (and (not new-subj) (string-match "^[Rr][Ee]\\>" subject))
;; only ask if it wasn't our subject
(setq new-subj
(read-from-minibuffer (concat "New Subject: (was " subject ") "))))
;; new-subj is nil if we already have an original subject (not starting with "Re:")
;; It is a string if we are following-up (so might want to remove "(was ...)")
(if (and new-subj
(or ;(re-search-forward "\\s-*\\((was\\>.*\\)" subject-end t)
(string-match "\\s-*\\([[(,;]\\s-*was\\>.*\\)" subject)
(string-match "\\s-*\\<\\(was:?\\s-+[Rr][Ee]:.*\\)" subject)
(string-match "\\s-*[[(,;]\\s-*\\([Rr][Ee]:.*\\)" subject))
(or (not (string= new-subj "")) ; if replacing, force removal
(y-or-n-p (concat "Remove \"" (match-string 1 subject) "\" from Subject: line? "))))
(setq new-subj (replace-match "" t t subject)
subject nil))
(if (or (null new-subj) (string= "" new-subj))
;; No true change in subject
(setq new-subj subject
subject nil)
;; User changed the subject
;; first undo RFC-822 line-wrap
(while (and subject (string-match "\n[ \t]" subject))
(setq subject (replace-match " " t t subject)))
;; might be a followup to a forwarded message, so trim [...] too
(while (and subject (string-match message-change-subject-ignored-prefixes subject))
(setq subject (replace-match "" t t subject)))
;; Trim subject line to 75 chars (leaving room for a recipient to add "Re: ")
;; "Subject: "(9) + new-subj + "(was: "(6) + subject + "...)"(1 or 4) <=75
;; means subject<=(59 - new-subj) or trim to (56 - new-subj)
(if (and subject (> (length subject) (- 59 (length new-subj))))
(let ((maxlen (- 56 (length new-subj))))
(if (<= maxlen 0)
(setq subject "...")
;; keep one extra char, so we know if last char is a word-boundary
(setq subject (substring subject 0 (1+ maxlen)))
(if (string-match "\\s-*\\(\\B.\\|\\<.\\)*\\'" subject)
(setq subject (replace-match "..." t t subject))))))))
(widen)
(when new-subj
(if (and subject (not (string= "" subject)))
(setq new-subj (concat new-subj " (was: " subject ")")))
(message-goto-subject)
(message-delete-line)
(insert "Subject: " new-subj "\n"))))))
[-- Attachment #3: Type: text/plain, Size: 13 bytes --]
along with
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: Type: text/x-emacs-lisp, Size: 68 bytes --]
(add-hook 'message-send-hook 'message-change-subject-interactively)
[-- Attachment #5: Type: text/plain, Size: 490 bytes --]
to invoke it every time I respond to an article.
It won't change the subject if it doesn't begin with "Re:", assuming
instead that you've written your own subject line, rather than having
a generated one.
BTW the string "Re: " is important, and should never be changed to any
other value unless you want to look like an MS-luser trying to break news
(e.g. such nonstandard prefixes break gnus-gather-threads-by-subject and
avoidance of duplicate "Re: " prefixes, amongst other things).
next prev parent reply other threads:[~2001-09-05 15:02 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-08-29 18:25 message-subject-re Michael.Cook
2001-08-29 18:29 ` message-subject-re Paul Jarc
2001-08-29 18:34 ` message-subject-re Michael.Cook
2001-08-29 18:48 ` message-subject-re Paul Jarc
2001-08-29 19:33 ` message-subject-re Simon Josefsson
2001-08-29 19:40 ` message-subject-re Henrik Enberg
2001-08-29 19:46 ` message-subject-re Paul Jarc
2001-08-29 20:08 ` message-subject-re Michael.Cook
2001-08-29 19:51 ` message-subject-re Frank Schmitt
2001-08-29 20:11 ` message-subject-re Michael.Cook
2001-08-29 23:52 ` message-subject-re Daniel Pittman
2001-08-30 1:50 ` message-subject-re Michael.Cook
2001-08-30 2:31 ` message-subject-re Daniel Pittman
2001-08-30 4:44 ` message-subject-re Paul Jarc
2001-08-30 16:32 ` message-subject-re Michael.Cook
2001-08-30 16:39 ` message-subject-re Jesper Harder
2001-08-30 13:38 ` message-subject-re Per Abrahamsen
2001-08-29 19:43 ` message-subject-re Paul Jarc
2001-08-29 19:51 ` message-subject-re Simon Josefsson
2001-08-30 14:17 ` message-subject-re Per Abrahamsen
2001-08-31 23:26 ` message-subject-re Simon Josefsson
2001-09-01 14:34 ` message-subject-re Per Abrahamsen
2001-08-30 2:16 ` message-subject-re Steve Youngs
2001-09-05 15:02 ` Toby Speight [this message]
2001-09-05 15:12 ` message-subject-re Colin Marquardt
2001-09-05 16:10 ` message-subject-re Michael.Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=s8u1yhy92j.fsf_-_@suilven.cam.eu.citrix.com \
--to=streapadair@gmx.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).