Function: mh-edit-again

mh-edit-again is an autoloaded, interactive and byte-compiled function defined in mh-comp.el.gz.

Signature

(mh-edit-again MESSAGE)

Documentation

Edit a MESSAGE to send it again.

If you don't complete a draft for one reason or another, and if the draft buffer is no longer available, you can pick your draft up again with this command. If you don't use a draft folder, your last "draft" file will be used. If you use draft folders, you'll need to visit the draft folder with "\\[mh-visit-folder] drafts <RET>", use M-x mh-next-undeleted-msg (mh-next-undeleted-msg) to move to the appropriate message, and then use M-x mh-edit-again (mh-edit-again) to prepare the message for editing.

This command can also be used to take messages that were sent to you and to send them to more people.

Don't use this command to re-edit a message from a Mailer-Daemon who complained that your mail wasn't posted for some reason or another (see mh-extract-rejected-mail).

The default message is the current message.

See also mh-send.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/mh-e/mh-comp.el.gz
;;; MH-Folder Commands

;; Alphabetical.

;;;###mh-autoload
(defun mh-edit-again (message)
  "Edit a MESSAGE to send it again.

If you don't complete a draft for one reason or another, and if
the draft buffer is no longer available, you can pick your draft
up again with this command. If you don't use a draft folder, your
last \"draft\" file will be used. If you use draft folders,
you'll need to visit the draft folder with \"\\[mh-visit-folder]
drafts <RET>\", use \\[mh-next-undeleted-msg] to move to the
appropriate message, and then use \\[mh-edit-again] to prepare
the message for editing.

This command can also be used to take messages that were sent to
you and to send them to more people.

Don't use this command to re-edit a message from a Mailer-Daemon
who complained that your mail wasn't posted for some reason or
another (see `mh-extract-rejected-mail').

The default message is the current message.

See also `mh-send'."
  (interactive (list (mh-get-msg-num t)))
  (let* ((from-folder mh-current-folder)
         (config (current-window-configuration))
         (components-file (mh-bare-components mh-comp-formfile))
         (draft
          (cond ((and mh-draft-folder (equal from-folder mh-draft-folder))
                 (pop-to-buffer (find-file-noselect (mh-msg-filename message))
                                t)
                 (rename-buffer (format "draft-%d" message))
                 ;; Make buffer writable...
                 (setq buffer-read-only nil)
                 ;; If buffer was being used to display the message reinsert
                 ;; from file...
                 (when (eq major-mode 'mh-show-mode)
                   (erase-buffer)
                   (insert-file-contents buffer-file-name))
                 (buffer-name))
                (t
                 (mh-read-draft "clean-up" (mh-msg-filename message) nil)))))
    (mh-clean-msg-header (point-min) mh-new-draft-cleaned-headers nil)
    (mh-insert-header-separator)
    ;; Merge in components
    (mapc
     (lambda (header-field)
       (let ((field (car header-field))
             (value (cdr header-field))
             (case-fold-search t))
         (cond
          ;; Address field
          ((string-match field "^To$\\|^Cc$\\|^From$")
           (cond
            ((not (mh-goto-header-field (concat field ":")))
             ;; Header field does not exist, add it
             (mh-goto-header-end 0)
             (insert field ": " value "\n"))
            ((string-equal value "")
             ;; Header field already exists and no value
             )
            (t
             ;; Header field exists and we have a value
             (let (address mailbox (alias (mh-alias-expand value)))
               (and alias
                    (setq address (mail-header-parse-address alias))
                    (setq mailbox (car address)))
               ;; XXX - Need to parse all addresses out of field
               (if (and
                    (not (mh-regexp-in-field-p
                          (concat "\\b" (regexp-quote value) "\\b") field))
                    mailbox
                    (not (mh-regexp-in-field-p
                          (concat "\\b" (regexp-quote mailbox) "\\b") field)))
                   (insert " " value ","))
               ))))
          ((string-match field "^Fcc$")
           ;; Folder reference
           (mh-modify-header-field field value))
          ;; Text field, that's an easy case
          (t
           (mh-modify-header-field field value)))))
     (mh-components-to-list components-file))
    (delete-file components-file)
    (goto-char (point-min))
    (save-buffer)
    (mh-compose-and-send-mail
     draft "" from-folder nil nil nil nil nil nil config)
    (mh-letter-mode-message)
    (mh-letter-adjust-point)))