🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #1093

MAIL-YANK-ORIGINAL enhancements

#1093
From: Ashwin Ram
Date: Tue, 25 Oct 1988 15:05
60 lines
2780 bytes
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
Technical Details
Message-ID: <8810251505.AA20715@ATHENA.CS.YALE.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!uunet!tut.cis.ohio-state.edu!YALE.ARPA!ram-ashwin

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!uunet!tut.cis.ohio-state.edu!YALE.ARPA!ram-ashwin
From: ram-ashwin@YALE.ARPA (Ashwin Ram)
Newsgroups: gnu.emacs.bug
Subject: MAIL-YANK-ORIGINAL enhancements
Message-ID: <8810251505.AA20715@ATHENA.CS.YALE.EDU>
Date: 25 Oct 88 15:05:01 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 60