From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/28713 Path: main.gmane.org!not-for-mail From: Toby Speight Newsgroups: gmane.emacs.gnus.general Subject: Re: [Message/code] Changing the subject to "new subject (was: old subject)" (was: ...) Date: 11 Jan 2000 12:31:43 +0000 Organization: Citrix Systems (Cambridge) Sender: owner-ding@hpc.uh.edu Message-ID: References: NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1035165511 31270 80.91.224.250 (21 Oct 2002 01:58:31 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 21 Oct 2002 01:58:31 +0000 (UTC) Return-Path: Original-Received: from spinoza.math.uh.edu (spinoza.math.uh.edu [129.7.128.18]) by mailhost.sclp.com (Postfix) with ESMTP id E3FE8D051E for ; Tue, 11 Jan 2000 07:34:00 -0500 (EST) Original-Received: from sina.hpc.uh.edu (lists@Sina.HPC.UH.EDU [129.7.3.5]) by spinoza.math.uh.edu (8.9.1/8.9.1) with ESMTP id GAB00321; Tue, 11 Jan 2000 06:33:37 -0600 (CST) Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Tue, 11 Jan 2000 06:33:33 -0600 (CST) Original-Received: from mailhost.sclp.com (postfix@sclp3.sclp.com [204.252.123.139]) by sina.hpc.uh.edu (8.9.3/8.9.3) with ESMTP id GAA08047 for ; Tue, 11 Jan 2000 06:33:19 -0600 (CST) Original-Received: from gatekeeper.ctxuk.citrix.com (gatekeeper.ctxuk.citrix.com [195.153.38.114]) by mailhost.sclp.com (Postfix) with ESMTP id 8B420D051E for ; Tue, 11 Jan 2000 07:31:46 -0500 (EST) Original-Received: from sh.ctxuk.citrix.com (sh.ctxuk.citrix.com [10.30.224.4]) by gatekeeper.ctxuk.citrix.com (8.8.7/BSCF-1.7) with ESMTP id MAA21990 for ; Tue, 11 Jan 2000 12:31:45 GMT Original-Received: from hwav01.ctxuk.citrix.com (hwav01.ctxuk.citrix.com [10.30.224.26]) by sh.ctxuk.citrix.com (8.8.7/BSCF-1.7) with SMTP id MAA10357 for ; Tue, 11 Jan 2000 12:31:45 GMT Original-Received: from 10.30.224.23 by hwav01.ctxuk.citrix.com (InterScan E-Mail VirusWall NT); Tue, 11 Jan 2000 12:31:45 -0000 (GMT Standard Time) Original-Received: from lanber.cam.eu.citrix.com (LANBER [10.70.1.235]) by hwmail01.ctxuk.citrix.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21) id CN6H9K5A; Tue, 11 Jan 2000 12:31:44 -0000 Original-To: The Gnus Mailing List Original-Lines: 81 X-Author-Info: Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:28713 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:28713 Jonas> Jonas Steverud 0> In article , Jonas wrote: Jonas> Something I sometimes do is changing a subject from "Re: old" Jonas> to "new (was: Re: old)". I have now written a function that Jonas> does it for me. js-gnus-message-change-subject-was is used Jonas> when you speak other language then English. I have a longer version of this function, which does the above but doesn't include any "Re: " in the old-subject part - readers can infer that. It also offers to strip the (was...) part from an existing subject (useful when the thread has drifted completely away from the original topic, and you don't want it to be affected by people's score files for the original). And it shortens the old subject to fit it onto one reasonable-length line, if possible. To change this to use a variable for the word "was" would be easy; adjusting the "(was...)" stripping regexps to remove other variants may be tricky. The code is suitable for use in `message-send-hook'; I recommend that if you also spell-check your articles, you ensure that this function appears first in the hook. (defun message-change-subject-interactively (&optional new-subj) "Change the Subject, bracketing with \"(was...)\" if necessary." (interactive "*") (undo-boundary) (save-excursion (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) "\" from Subject: line? ")))) (setq new-subj (replace-match "" t t subject) subject "")) (when (or (null new-subj) (string= "" new-subj)) (setq new-subj subject subject "")) ;; undo RFC-822 line-wrap (while (string-match "\n[ \t]" subject) (setq subject (replace-match " " t t subject))) ;; might be a followup to a forwarded message, so trim [...] too (while (string-match "\\`\\(\\(Re\\|Fwd\\|AW\\)\\>[.:]?\\|\\[[^][]+\\]\\|[ \t\r]+\\)" 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 (> (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")))))