Article View: gnu.emacs.vm.bug
Article #9201vm-reply-subject-hook
From: Joe Wells
Date: Fri, 28 Feb 1992 08:03
Date: Fri, 28 Feb 1992 08:03
69 lines
3375 bytes
3375 bytes
The following hook patch allows me to handle reply subjects in a useful
way. Included below is the function I currently bind to this hook, so you
can see how useful it can be.
--
Joe Wells <jbw@cs.bu.edu>
Member of the League for Programming Freedom --- send e-mail for details
----------------------------------------------------------------------
--- vm-reply.el-dist Sat Apr 20 19:35:03 1991
+++ ./vm-reply.el Fri Feb 28 02:40:09 1992
@@ -18,7 +18,11 @@
(require 'vm)
+(defvar vm-reply-subject-hook nil
+ "If non-nil, a function which munges subjects for e-mail replies.
+Called with one argument, the former subject. What it returns will be the
+new subject.")
+
(defun vm-do-reply (to-all include-text count)
(save-restriction
- (widen)
(let ((mail-buffer (current-buffer))
(mlist (vm-select-marked-or-prefixed-messages count))
@@ -38,4 +42,6 @@
(vm-sprintf 'vm-in-reply-to-format (car mp)))
in-reply-to (and (not (equal "" in-reply-to)) in-reply-to))
+ (if vm-reply-subject-hook ;jbw: added
+ (setq subject (funcall vm-reply-subject-hook subject))
(and subject vm-reply-subject-prefix
(let ((case-fold-search t))
@@ -45,5 +51,5 @@
subject)
0)))
- (setq subject (concat vm-reply-subject-prefix subject))))
+ (setq subject (concat vm-reply-subject-prefix subject)))))
(t (cond ((setq tmp (vm-get-header-contents (car mp) "Reply-To"))
(setq to (concat to "," tmp)))
----------------------------------------------------------------------
;; The following function does this with reply subjects. (1) Strips
;; off "Re:" and "Re^2:". (2) Removes trailing "(was: old subject)".
;; (3) Removes leading and trailing spaces. (4) Adds on a "Re:".
;; (5) Asks the user for confirmation. (6) If the user doesn't like,
;; converts into "(was: subject)" and allows the user to edit in
;; minibuffer.
(defun vm-reply-subject-hook (subject)
(let (previous
new-subject
(case-fold-search t))
;; strip prefixes from subject
(while (not (eq subject previous))
(setq previous subject)
(cond ((string-match "\\`[ \t]*re\\(^[0-9]+\\)?:[ \t]*" subject)
(setq subject (substring subject (match-end 0))))
((string-match "[ \t]*(was:.*)\\'" subject)
(setq subject (substring subject 0 (match-beginning 0))))
((string-match "\\`[ \t]+" subject)
(setq subject (substring subject (match-end 0))))
((string-match "[ \t]+\\'" subject)
(setq subject (substring subject 0 (match-beginning 0))))))
(setq new-subject (concat "Re: " subject))
(if (and subject
(y-or-n-p (format "Use \"%s\" as subject? " new-subject)))
new-subject
(let ((unread-command-char ?\C-a))
(read-string "Subject: " (and subject
(format " (was: %s)" subject)))))))
----------------------------------------------------------------------
Technical Details
Message-ID:
<9202280803.AA18766@bigbird.bu.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!wendy-fate.uu.net!bug-vmShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f6829,fb6d085d46c78330,start X-Google-Attributes: gidf6829,public X-Google-ArrivalTime: 1992-02-28 06:07:50 PST Newsgroups: gnu.emacs.vm.bug Sender: bug-vm-request@uunet.uu.net Date: Fri, 28 Feb 92 03:03:14 -0500 From: jbw@bigbird.bu.edu (Joe Wells) Message-ID: <9202280803.AA18766@bigbird.bu.edu> Subject: vm-reply-subject-hook Path: arc1-ca.pugleaf.net!sparky!uunet!wendy-fate.uu.net!bug-vm