[gnu.emacs.bug] MAIL-YANK-ORIGINAL enhancements

ram-ashwin@YALE.ARPA (Ashwin Ram) (10/25/88)

GNU Emacs 18.48.0 of Mon Oct 24 1988 on leo.ring.cs.yale.edu (domain/ix)

When replying to a mail message, it would be nice to have a way to highlight
the original message with ">" in the first column as many mailers do.  I've
added a variable to control this behavior.  This defaults to "   " so by
default you get the "indent rigidly by 3" behavior that mail-yank-original
currently has.

mail-prefix-region is separated out since it is nice to bind it to a key so
that you can mark a region and indent it by hand.  ^C^I (I for Indent) is the
key I use for this.  (Idea stolen from gnews).

I've also added mail-yank-hook which is useful to, e.g., fill the yanked
message, delete multiple blank lines, fix up the header, etc., automatically.

If acceptable, this code should go into sendmail.el.

-----------------------------------------------------------------------------
(defvar mail-yank-prefix "   " "String to prefix every line in a yanked message.")

(defun mail-yank-original (arg)
  "Insert the message being replied to, if any (in rmail).
Puts point before the text and mark after.
Prefix each line with mail-yank-prefix.
Just \\[universal-argument] as argument means don't indent
and don't delete any header fields."
  (interactive "P")
  (if mail-reply-buffer
      (let ((start (point)))
	(delete-windows-on mail-reply-buffer)
	(insert-buffer mail-reply-buffer)
	(if (consp arg)
	    nil
	  (mail-yank-clear-headers start (mark)))
	(exchange-point-and-mark)
        (delete-region (point) ; Remove trailing blank lines.
                       (progn (re-search-backward "[^ \^I\^L\n]")
                              (end-of-line)
                              (point)))
        (mail-prefix-region (mark) (point)) ; Highlight original message.
        (insert ?\n)
        (run-hooks 'mail-yank-hook))))

(defun mail-prefix-region (beg end)
   "Prefix region with mail-yank-prefix."
   (interactive "r")
   (save-excursion
      (save-restriction
         (narrow-to-region beg end)
         (goto-char (point-min))
         (while (re-search-forward "^" (point-max) t)
            (replace-match mail-yank-prefix t t)))))
-----------------------------------------------------------------------------


-- Ashwin.

ARPA:    Ram-Ashwin@cs.yale.edu
UUCP:    {decvax,ucbvax,harvard,cmcl2,...}!yale!Ram-Ashwin
BITNET:  Ram@yalecs

weemba@garnet.berkeley.edu (Matthew P Wiener) (10/27/88)

In article <8810251505.AA20715@ATHENA.CS.YALE.EDU>, ram-ashwin@YALE (Ashwin Ram) writes:
>mail-prefix-region is separated out since it is nice to bind it to a
>key so that you can mark a region and indent it by hand.  ^C^I (I for
>Indent) is the key I use for this.  (Idea stolen from gnews).

You could have stolen the code too!

I have several mail hacks designed to make mail-mode like my e-reply mode.
You can find them in the manual in Appendix E.5, or equivalently the info
node "examples mail".  For example, not only is the above indentation sup-
ported, but I have support for fancy signaturing, path aliasing, and so on.

ucbvax!garnet!weemba	Matthew P Wiener/Brahms Gang/Berkeley CA 94720