Path: utzoo!telly!ddsw1!lll-winken!killer!mit-eddie!bbn!csd4.milw.wisc.edu!mailrus!tut.cis.ohio-state.edu!EW09.NAS.NASA.GOV!raible From: raible@EW09.NAS.NASA.GOV (Eric L. Raible) Newsgroups: gnu.emacs Subject: rmail-extract-rejected-message Message-ID: <8901201827.AA15278@ew09.nas.nasa.gov> Date: 20 Jan 89 18:27:14 GMT Sender: daemon@tut.cis.ohio-state.edu Reply-To: raible@orville.nas.nasa.gov Distribution: gnu Organization: GNUs Not Usenet Lines: 51 mh-mode has it, rmail mode didn't, so here it is. I put rmail-extract-rejected-message on 'e' (and use x for expunge). ;; GNU Emacs and this file "rmail-extract.el", is distributed in the hope ;; that it will be useful, but WITHOUT ANY WARRANTY. No author or ;; distributor accepts responsibility to anyone for the consequences ;; of using it or for whether it serves any particular purpose or ;; works at all, unless he says so in writing. Refer to the GNU Emacs ;; General Public License for full details. ;; Everyone is granted permission to copy, modify and redistribute GNU ;; Emacs and rmail-extract.el, but only under the conditions described in ;; the GNU Emacs General Public License. A copy of this license is ;; supposed to have been given to you along with GNU Emacs so you can ;; know your rights and responsibilities. It should be in a file ;; named COPYING. Among other things, the copyright notice and this ;; notice must be preserved on all copies. (defvar mail-unsent-separator "^ ----- Unsent message follows -----$") (defun rmail-extract-rejected-message () "Create a message to be sent based on the current RMAIL message. Any text in the RMAIL message before mail-unsend-separator is ignored. This function can also be meaningfully used to messages that have *not* been rejected. Try it and see." (interactive) (rmail-beginning-of-message) (re-search-forward mail-unsent-separator nil t) (let* ((to (rmail-get-field "To")) (subj (rmail-get-field "Subject")) (irp2 (rmail-get-field "In-reply-to")) (cc (rmail-get-field "Cc")) (orig-message (buffer-substring (progn (re-search-forward "\n\n") (point)) (point-max))) (mail-setup-hook (function (lambda () (goto-char (point-max)) (insert orig-message) (mail-to))))) (rmail-beginning-of-message) (mail-other-window nil to subj irp2 cc (current-buffer)))) (defun rmail-get-field (field-name) (save-excursion (let ((case-fold-search t)) (if (re-search-forward (concat "^" field-name ": ") nil t) (buffer-substring (point) (progn (end-of-line) (point)))))))