From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/36048 Path: main.gmane.org!not-for-mail From: Toby Speight Newsgroups: gmane.emacs.gnus.general Subject: Re: Integrating message-utils.el into Gnus? Date: 28 Apr 2001 02:34:48 +0100 Organization: Citrix Systems Sender: tspeight@lanber.cam.eu.citrix.com Message-ID: References: <874rval15a.fsf@fulmine.dhs.org> NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1035171699 6488 80.91.224.250 (21 Oct 2002 03:41:39 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 21 Oct 2002 03:41:39 +0000 (UTC) Return-Path: Original-Received: (qmail 23064 invoked by alias); 28 Apr 2001 01:34:56 -0000 Original-Received: (qmail 23059 invoked from network); 28 Apr 2001 01:34:55 -0000 Original-Received: from gatekeeper.ctxuk.citrix.com (root@195.153.38.114) by gnus.org with SMTP; 28 Apr 2001 01:34:55 -0000 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 CAA05181 for ; Sat, 28 Apr 2001 02:34:51 +0100 (BST) Original-Received: from uk1mailscan01 (uk1mailscan01.ctxuk.citrix.com [10.30.224.37]) by sh.ctxuk.citrix.com (8.8.7/BSCF-1.7) with SMTP id CAA07904 for ; Sat, 28 Apr 2001 02:34:51 +0100 (BST) Original-Received: from 10.30.224.104 by uk1mailscan01 (InterScan E-Mail VirusWall NT); Sat, 28 Apr 2001 02:34:51 +0100 (GMT Daylight Time) Original-Received: from lanber.cam.eu.citrix.com ([10.70.128.81]) by hwmail04.ctxuk.citrix.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21) id JJS3T04K; Sat, 28 Apr 2001 02:34:49 +0100 Original-To: The Gnus Mailing List User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 X-Face: wqk-$Z5Z Original-Lines: 117 Xref: main.gmane.org gmane.emacs.gnus.general:36048 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:36048 0> In article <874rval15a.fsf@fulmine.dhs.org>, 0> Matthias Wiehl ("Matthias") wrote: Matthias> Holger Schauer [1] provides a file called message-utils.el Matthias> [2]. It contains a few complementary functions for use with Matthias> Gnus' message-mode. Matthias> Matthias> [1] Matthias> [2] Matthias> Matthias> Matthias> Personally, I find three of those functions extraordinarily Matthias> useful: Matthias> Matthias> o `message-change-subject' asks for a new subject, and Matthias> modifies the message's Subject header in a way that is Matthias> RFC 1036bis compliant: `new subject (was: old subject)'. Matthias> Matthias> o `message-strip-subject-was' can be hooked into Matthias> `message-header-setup-hook'. It strips `(was: old Matthias> subject)' from the Subject header (which is what user Matthias> agents are supposed to do) as far as I know) when Matthias> entering message-mode. Both slrn and tin do this Matthias> out-of-the-box. I've posted my equivalent here before - perhaps someone has the time to compare the two and combine the best bits of each? Matthias> o `message-xpost-fup2' asks for a newsgroup name (providing Matthias> tab-completion via gnus-newsrc-alist). This name is then Matthias> appended to the Newsgroups header, and the Followup-To Matthias> header is modified to contain only the given newsgroup Matthias> name as its value. Furthermore, a customizable note is Matthias> inserted in the message body, saying that a Followup-To Matthias> header has been set. I haven't written anything to do that - sounds cool. Here's my code: -- snip here -- (defvar message-change-subject-ignored-prefixes "\\`\\(\\(Re\\|Fwd\\|AW\\)\\>[.:]?\\|\\[[^][]+\\]\\|[ \t\r]+\\)" "Regexp matching things to be stripped when following up.") (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")))))) -- snip here -- It's suitable for use in `message-send-hook' (that's how I use it), in which case it asks you to confirm the subject if you've not obviously edited it from the existing value. If you change it, it removes any (was...) string and replaces it with one made from the old subject. It attempts to truncate the new (was...) string to fit an 80-column screen, preferably at word boundaries. If you leave the subject unchanged, and there was a "(was...)" section if offers (y-or-n-p) to remove it for you.