Function: mh-forward
mh-forward is an autoloaded, interactive and byte-compiled function
defined in mh-comp.el.gz.
Signature
(mh-forward TO CC &optional RANGE)
Documentation
Forward message.
You are prompted for the TO and CC recipients. You are given a draft to edit that looks like it would if you had run the MH command "forw". You can then add some text.
You can forward several messages by using a RANGE. All of the
messages in the range are inserted into your draft. Check the
documentation of mh-interactive-range to see how RANGE is read
in interactive use.
The hook mh-forward-hook is called on the draft.
See also mh-compose-forward-as-mime-flag,
mh-forward-subject-format, and mh-send.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/mh-e/mh-comp.el.gz
;;;###mh-autoload
(defun mh-forward (to cc &optional range)
"Forward message.
You are prompted for the TO and CC recipients. You are given a
draft to edit that looks like it would if you had run the MH
command \"forw\". You can then add some text.
You can forward several messages by using a RANGE. All of the
messages in the range are inserted into your draft. Check the
documentation of `mh-interactive-range' to see how RANGE is read
in interactive use.
The hook `mh-forward-hook' is called on the draft.
See also `mh-compose-forward-as-mime-flag',
`mh-forward-subject-format', and `mh-send'."
(interactive (list (mh-interactive-read-address "To: ")
(mh-interactive-read-address "Cc: ")
(mh-interactive-range "Forward")))
(let* ((folder mh-current-folder)
(msgs (mh-range-to-msg-list range))
(config (current-window-configuration))
(fwd-msg-file (mh-msg-filename (car msgs) folder))
;; forw always leaves file in "draft" since it doesn't have -draft
(draft-name (expand-file-name "draft" mh-user-path))
(draft (cond ((or (not (file-exists-p draft-name))
(y-or-n-p "The file draft exists; discard it? "))
(mh-exec-cmd "forw" "-build"
(if (and (mh-variant-p 'nmh)
mh-compose-forward-as-mime-flag)
"-mime")
mh-current-folder
(mh-coalesce-msg-list msgs))
(prog1
(mh-read-draft "" draft-name t)
(mh-insert-fields "To:" to "Cc:" cc)
(save-buffer)))
(t
(mh-read-draft "" draft-name nil)))))
(let (orig-from
orig-subject)
(with-current-buffer (get-buffer-create mh-temp-buffer)
(erase-buffer)
(insert-file-contents fwd-msg-file)
(setq orig-from (mh-get-header-field "From:"))
(setq orig-subject (mh-get-header-field "Subject:")))
(let ((forw-subject
(mh-forwarded-letter-subject orig-from orig-subject)))
(mh-modify-header-field "Subject" forw-subject t)
(goto-char (point-min))
;; Set the local value of mh-mail-header-separator according to what is
;; present in the buffer...
(setq-local mh-mail-header-separator
(save-excursion
(goto-char (mh-mail-header-end))
(buffer-substring-no-properties (point)
(line-end-position))))
(setq-local mail-header-separator mh-mail-header-separator) ;override sendmail.el
;; If using MML, translate MH-style directive
(if (equal mh-compose-insertion 'mml)
(save-excursion
(goto-char (mh-mail-header-end))
(while
(re-search-forward
"^#forw \\[\\([^]]+\\)\\] \\(\\+\\S-+\\) \\(.*\\)$"
(point-max) t)
(let ((description (if (equal (match-string 1)
"forwarded messages")
"forwarded message %d"
(match-string 1)))
(msgs (split-string (match-string 3)))
(i 0))
(beginning-of-line)
(delete-region (point) (progn (forward-line 1) (point)))
(dolist (msg msgs)
(setq i (1+ i))
(mh-mml-forward-message (format description i)
folder msg)
;; Was inserted before us, move to end of file to preserve order
(goto-char (point-max)))))))
;; Position just before forwarded message.
(if (re-search-forward "^------- Forwarded Message" nil t)
(forward-line -1)
(goto-char (mh-mail-header-end))
(forward-line 1))
(delete-other-windows)
(mh-add-msgs-to-seq msgs 'forwarded t)
(mh-compose-and-send-mail draft "" folder msgs
to forw-subject cc
mh-note-forw "Forwarded:"
config)
(mh-letter-mode-message)
(mh-letter-adjust-point)
(run-hooks 'mh-forward-hook)))))