[comp.emacs] RMAIL forwarding

grover@potomac.UUCP (Mark D. Grover) (10/16/87)

Anyone have a routine to automatically prepend a "Forwarded message
follows" text line before forwarded text?  How about one that appends
"(forwarded)" to the new Subject line?  How about one that prepends
"Re:" to the subject of a reply?

- MDG -
-- 
   --> Our site is in transition.  Please use one of the addresses below. <--
Mark D. Grover (grover@ads.ARPA)   UUCP: ames!amdcad!sun!sundc!potomac!grover
Advanced Decision Systems          1500 Wilson Blvd #512; Arlington, VA 22209
Future address: grover@dc.ads.com  "I've been ionized... but I'm okay now."

ram-ashwin@YALE.ARPA (Ashwin Ram) (10/18/87)

>    Anyone have a routine to automatically prepend a "Forwarded message
>    follows" text line before forwarded text?  ... How about one that prepends
>    "Re:" to the subject of a reply?


The addition of "Re: " is pretty easy.  Just use:
        (concat "Re: " (or subject "[none]"))
instead of:
        subject
in the call to mail-other-window at the end of the rmail-reply function.

----------

For the forwarded message problem, wrap some code around the original
rmail-forward to add whatever you want.  E.g., here's code that will wrap a
"forwarded message follows/ends" message around the original message, and
also set it off from your own comments by inserting a ">  " at the beginning
of each line of the message.  Pick up whatever part of this code you need.

(defun rmail-forward-2 ()
   (interactive)
   (rmail-forward)
;  Remove trailing whitespace (purely esthetic).
   (save-excursion
      (goto-char (point-max))
      (delete-region (point)
                     (progn (re-search-backward "[^ \^I\^L\n]")
                            (end-of-line)
                            (point))))
;  Highlight original message.  Wrap "Forwarded message follows/ends" around it.
   (save-excursion
      (save-restriction
         (re-search-forward (concat "^" (regexp-quote mail-header-separator) "\n"))
         (narrow-to-region (point) (point-max))
         (insert "Forwarded message follows\n")
         (while (re-search-forward "^" (point-max) t)
            (replace-match ">    " t t))
         (goto-char (point-max))
         (insert "\nEnd of forwarded message\n\n"))))

(define-key rmail-mode-map "f" 'rmail-forward-2)

---------

You can hack rmail-yank-original to insert ">  " at the beginning of the
original message (instead of just indenting it) in a similar way.  When
interleaving your reply with the original message, this improves readability
considerably.

Aside: My feeling is that these behaviors should be controlled via variables.
E.g., a rmail-yank-original-prefix that you could set to " " or "> ", and a
rmail-reply-subject-prefix that you could set to "Re: " if you wanted.

-- Ashwin Ram --

ARPA:    Ram-Ashwin@cs.yale.edu
UUCP:    {decvax,linus,seismo}!yale!Ram-Ashwin
BITNET:  Ram@yalecs