Function: rmail-forward

rmail-forward is an interactive and byte-compiled function defined in rmail.el.gz.

Signature

(rmail-forward RESEND)

Documentation

This function has :override advice: hrmail--rmail-forward.

This is an :override advice, which means that rmail-forward isn't run at all, and the documentation below may be irrelevant.

Forward the current message to another user. With prefix argument, "resend" the message instead of forwarding it; see the documentation of rmail-resend.

View in manual

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/mail/rmail.el.gz
(defun rmail-forward (resend)
  "Forward the current message to another user.
With prefix argument, \"resend\" the message instead of forwarding it;
see the documentation of `rmail-resend'."
  (interactive "P")
  (if (zerop rmail-current-message)
      (error "No message to forward"))
  (if resend
      (call-interactively 'rmail-resend)
    (let ((forward-buffer rmail-buffer)
	  (msgnum rmail-current-message)
	  (subject (concat "["
			   (let ((from (or (mail-fetch-field "From")
					   ;; FIXME - huh?
					   (mail-fetch-field ">From"))))
			     (if from
				 (concat (mail-strip-quoted-names from) ": ")
			       ""))
			   (or (mail-fetch-field "Subject") "")
			   "]")))
      (if (rmail-start-mail
	   nil nil subject nil nil rmail-buffer
	   (list (list 'rmail-mark-message
		       forward-buffer
		       (with-current-buffer rmail-buffer
			 (aref rmail-msgref-vector msgnum))
		       rmail-forwarded-attr-index))
	   ;; If only one window, use it for the mail buffer.
	   ;; Otherwise, use another window for the mail buffer
	   ;; so that the Rmail buffer remains visible
	   ;; and sending the mail will get back to it.
	   (and (not rmail-mail-new-frame) (one-window-p t)))
	  ;; The mail buffer is now current.
	  (save-excursion
	    ;; Insert after header separator--before signature if any.
	    (rfc822-goto-eoh)
	    (forward-line 1)
	    (if (and rmail-enable-mime rmail-enable-mime-composing
		     rmail-insert-mime-forwarded-message-function)
		(prog1
		    (funcall rmail-insert-mime-forwarded-message-function
			     forward-buffer)
		  ;; rmail-insert-mime-forwarded-message-function
		  ;; works by inserting MML tags into forward-buffer.
		  ;; The MUA will need to convert it to MIME before
		  ;; sending.  mail-encode-mml tells them to do that.
		  ;; message.el does that automagically.
		  (or (eq mail-user-agent 'message-user-agent)
		      (setq mail-encode-mml t)))
	      (insert "------- Start of forwarded message -------\n")
	      ;; Quote lines with `- ' if they start with `-'.
	      (let ((beg (point)) end)
		(setq end (point-marker))
		(set-marker-insertion-type end t)
		(insert-buffer-substring forward-buffer)
		(goto-char beg)
		(while (re-search-forward "^-" end t)
		  (beginning-of-line)
		  (insert "- ")
		  (forward-line 1))
		(goto-char end)
		(skip-chars-backward "\n")
		(if (< (point) end)
		    (forward-char 1))
		(delete-region (point) end)
		(set-marker end nil))
	      (insert "------- End of forwarded message -------\n"))
	    (push-mark))))))