diff lisp/mh-e/mh-comp.el @ 90261:7beb78bc1f8e

Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-97 Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 616-696) - Add lisp/mh-e/.arch-inventory - Update from CVS - Merge from gnus--rel--5.10 - Update from CVS: lisp/smerge-mode.el: Add 'tools' to file keywords. - lisp/gnus/ChangeLog: Remove duplicate entry * gnus--rel--5.10 (patch 147-181) - Update from CVS - Merge from emacs--cvs-trunk--0 - Update from CVS: lisp/mml.el (mml-preview): Doc fix. - Update from CVS: texi/message.texi: Fix default values. - Update from CVS: texi/gnus.texi (RSS): Addition.
author Miles Bader <miles@gnu.org>
date Mon, 16 Jan 2006 08:37:27 +0000
parents 0ca0d9181b5e 5012e59a73c7
children d88caeac70d7
line wrap: on
line diff
--- a/lisp/mh-e/mh-comp.el	Mon Jan 16 06:59:21 2006 +0000
+++ b/lisp/mh-e/mh-comp.el	Mon Jan 16 08:37:27 2006 +0000
@@ -1,7 +1,7 @@
 ;;; mh-comp.el --- MH-E functions for composing messages
 
 ;; Copyright (C) 1993, 1995, 1997,
-;;  2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+;;  2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Bill Wohler <wohler@newt.com>
 ;; Maintainer: Bill Wohler <wohler@newt.com>
@@ -33,26 +33,24 @@
 
 ;;; Code:
 
+;;(message "> mh-comp")
 (eval-when-compile (require 'mh-acros))
 (mh-require-cl)
-(require 'mh-e)
+
+(require 'easymenu)
 (require 'gnus-util)
-(require 'easymenu)
+(require 'mh-buffers)
+(require 'mh-e)
 (require 'mh-gnus)
+
 (eval-when (compile load eval)
   (ignore-errors (require 'mailabbrev)))
+;;(message "< mh-comp")
 
-;; Shush the byte-compiler
-(defvar adaptive-fill-first-line-regexp)
-(defvar font-lock-defaults)
-(defvar mark-active)
-(defvar sendmail-coding-system)
-(defvar mh-identity-list)
-(defvar mh-identity-default)
-(defvar mh-mml-mode-default)
-(defvar mh-identity-menu)
+
 
 ;;; Autoloads
+
 (autoload 'mail-mode-fill-paragraph "sendmail")
 (autoload 'mm-handle-displayed-p "mm-decode")
 
@@ -80,21 +78,20 @@
 when this function is called.  Also, the hook `sc-pre-hook' is run
 before, and `sc-post-hook' is run after the guts of this function.")
 
+
+
 ;;; Site customization (see also mh-utils.el):
 
 (defvar mh-send-prog "send"
   "Name of the MH send program.
 Some sites need to change this because of a name conflict.")
 
-(defvar mh-redist-full-contents nil
-  "Non-nil if the `dist' command needs whole letter for redistribution.
-This is the case only when `send' is compiled with the BERK option.
-If MH will not allow you to redist a previously redist'd msg, set to nil.")
-
 (defvar mh-redist-background nil
   "If non-nil redist will be done in background like send.
-This allows transaction log to be visible if -watch, -verbose or -snoop are
-used.")
+This allows transaction log to be visible if -watch, -verbose or
+-snoop are used.")
+
+
 
 ;;; Scan Line Formats
 
@@ -109,32 +106,39 @@
 
 (defvar mh-yank-hooks nil
   "Obsolete hook for modifying a citation just inserted in the mail buffer.
+
 Each hook function can find the citation between point and mark.
-And each hook function should leave point and mark around the citation
-text as modified.
+And each hook function should leave point and mark around the
+citation text as modified.
 
-This is a normal hook, misnamed for historical reasons.
-It is semi-obsolete and is only used if `mail-citation-hook' is nil.")
+This is a normal hook, misnamed for historical reasons. It is
+semi-obsolete and is only used if `mail-citation-hook' is nil.")
 
 (defvar mh-comp-formfile "components"
   "Name of file to be used as a skeleton for composing messages.
-Default is \"components\".  If not an absolute file name, the file
-is searched for first in the user's MH directory, then in the
-system MH lib directory.")
+
+Default is \"components\".
+
+If not an absolute file name, the file is searched for first in the
+user's MH directory, then in the system MH lib directory.")
 
 (defvar mh-repl-formfile "replcomps"
   "Name of file to be used as a skeleton for replying to messages.
-Default is \"replcomps\".  If not an absolute file name, the file
-is searched for first in the user's MH directory, then in the
-system MH lib directory.")
+
+Default is \"replcomps\".
+
+If not an absolute file name, the file is searched for first in the
+user's MH directory, then in the system MH lib directory.")
 
 (defvar mh-repl-group-formfile "replgroupcomps"
   "Name of file to be used as a skeleton for replying to messages.
-This file is used to form replies to the sender and all recipients of a
-message. Only used if `(mh-variant-p 'nmh)' is non-nil.
+
 Default is \"replgroupcomps\".
-If not an absolute file name, the file is searched for first in the user's MH
-directory, then in the system MH lib directory.")
+
+This file is used to form replies to the sender and all recipients of
+a message. Only used if `(mh-variant-p 'nmh)' is non-nil.
+If not an absolute file name, the file is searched for first in the
+user's MH directory, then in the system MH lib directory.")
 
 (defvar mh-rejected-letter-start
   (format "^%s$"
@@ -154,12 +158,19 @@
 
 (defvar mh-new-draft-cleaned-headers
   "^Date:\\|^Received:\\|^Message-Id:\\|^From:\\|^Sender:\\|^Errors-To:\\|^Delivery-Date:\\|^Return-Path:"
-  "Regexp of header lines to remove before offering a message as a new draft.
-Used by the \\<mh-folder-mode-map>`\\[mh-edit-again]' and `\\[mh-extract-rejected-mail]' commands.")
+  "Regexp of header lines to remove before offering a message as a new draft\\<mh-folder-mode-map>.
+Used by the \\[mh-edit-again] and \\[mh-extract-rejected-mail] commands.")
 
-(defvar mh-to-field-choices '(("t" . "To:") ("s" . "Subject:") ("c" . "Cc:")
-                              ("b" . "Bcc:") ("f" . "Fcc:") ("r" . "From:")
-                              ("d" . "Dcc:"))
+(defvar mh-to-field-choices '(("a" . "Mail-Reply-To:")
+                              ("b" . "Bcc:")
+                              ("c" . "Cc:")
+                              ("d" . "Dcc:")
+                              ("f" . "Fcc:")
+                              ("l" . "Mail-Followup-To:")
+                              ("m" . "From:")
+                              ("r" . "Reply-To:")
+                              ("s" . "Subject:")
+                              ("t" . "To:"))
   "Alist of (final-character . field-name) choices for `mh-to-field'.")
 
 (defvar mh-letter-mode-map (copy-keymap text-mode-map)
@@ -195,47 +206,63 @@
 
 ;;;###autoload
 (defun mh-smail ()
-  "Compose and send mail with the MH mail system.
-This function is an entry point to MH-E, the Emacs interface to the MH mail
-system.
-
+  "Compose a message with the MH mail system.
 See `mh-send' for more details on composing mail."
   (interactive)
   (mh-find-path)
   (call-interactively 'mh-send))
 
+;;;###autoload
+(defun mh-smail-other-window ()
+  "Compose a message with the MH mail system in other window.
+See `mh-send' for more details on composing mail."
+  (interactive)
+  (mh-find-path)
+  (call-interactively 'mh-send-other-window))
+
 (defvar mh-error-if-no-draft nil)       ;raise error over using old draft
 
 ;;;###autoload
 (defun mh-smail-batch (&optional to subject other-headers &rest ignored)
-  "Set up a mail composition draft with the MH mail system.
-This function is an entry point to MH-E, the Emacs interface to the MH mail
-system. This function does not prompt the user for any header fields, and thus
-is suitable for use by programs that want to create a mail buffer. Users
-should use `mh-smail' to compose mail.
+  "Compose a message with the MH mail system.
+
+This function does not prompt the user for any header fields, and
+thus is suitable for use by programs that want to create a mail
+buffer. Users should use \\[mh-smail] to compose mail.
 
-Optional arguments for setting certain fields include TO, SUBJECT, and
-OTHER-HEADERS. Additional arguments are IGNORED."
+Optional arguments for setting certain fields include TO,
+SUBJECT, and OTHER-HEADERS. Additional arguments are IGNORED.
+
+This function remains for Emacs 21 compatibility. New
+applications should use `mh-user-agent-compose'."
   (mh-find-path)
   (let ((mh-error-if-no-draft t))
     (mh-send (or to "") "" (or subject ""))))
 
-;; XEmacs needs this:
+;;;###autoload
+(define-mail-user-agent 'mh-e-user-agent
+  'mh-user-agent-compose 'mh-send-letter 'mh-fully-kill-draft
+  'mh-before-send-letter-hook)
+
 ;;;###autoload
 (defun mh-user-agent-compose (&optional to subject other-headers continue
                                         switch-function yank-action
                                         send-actions)
   "Set up mail composition draft with the MH mail system.
-This is `mail-user-agent' entry point to MH-E.
+This is the `mail-user-agent' entry point to MH-E. This function
+conforms to the contract specified by `define-mail-user-agent'
+which means that this function should accept the same arguments
+as `compose-mail'.
 
 The optional arguments TO and SUBJECT specify recipients and the
 initial Subject field, respectively.
 
-OTHER-HEADERS is an alist specifying additional
-header fields.  Elements look like (HEADER . VALUE) where both
-HEADER and VALUE are strings.
+OTHER-HEADERS is an alist specifying additional header fields.
+Elements look like (HEADER . VALUE) where both HEADER and VALUE
+are strings.
 
-CONTINUE, SWITCH-FUNCTION, YANK-ACTION and SEND-ACTIONS are ignored."
+CONTINUE, SWITCH-FUNCTION, YANK-ACTION and SEND-ACTIONS are
+ignored."
   (mh-find-path)
   (let ((mh-error-if-no-draft t))
     (mh-send to "" subject)
@@ -245,10 +272,26 @@
       (setq other-headers (cdr other-headers)))))
 
 ;;;###mh-autoload
-(defun mh-edit-again (msg)
-  "Clean up a draft or a message MSG previously sent and make it resendable.
-Default is the current message.
-The variable `mh-new-draft-cleaned-headers' specifies the headers to remove.
+(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)))
@@ -256,8 +299,9 @@
          (config (current-window-configuration))
          (draft
           (cond ((and mh-draft-folder (equal from-folder mh-draft-folder))
-                 (pop-to-buffer (find-file-noselect (mh-msg-filename msg)) t)
-                 (rename-buffer (format "draft-%d" msg))
+                 (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
@@ -267,7 +311,7 @@
                    (insert-file-contents buffer-file-name))
                  (buffer-name))
                 (t
-                 (mh-read-draft "clean-up" (mh-msg-filename msg) nil)))))
+                 (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)
     (goto-char (point-min))
@@ -278,16 +322,21 @@
     (mh-letter-adjust-point)))
 
 ;;;###mh-autoload
-(defun mh-extract-rejected-mail (msg)
-  "Extract message MSG returned by the mail system and make it resendable.
-Default is the current message.  The variable `mh-new-draft-cleaned-headers'
-gives the headers to clean out of the original message.
+(defun mh-extract-rejected-mail (message)
+  "Edit a MESSAGE that was returned by the mail system.
+
+This command prepares the message for editing by removing the
+Mailer-Daemon envelope and unneeded header fields. Fix whatever
+addressing problem you had, and send the message again with
+\\[mh-send-letter].
+
+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))
-        (draft (mh-read-draft "extraction" (mh-msg-filename msg) nil)))
+        (draft (mh-read-draft "extraction" (mh-msg-filename message) nil)))
     (goto-char (point-min))
     (cond ((re-search-forward mh-rejected-letter-start nil t)
            (skip-chars-forward " \t\n")
@@ -298,7 +347,7 @@
     (mh-insert-header-separator)
     (goto-char (point-min))
     (save-buffer)
-    (mh-compose-and-send-mail draft "" from-folder msg
+    (mh-compose-and-send-mail draft "" from-folder message
                               (mh-get-header-field "To:")
                               (mh-get-header-field "From:")
                               (mh-get-header-field "Cc:")
@@ -307,14 +356,21 @@
 
 ;;;###mh-autoload
 (defun mh-forward (to cc &optional range)
-  "Forward messages to the recipients TO and CC.
-Use optional RANGE argument to specify a message or sequence to forward.
-Default is the displayed message.
+  "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.
 
-Check the documentation of `mh-interactive-range' to see how RANGE is read in
-interactive use.
+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.
 
-See also `mh-send'."
+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")))
@@ -325,7 +381,7 @@
          ;; 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? "))
+                           (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)
@@ -350,8 +406,8 @@
              (mh-forwarded-letter-subject orig-from orig-subject)))
         (mh-insert-fields "Subject:" forw-subject)
         (goto-char (point-min))
-        ;; If using MML, translate mhn
-        (if (equal mh-compose-insertion 'gnus)
+        ;; If using MML, translate MH-style directive
+        (if (equal mh-compose-insertion 'mml)
             (save-excursion
               (goto-char (mh-mail-header-end))
               (while
@@ -398,33 +454,31 @@
            (setq from (substring from (1+ comment) (1- (length from)))))))
   (format mh-forward-subject-format from subject))
 
-;;;###autoload
-(defun mh-smail-other-window ()
-  "Compose and send mail in other window with the MH mail system.
-This function is an entry point to MH-E, the Emacs interface to the MH mail
-system.
+;;;###mh-autoload
+(defun mh-redistribute (to cc &optional message)
+  "Redistribute a message.
 
-See `mh-send' for more details on composing mail."
-  (interactive)
-  (mh-find-path)
-  (call-interactively 'mh-send-other-window))
+This command is similar in function to forwarding mail, but it
+does not allow you to edit the message, nor does it add your name
+to the \"From\" header field. It appears to the recipient as if
+the message had come from the original sender. When you run this
+command, you are prompted for the TO and CC recipients. The
+default MESSAGE is the current message.
 
-;;;###mh-autoload
-(defun mh-redistribute (to cc &optional msg)
-  "Redistribute displayed message to recipients TO and CC.
-Use optional argument MSG to redistribute another message.
-Depending on how your copy of MH was compiled, you may need to change the
-setting of the variable `mh-redist-full-contents'.  See its documentation."
+Also investigate the command \\[mh-edit-again] for another way to
+redistribute messages.
+
+See also `mh-redist-full-contents-flag'."
   (interactive (list (mh-read-address "Redist-To: ")
                      (mh-read-address "Redist-Cc: ")
                      (mh-get-msg-num t)))
-  (or msg
-      (setq msg (mh-get-msg-num t)))
+  (or message
+      (setq message (mh-get-msg-num t)))
   (save-window-excursion
     (let ((folder mh-current-folder)
           (draft (mh-read-draft "redistribution"
-                                (if mh-redist-full-contents
-                                    (mh-msg-filename msg)
+                                (if mh-redist-full-contents-flag
+                                    (mh-msg-filename message)
                                   nil)
                                 nil)))
       (mh-goto-header-end 0)
@@ -438,17 +492,18 @@
       (message "Redistributing...")
       (let ((env "mhdist=1"))
         ;; Setup environment...
-        (setq env (concat env " mhaltmsg=" (if mh-redist-full-contents
-                                               buffer-file-name
-                                             (mh-msg-filename msg folder))))
-        (unless mh-redist-full-contents
+        (setq env (concat env " mhaltmsg="
+                          (if mh-redist-full-contents-flag
+                              buffer-file-name
+                            (mh-msg-filename message folder))))
+        (unless mh-redist-full-contents-flag
           (setq env (concat env " mhannotate=1")))
         ;; Redistribute...
         (if mh-redist-background
             (mh-exec-cmd-env-daemon env mh-send-prog nil buffer-file-name)
           (mh-exec-cmd-error env mh-send-prog "-push" buffer-file-name))
         ;; Annotate...
-        (mh-annotate-msg msg folder mh-note-dist
+        (mh-annotate-msg message folder mh-note-dist
                          "-component" "Resent:"
                          "-text" (format "\"%s %s\"" to cc)))
       (kill-buffer draft)
@@ -456,10 +511,11 @@
 
 (defun mh-show-buffer-message-number (&optional buffer)
   "Message number of displayed message in corresponding show buffer.
+
 Return nil if show buffer not displayed.
-If in `mh-letter-mode', don't display the message number being replied to,
-but rather the message number of the show buffer associated with our
-originating folder buffer.
+If in `mh-letter-mode', don't display the message number being replied
+to, but rather the message number of the show buffer associated with
+our originating folder buffer.
 Optional argument BUFFER can be used to specify the buffer."
   (save-excursion
     (if buffer
@@ -481,27 +537,55 @@
 
 ;;;###mh-autoload
 (defun mh-reply (message &optional reply-to includep)
-  "Reply to MESSAGE.
-Default is the displayed message.
-If the optional argument REPLY-TO is not given, prompts for type of addresses
-to reply to:
-   from    sender only,
-   to      sender and primary recipients,
-   cc/all  sender and all recipients.
-If optional prefix argument INCLUDEP provided, then include the message
-in the reply using filter `mhl.reply' in your MH directory.
-If the file named by `mh-repl-formfile' exists, it is used as a skeleton for
-the reply. If REPLY-TO is cc or all and you're using either the nmh or GNU
-mailutils variants and the file names by `mh-repl-group-formfile' exists, it
-is used instead.
+  "Reply to a MESSAGE.
+
+When you reply to a message, you are first prompted with \"Reply
+to whom?\" (unless the optional argument REPLY-TO is provided).
+You have several choices here.
+
+     Response     Reply Goes To
+
+     from         The person who sent the message.  This is the
+                  default, so <RET> is sufficient.
+
+     to           Replies to the sender, plus all recipients in the
+                  \"To:\" header field.
+
+     all
+     cc           Forms a reply to the sender, plus all recipients.
 
-See also `mh-send'."
+Depending on your answer, \"repl\" is given a different argument
+to form your reply. Specifically, a choice of \"from\" or none at
+all runs \"repl -nocc all\", and a choice of \"to\" runs \"repl
+-cc to\". Finally, either \"cc\" or \"all\" runs \"repl -cc all
+-nocc me\".
+
+Two windows are then created. One window contains the message to
+which you are replying in an MH-Show buffer. Your draft, in
+MH-Letter mode (see `mh-letter-mode'), is in the other window.
+
+If you supply a prefix argument INCLUDEP, the message you are
+replying to is inserted in your reply after having first been run
+through \"mhl\" with the format file \"mhl.reply\".
+
+Alternatively, you can customize the option `mh-yank-behavior'
+and choose one of its \"Automatically\" variants to do the same
+thing. If you do so, the prefix argument has no effect.
+
+Another way to include the message automatically in your draft is
+to use \"repl: -filter repl.filter\" in your MH profile.
+
+If you wish to customize the header or other parts of the reply
+draft, please see \"repl\" and \"mh-format\".
+
+See also `mh-reply-show-message-flag',
+`mh-reply-default-reply-to', and `mh-send'."
   (interactive (list
                 (mh-get-msg-num t)
                 (let ((minibuffer-help-form
                        "from => Sender only\nto => Sender and primary recipients\ncc or all => Sender and all recipients"))
                   (or mh-reply-default-reply-to
-                      (completing-read "Reply to whom: [from] "
+                      (completing-read "Reply to whom (default from): "
                                        '(("from") ("to") ("cc") ("all"))
                                        nil
                                        t)))
@@ -527,8 +611,8 @@
                        (group-reply (if (mh-variant-p 'nmh 'mu-mh)
                                         '("-group" "-nocc" "me")
                                       '("-cc" "all" "-nocc" "me"))))
-                 (cond ((or (eq mh-yank-from-start-of-msg 'autosupercite)
-                            (eq mh-yank-from-start-of-msg 'autoattrib))
+                 (cond ((or (eq mh-yank-behavior 'autosupercite)
+                            (eq mh-yank-behavior 'autoattrib))
                         '("-noformat"))
                        (includep '("-filter" "mhl.reply"))
                        (t '())))
@@ -551,8 +635,8 @@
         (message "Composing a reply...done")
         (mh-compose-and-send-mail draft "" folder message to subject cc
                                   mh-note-repl "Replied:" config))
-      (when (and (or (eq 'autosupercite mh-yank-from-start-of-msg)
-                     (eq 'autoattrib mh-yank-from-start-of-msg))
+      (when (and (or (eq 'autosupercite mh-yank-behavior)
+                     (eq 'autoattrib mh-yank-behavior))
                  (eq (mh-show-buffer-message-number) mh-sent-from-msg))
         (undo-boundary)
         (mh-yank-cur-msg))
@@ -560,14 +644,21 @@
 
 ;;;###mh-autoload
 (defun mh-send (to cc subject)
-  "Compose and send a letter.
-Do not call this function from outside MH-E; use \\[mh-smail] instead.
+  "Compose a message.
+
+Your letter appears in an Emacs buffer whose mode is
+MH-Letter (see `mh-letter-mode').
 
-The file named by `mh-comp-formfile' will be used as the form.
-The letter is composed in `mh-letter-mode'; see its documentation for more
-details.
-If `mh-compose-letter-function' is defined, it is called on the draft and
-passed three arguments: TO, CC, and SUBJECT."
+The arguments TO, CC, and SUBJECT can be used to prefill the
+draft fields or suppress the prompts if `mh-compose-prompt-flag'
+is on. They are also passed to the function set in the option
+`mh-compose-letter-function'.
+
+See also `mh-insert-x-mailer-flag' and `mh-letter-mode-hook'.
+
+Outside of an MH-Folder buffer (`mh-folder-mode'), you must call
+either \\[mh-smail] or \\[mh-smail-other-window] to compose a new
+message."
   (interactive (list
                 (mh-interactive-read-address "To: ")
                 (mh-interactive-read-address "Cc: ")
@@ -578,15 +669,10 @@
 
 ;;;###mh-autoload
 (defun mh-send-other-window (to cc subject)
-  "Compose and send a letter in another window.
-Do not call this function from outside MH-E; use \\[mh-smail-other-window]
-instead.
+  "Compose a message in another window.
 
-The file named by `mh-comp-formfile' will be used as the form.
-The letter is composed in `mh-letter-mode'; see its documentation for more
-details.
-If `mh-compose-letter-function' is defined, it is called on the draft and
-passed three arguments: TO, CC, and SUBJECT."
+See `mh-send' for more information and a description of how the
+TO, CC, and SUBJECT arguments are used."
   (interactive (list
                 (mh-interactive-read-address "To: ")
                 (mh-interactive-read-address "Cc: ")
@@ -636,14 +722,16 @@
 
 (defun mh-read-draft (use initial-contents delete-contents-file)
   "Read draft file into a draft buffer and make that buffer the current one.
-USE is a message used for prompting about the intended use of the message.
+
+USE is a message used for prompting about the intended use of the
+message.
 INITIAL-CONTENTS is filename that is read into an empty buffer, or nil
-if buffer should not be modified.  Delete the initial-contents file if
+if buffer should not be modified. Delete the initial-contents file if
 DELETE-CONTENTS-FILE flag is set.
 Returns the draft folder's name.
-If the draft folder facility is enabled in ~/.mh_profile, a new buffer is
-used each time and saved in the draft folder.  The draft file can then be
-reused."
+If the draft folder facility is enabled in ~/.mh_profile, a new buffer
+is used each time and saved in the draft folder. The draft file can
+then be reused."
   (cond (mh-draft-folder
          (let ((orig-default-dir default-directory)
                (draft-file-name (mh-new-draft-name)))
@@ -691,14 +779,16 @@
 
 (defun mh-annotate-msg (msg buffer note &rest args)
   "Mark MSG in BUFFER with character NOTE and annotate message with ARGS.
-MSG can be a message number, a list of message numbers, or a sequence."
+MSG can be a message number, a list of message numbers, or a
+sequence."
   (apply 'mh-exec-cmd "anno" buffer
          (if (listp msg) (append msg args) (cons msg args)))
   (save-excursion
     (cond ((get-buffer buffer)          ; Buffer may be deleted
            (set-buffer buffer)
            (mh-iterate-on-range nil msg
-             (mh-notate nil note (1+ mh-cmd-note)))))))
+             (mh-notate nil note
+                        (+ mh-cmd-note mh-scan-field-destination-offset)))))))
 
 (defun mh-insert-fields (&rest name-values)
   "Insert the NAME-VALUES pairs in the current buffer.
@@ -722,7 +812,8 @@
   "Move to the end of the FIELD in the header.
 Move to end of entire header if FIELD not found.
 Returns non-nil iff FIELD was found.
-The optional second arg is for pre-version 4 compatibility and is IGNORED."
+The optional second arg is for pre-version 4 compatibility and is
+IGNORED."
   (cond ((mh-goto-header-field field)
          (mh-header-field-end)
          t)
@@ -773,9 +864,12 @@
 
 ;;; Mode for composing and sending a draft message.
 
+(defvar mh-pgp-support-flag (not (not (locate-library "mml2015")))
+  "Non-nil means PGP support is available.")
+
 (put 'mh-letter-mode 'mode-class 'special)
 
-;;; Menu extracted from mh-menubar.el V1.1 (31 July 2001)
+;; Menu extracted from mh-menubar.el V1.1 (31 July 2001)
 (eval-when-compile (defvar mh-letter-menu nil))
 (easy-menu-define
   mh-letter-menu mh-letter-mode-map "Menu for MH-E letter mode."
@@ -788,13 +882,13 @@
     ["Insert Signature"         mh-insert-signature t]
     ("Encrypt/Sign Message"
      ["Sign Message"
-      mh-mml-secure-message-sign mh-gnus-pgp-support-flag]
+      mh-mml-secure-message-sign mh-pgp-support-flag]
      ["Encrypt Message"
-      mh-mml-secure-message-encrypt mh-gnus-pgp-support-flag]
+      mh-mml-secure-message-encrypt mh-pgp-support-flag]
      ["Sign+Encrypt Message"
-      mh-mml-secure-message-signencrypt mh-gnus-pgp-support-flag]
+      mh-mml-secure-message-signencrypt mh-pgp-support-flag]
      ["Disable Security"
-      mh-mml-unsecure-message mh-gnus-pgp-support-flag]
+      mh-mml-unsecure-message mh-pgp-support-flag]
      "--"
      "Security Method"
      ["PGP (MIME)" (setq mh-mml-method-default "pgpmime")
@@ -810,23 +904,26 @@
      ["Save Method as Default"
       (customize-save-variable 'mh-mml-method-default mh-mml-method-default) t]
      )
-    ["Compose Insertion (MIME)..."      mh-compose-insertion t]
-    ["Compose Compressed tar (MIME)..."
-     mh-mhn-compose-external-compressed-tar t]
-    ["Compose Get File (MIME)..."       mh-mhn-compose-anon-ftp t]
-    ["Compose Forward (MIME)..."        mh-compose-forward t]
+    ["Compose Insertion..."      mh-compose-insertion t]
+    ["Compose Compressed tar (MH)..."
+     mh-mh-compose-external-compressed-tar t]
+    ["Compose Get File (MH)..."       mh-mh-compose-anon-ftp t]
+    ["Compose Forward..."        mh-compose-forward t]
     ;; The next two will have to be merged. But I also need to make sure the
-    ;; user can't mix directives of both types.
-    ["Pull in All Compositions (mhn)"
-     mh-edit-mhn (mh-mhn-directive-present-p)]
-    ["Pull in All Compositions (gnus)"
-     mh-mml-to-mime (mh-mml-directive-present-p)]
-    ["Revert to Non-MIME Edit (mhn)"
-     mh-revert-mhn-edit (equal mh-compose-insertion 'mhn)]
+    ;; user can't mix tags of both types.
+    ["Pull in All Compositions (MH)"
+     mh-mh-to-mime (mh-mh-directive-present-p)]
+    ["Pull in All Compositions (MML)"
+     mh-mml-to-mime (mh-mml-tag-present-p)]
+    ["Revert to Non-MIME Edit (MH)"
+     mh-mh-to-mime-undo (equal mh-compose-insertion 'mh)]
     ["Kill This Draft"          mh-fully-kill-draft t]))
 
+
+
 ;;; Help Messages
-;;; Group messages logically, more or less.
+
+;; Group messages logically, more or less.
 (defvar mh-letter-mode-help-messages
   '((nil
      "Send letter:          \\[mh-send-letter]"
@@ -846,51 +943,41 @@
      "\t\t  Signature:              \\[mh-insert-signature]"))
   "Key binding cheat sheet.
 
-This is an associative array which is used to show the most common commands.
-The key is a prefix char. The value is one or more strings which are
-concatenated together and displayed in the minibuffer if ? is pressed after
-the prefix character. The special key nil is used to display the
-non-prefixed commands.
-
-The substitutions described in `substitute-command-keys' are performed as
-well.")
+This is an associative array which is used to show the most
+common commands. The key is a prefix char. The value is one or
+more strings which are concatenated together and displayed in the
+minibuffer if ? is pressed after the prefix character. The
+special key nil is used to display the non-prefixed commands.
 
-;;;###mh-autoload
-(defun mh-fill-paragraph-function (arg)
-  "Fill paragraph at or after point.
-Prefix ARG means justify as well. This function enables `fill-paragraph' to
-work better in MH-Letter mode."
-  (interactive "P")
-  (let ((fill-paragraph-function) (fill-prefix))
-    (if (mh-in-header-p)
-        (mail-mode-fill-paragraph arg)
-      (fill-paragraph arg))))
+The substitutions described in `substitute-command-keys' are
+performed as well.")
 
-;; Avoid compiler warnings in XEmacs and Emacs 20
+;; Shush compiler.
 (eval-when-compile
-  (defvar tool-bar-mode)
+  (defvar adaptive-fill-first-line-regexp)
   (defvar tool-bar-map))
 
+(defvar mh-letter-buttons-init-flag nil)
+
 ;;;###autoload
-(define-derived-mode mh-letter-mode text-mode "MH-Letter"
-  "Mode for composing letters in MH-E.\\<mh-letter-mode-map>
-
-When you have finished composing, type \\[mh-send-letter] to send the message
-using the MH mail handling system.
+(define-derived-mode mh-letter-mode mail-mode "MH-Letter"
+  "Mode for composing letters in MH-E\\<mh-letter-mode-map>.
 
-There are two types of MIME directives used by MH-E: Gnus and MH. The option
-`mh-compose-insertion' controls what type of directives are inserted by MH-E
-commands. These directives can be converted to MIME body parts by running
-\\[mh-edit-mhn] for mhn directives or \\[mh-mml-to-mime] for Gnus directives.
-This step is mandatory if these directives are added manually. If the
-directives are inserted with MH-E commands such as \\[mh-compose-insertion],
-the directives are expanded automatically when the letter is sent.
+When you have finished composing, type \\[mh-send-letter] to send
+the message using the MH mail handling system.
+
+There are two types of tags used by MH-E when composing MIME
+messages: MML and MH. The option `mh-compose-insertion' controls
+what type of tags are inserted by MH-E commands. These tags can
+be converted to MIME body parts by running \\[mh-mh-to-mime] for
+MH-style directives or \\[mh-mml-to-mime] for MML tags.
 
 Options that control this mode can be changed with
 \\[customize-group]; specify the \"mh-compose\" group.
 
-When a message is composed, the hooks `text-mode-hook' and
-`mh-letter-mode-hook' are run.
+When a message is composed, the hooks `text-mode-hook',
+`mail-mode-hook', and `mh-letter-mode-hook' are run (in that
+order).
 
 \\{mh-letter-mode-map}"
   (mh-find-path)
@@ -900,6 +987,10 @@
   (make-local-variable 'mh-previous-window-config)
   (make-local-variable 'mh-sent-from-folder)
   (make-local-variable 'mh-sent-from-msg)
+  (mh-do-in-gnu-emacs
+   (unless mh-letter-buttons-init-flag
+     (mh-tool-bar-letter-buttons-init)
+     (setq mh-letter-buttons-init-flag t)))
   ;; Set the local value of mh-mail-header-separator according to what is
   ;; present in the buffer...
   (set (make-local-variable 'mh-mail-header-separator)
@@ -913,40 +1004,14 @@
   (setq buffer-invisibility-spec '((vanish . t) t))
   (set (make-local-variable 'line-move-ignore-invisible) t)
 
-  ;; From sendmail.el for proper paragraph fill
-  ;; sendmail.el also sets a normal-auto-fill-function (not done here)
-  (make-local-variable 'paragraph-separate)
-  (make-local-variable 'paragraph-start)
-  (make-local-variable 'fill-paragraph-function)
-  (setq fill-paragraph-function 'mh-fill-paragraph-function)
-  (make-local-variable 'adaptive-fill-regexp)
-  (setq adaptive-fill-regexp
-        (concat adaptive-fill-regexp
-                "\\|[ \t]*[-[:alnum:]]*>+[ \t]*"))
-  (make-local-variable 'adaptive-fill-first-line-regexp)
-  (setq adaptive-fill-first-line-regexp
-        (concat adaptive-fill-first-line-regexp
-                "\\|[ \t]*[-[:alnum:]]*>+[ \t]*"))
-  ;; `-- ' precedes the signature.  `-----' appears at the start of the
-  ;; lines that delimit forwarded messages.
-  ;; Lines containing just >= 3 dashes, perhaps after whitespace,
-  ;; are also sometimes used and should be separators.
-  (setq paragraph-start (concat (regexp-quote mail-header-separator)
-                                "\\|\t*\\([-|#;>* ]\\|(?[0-9]+[.)]\\)+$"
-                                "\\|[ \t]*[[:alnum:]]*>+[ \t]*$\\|[ \t]*$\\|"
-                                "-- $\\|---+$\\|"
-                                page-delimiter))
-  (setq paragraph-separate paragraph-start)
-  ;; --- End of code from sendmail.el ---
-
   ;; Enable undo since a show-mode buffer might have been reused.
   (buffer-enable-undo)
   (set (make-local-variable 'tool-bar-map) mh-letter-tool-bar-map)
-  (mh-funcall-if-exists mh-toolbar-init :letter)
+  (mh-funcall-if-exists mh-tool-bar-init :letter)
   (make-local-variable 'font-lock-defaults)
   (cond
-   ((or (equal mh-highlight-citation-p 'font-lock)
-        (equal mh-highlight-citation-p 'gnus))
+   ((or (equal mh-highlight-citation-style 'font-lock)
+        (equal mh-highlight-citation-style 'gnus))
     ;; Let's use font-lock even if gnus is used in show-mode.  The reason
     ;; is that gnus uses static text properties which are not appropriate
     ;; for a buffer that will be edited.  So the choice here is either fontify
@@ -989,8 +1054,8 @@
 
 (defun mh-letter-header-end ()
   "Find the end of the message header.
-This function is to be used only for font locking. It works by searching for
-`mh-mail-header-separator' in the buffer."
+This function is to be used only for font locking. It works by
+searching for `mh-mail-header-separator' in the buffer."
   (save-excursion
     (goto-char (point-min))
     (cond ((equal mh-mail-header-separator "") (point-min))
@@ -1000,7 +1065,8 @@
 
 (defun mh-auto-fill-for-letter ()
   "Perform auto-fill for message.
-Header is treated specially by inserting a tab before continuation lines."
+Header is treated specially by inserting a tab before continuation
+lines."
   (if (mh-in-header-p)
       (let ((fill-prefix "\t"))
         (do-auto-fill))
@@ -1016,10 +1082,13 @@
 
 ;;;###mh-autoload
 (defun mh-to-field ()
-  "Move point to the end of a specified header field.
-The field is indicated by the previous keystroke (the last keystroke
-of the command) according to the list in the variable `mh-to-field-choices'.
-Create the field if it does not exist.  Set the mark to point before moving."
+  "Move to specified header field.
+
+The field is indicated by the previous keystroke (the last
+keystroke of the command) according to the list in the variable
+`mh-to-field-choices'.
+Create the field if it does not exist.
+Set the mark to point before moving."
   (interactive)
   (expand-abbrev)
   (let ((target (cdr (or (assoc (char-to-string (logior last-input-char ?`))
@@ -1047,19 +1116,19 @@
 
 ;;;###mh-autoload
 (defun mh-to-fcc (&optional folder)
-  "Insert an Fcc: FOLDER field in the current message.
-Prompt for the field name with a completion list of the current folders."
-  (interactive)
-  (or folder
-      (setq folder (mh-prompt-for-folder
-                    "Fcc"
-                    (or (and mh-default-folder-for-message-function
-                             (save-excursion
-                               (goto-char (point-min))
-                               (funcall
-                                mh-default-folder-for-message-function)))
-                        "")
-                    t)))
+  "Move to \"Fcc:\" header field.
+
+This command will prompt you for the FOLDER name in which to file
+a copy of the draft."
+  (interactive (list (mh-prompt-for-folder
+                      "Fcc"
+                      (or (and mh-default-folder-for-message-function
+                               (save-excursion
+                                 (goto-char (point-min))
+                                 (funcall
+                                  mh-default-folder-for-message-function)))
+                          "")
+                      t)))
   (let ((last-input-char ?\C-f))
     (expand-abbrev)
     (save-excursion
@@ -1075,28 +1144,40 @@
          (file-exists-p file)
          (or (and (not (mh-have-file-command))
                   (not (null (string-match "\.vcf$" file))))
-             (and (mh-have-file-command)
-                  (string-equal "text/x-vcard" (mh-file-mime-type file)))))))
+             (string-equal "text/x-vcard" (mh-file-mime-type file))))))
 
 ;;;###mh-autoload
 (defun mh-insert-signature (&optional file)
-  "Insert the signature specified by `mh-signature-file-name' or FILE at point.
-A signature separator (`-- ') will be added if the signature block does not
-contain one and `mh-signature-separator-flag' is on.
-The value of `mh-letter-insert-signature-hook' is a list of functions to be
-called, with no arguments, after the signature is inserted.
-The signature can also be inserted with `mh-identity-list'."
-(interactive)
+  "Insert signature in message.
+
+This command inserts your signature at the current cursor location.
+
+By default, the text of your signature is taken from the file
+\"~/.signature\". You can read from other sources by changing the
+option `mh-signature-file-name'.
+
+A signature separator (\"-- \") will be added if the signature block
+does not contain one and `mh-signature-separator-flag' is on.
+
+The hook `mh-insert-signature-hook' is run after the signature is
+inserted. Hook functions may access the actual name of the file or the
+function used to insert the signature with `mh-signature-file-name'.
+
+The signature can also be inserted using Identities (see
+`mh-identity-list').
+
+In a program, you can pass in a signature FILE."
+  (interactive)
   (save-excursion
     (insert "\n")
     (let ((mh-signature-file-name (or file mh-signature-file-name))
-          (mh-mhn-p (mh-mhn-directive-present-p))
-          (mh-mml-p (mh-mml-directive-present-p)))
+          (mh-mh-p (mh-mh-directive-present-p))
+          (mh-mml-p (mh-mml-tag-present-p)))
       (save-restriction
         (narrow-to-region (point) (point))
         (cond
          ((mh-file-is-vcard-p mh-signature-file-name)
-          (if (equal mh-compose-insertion 'gnus)
+          (if (equal mh-compose-insertion 'mml)
               (insert "<#part type=\"text/x-vcard\" filename=\""
                       mh-signature-file-name
                       "\" disposition=inline description=VCard>\n<#/part>")
@@ -1105,7 +1186,7 @@
                     "\" [VCard] " (expand-file-name mh-signature-file-name))))
          (t
           (cond
-           (mh-mhn-p
+           (mh-mh-p
             (insert "#\n" "Content-Description: Signature\n"))
            (mh-mml-p
             (mml-insert-tag 'part 'type "text/plain" 'disposition "inline"
@@ -1118,13 +1199,13 @@
                  (funcall mh-signature-file-name)))))
         (save-restriction
           (widen)
-          (run-hooks 'mh-letter-insert-signature-hook))
+          (run-hooks 'mh-insert-signature-hook))
         (goto-char (point-min))
         (when (and (not (mh-file-is-vcard-p mh-signature-file-name))
                    mh-signature-separator-flag
                    (> (point-max) (point-min))
                    (not (mh-signature-separator-p)))
-          (cond (mh-mhn-p
+          (cond (mh-mh-p
                  (forward-line 2))
                 (mh-mml-p
                  (forward-line 1)))
@@ -1135,7 +1216,11 @@
 
 ;;;###mh-autoload
 (defun mh-check-whom ()
-  "Verify recipients of the current letter, showing expansion of any aliases."
+  "Verify recipients, showing expansion of any aliases.
+
+This command expands aliases so you can check the actual address(es)
+in the alias. A new buffer named \"*MH-E Recipients*\" is created with
+the output of \"whom\"."
   (interactive)
   (let ((file-name buffer-file-name))
     (save-buffer)
@@ -1174,8 +1259,8 @@
 
 (defvar mh-x-mailer-string nil
   "*String containing the contents of the X-Mailer header field.
-If nil, this variable is initialized to show the version of MH-E, Emacs, and
-MH the first time a message is composed.")
+If nil, this variable is initialized to show the version of MH-E,
+Emacs, and MH the first time a message is composed.")
 
 (defun mh-insert-x-mailer ()
   "Append an X-Mailer field to the header.
@@ -1215,12 +1300,14 @@
 
 ;;;###mh-autoload
 (defun mh-insert-auto-fields (&optional non-interactive)
-  "Insert custom fields if To or Cc match `mh-auto-fields-list'.
-Sets buffer-local `mh-insert-auto-fields-done-local' when done and inserted
-something.  If NON-INTERACTIVE is non-nil, do not be verbose and only
-attempt matches if `mh-insert-auto-fields-done-local' is nil.
+  "Insert custom fields if recipient is found in `mh-auto-fields-list'.
 
-An `identity' entry is skipped if one was already entered manually.
+Sets buffer-local `mh-insert-auto-fields-done-local' if header
+fields were added. If NON-INTERACTIVE is non-nil, perform actions
+quietly and only if `mh-insert-auto-fields-done-local' is nil.
+
+An `identity' entry is skipped if one was already entered
+manually.
 
 Return t if fields added; otherwise return nil."
   (interactive)
@@ -1261,7 +1348,8 @@
 
 (defun mh-modify-header-field (field value &optional overwrite-flag)
   "To header FIELD add VALUE.
-If OVERWRITE-FLAG is non-nil then the old value, if present, is discarded."
+If OVERWRITE-FLAG is non-nil then the old value, if present, is
+discarded."
   (cond ((and overwrite-flag
               (mh-goto-header-field (concat field ":")))
          (insert " " value)
@@ -1284,15 +1372,16 @@
                                        config)
   "Edit and compose a draft message in buffer DRAFT and send or save it.
 SEND-ARGS is the argument passed to the send command.
-SENT-FROM-FOLDER is buffer containing scan listing of current folder, or
-nil if none exists.
+SENT-FROM-FOLDER is buffer containing scan listing of current folder,
+or nil if none exists.
 SENT-FROM-MSG is the message number or sequence name or nil.
 The TO, SUBJECT, and CC fields are passed to the
 `mh-compose-letter-function'.
-If ANNOTATE-CHAR is non-null, it is used to notate the scan listing of the
-message.  In that case, the ANNOTATE-FIELD is used to build a string
-for `mh-annotate-msg'.
-CONFIG is the window configuration to restore after sending the letter."
+If ANNOTATE-CHAR is non-null, it is used to notate the scan listing of
+the message. In that case, the ANNOTATE-FIELD is used to build a
+string for `mh-annotate-msg'.
+CONFIG is the window configuration to restore after sending the
+letter."
   (pop-to-buffer draft)
   (mh-letter-mode)
 
@@ -1339,21 +1428,31 @@
 
 (defun mh-ascii-buffer-p ()
   "Check if current buffer is entirely composed of ASCII.
-The function doesn't work for XEmacs since `find-charset-region' doesn't exist
-there."
+The function doesn't work for XEmacs since `find-charset-region'
+doesn't exist there."
   (loop for charset in (mh-funcall-if-exists
                         find-charset-region (point-min) (point-max))
         unless (eq charset 'ascii) return nil
         finally return t))
 
+;; Shush compiler.
+(eval-when-compile (defvar sendmail-coding-system))
+
 ;;;###mh-autoload
 (defun mh-send-letter (&optional arg)
-  "Send the draft letter in the current buffer.
-If optional prefix argument ARG is provided, monitor delivery.
-The value of `mh-before-send-letter-hook' is a list of functions to be called,
-with no arguments, before doing anything.
-Run `\\[mh-edit-mhn]' if mhn directives are present; otherwise
-run `\\[mh-mml-to-mime]' if mml directives are present."
+  "Save draft and send message.
+
+When you are all through editing a message, you send it with this
+command. You can give a prefix argument ARG to monitor the first stage
+of the delivery\; this output can be found in a buffer called \"*MH-E
+Mail Delivery*\".
+
+The hook `mh-before-send-letter-hook' is run at the beginning of
+this command. For example, if you want to check your spelling in
+your message before sending, add the function `ispell-message'.
+
+In case the MH \"send\" program is installed under a different name,
+use `mh-send-prog' to tell MH-E the name."
   (interactive "P")
   (run-hooks 'mh-before-send-letter-hook)
   (if (and (mh-insert-auto-fields t)
@@ -1361,9 +1460,9 @@
            (goto-char (point-min)))
       (if (not (y-or-n-p "Auto fields inserted, send? "))
           (error "Send aborted")))
-  (cond ((mh-mhn-directive-present-p)
-         (mh-edit-mhn))
-        ((or (mh-mml-directive-present-p) (not (mh-ascii-buffer-p)))
+  (cond ((mh-mh-directive-present-p)
+         (mh-mh-to-mime))
+        ((or (mh-mml-tag-present-p) (not (mh-ascii-buffer-p)))
          (mh-mml-to-mime)))
   (save-buffer)
   (message "Sending...")
@@ -1382,12 +1481,16 @@
                (and (boundp 'default-buffer-file-coding-system )
                     default-buffer-file-coding-system)
                'iso-latin-1))))
+    ;; Adding a Message-ID field looks good, makes it easier to search for
+    ;; message in your +outbox, and best of all doesn't break threading for
+    ;; the recipient if you reply to a message in your +outbox.
+    (setq mh-send-args (concat "-msgid " mh-send-args))
     ;; The default BCC encapsulation will make a MIME message unreadable.
     ;; With nmh use the -mime arg to prevent this.
     (if (and (mh-variant-p 'nmh)
              (mh-goto-header-field "Bcc:")
              (mh-goto-header-field "Content-Type:"))
-        (setq mh-send-args (format "-mime %s" mh-send-args)))
+        (setq mh-send-args (concat "-mime " mh-send-args)))
     (cond (arg
            (pop-to-buffer mh-mail-delivery-buffer)
            (erase-buffer)
@@ -1419,22 +1522,35 @@
 
 ;;;###mh-autoload
 (defun mh-insert-letter (folder message verbatim)
-  "Insert a message into the current letter.
-Removes the header fields according to the variable
-`mh-invisible-header-fields-compiled'.
-Prefixes each non-blank line with `mh-ins-buf-prefix', unless
-`mh-yank-from-start-of-msg' is set for supercite in which case supercite is
-used to format the message.
-Prompts for FOLDER and MESSAGE.  If prefix argument VERBATIM provided, do
-not indent and do not delete headers.  Leaves the mark before the letter
-and point after it."
+  "Insert a message.
+
+This command prompts you for the FOLDER and MESSAGE number, which
+defaults to the current message in that folder. It then inserts
+the message, indented by `mh-ins-buf-prefix' (\"> \") unless
+`mh-yank-behavior' is set to one of the supercite flavors in
+which case supercite is used to format the message. Certain
+undesirable header fields (see
+`mh-invisible-header-fields-compiled') are removed before
+insertion.
+
+If given a prefix argument VERBATIM, the header is left intact, the
+message is not indented, and \"> \" is not inserted before each line.
+This command leaves the mark before the letter and point after it."
   (interactive
-   (list (mh-prompt-for-folder "Message from" mh-sent-from-folder nil)
-         (read-string (concat "Message number"
-                              (if (numberp mh-sent-from-msg)
-                                  (format " (default %d): " mh-sent-from-msg)
-                                ": ")))
-         current-prefix-arg))
+   (let* ((folder
+           (mh-prompt-for-folder "Message from"
+                                 mh-sent-from-folder nil))
+          (default
+            (if (and (equal folder mh-sent-from-folder)
+                     (numberp mh-sent-from-msg))
+                mh-sent-from-msg
+              (nth 0 (mh-translate-range folder "cur"))))
+          (message
+           (read-string (concat "Message number"
+                                (or (and default
+                                         (format " (default %d): " default))
+                                    ": ")))))
+     (list folder message current-prefix-arg)))
   (save-restriction
     (narrow-to-region (point) (point))
     (let ((start (point-min)))
@@ -1468,13 +1584,36 @@
 ;;;###mh-autoload
 (defun mh-yank-cur-msg ()
   "Insert the current message into the draft buffer.
-Prefix each non-blank line in the message with the string in
-`mh-ins-buf-prefix'.  If a region is set in the message's buffer, then
-only the region will be inserted.  Otherwise, the entire message will
-be inserted if `mh-yank-from-start-of-msg' is non-nil.  If this variable
-is nil, the portion of the message following the point will be yanked.
-If `mh-delete-yanked-msg-window-flag' is non-nil, any window displaying the
-yanked message will be deleted."
+
+It is often useful to insert a snippet of text from a letter that
+someone mailed to provide some context for your reply. This
+command does this by adding an attribution, yanking a portion of
+text from the message to which you're replying, and inserting
+`mh-ins-buf-prefix' (`> ') before each line.
+
+The attribution consists of the sender's name and email address
+followed by the content of the option
+`mh-extract-from-attribution-verb'.
+
+You can also turn on the option
+`mh-delete-yanked-msg-window-flag' to delete the window
+containing the original message after yanking it to make more
+room on your screen for your reply.
+
+You can control how the message to which you are replying is
+yanked into your reply using `mh-yank-behavior'.
+
+If this isn't enough, you can gain full control over the
+appearance of the included text by setting `mail-citation-hook'
+to a function that modifies it. For example, if you set this hook
+to `trivial-cite' (which is NOT part of Emacs), set
+`mh-yank-behavior' to \"Body and Header\" (see URL
+`http://shasta.cs.uiuc.edu/~lrclause/tc.html').
+
+Note that if `mail-citation-hook' is set, `mh-ins-buf-prefix' is
+not inserted. If the option `mh-yank-behavior' is set to one of
+the supercite flavors, the hook `mail-citation-hook' is ignored
+and `mh-ins-buf-prefix' is not inserted."
   (interactive)
   (if (and mh-sent-from-folder
            (save-excursion (set-buffer mh-sent-from-folder) mh-show-buffer)
@@ -1491,9 +1630,9 @@
                (yank-region (mh-mark-active-p nil))
                (mh-ins-str
                 (cond ((and yank-region
-                            (or (eq 'supercite mh-yank-from-start-of-msg)
-                                (eq 'autosupercite mh-yank-from-start-of-msg)
-                                (eq t mh-yank-from-start-of-msg)))
+                            (or (eq 'supercite mh-yank-behavior)
+                                (eq 'autosupercite mh-yank-behavior)
+                                (eq t mh-yank-behavior)))
                        ;; supercite needs the full header
                        (concat
                         (buffer-substring (point-min) (mh-mail-header-end))
@@ -1501,20 +1640,18 @@
                         (buffer-substring (region-beginning) (region-end))))
                       (yank-region
                        (buffer-substring (region-beginning) (region-end)))
-                      ((or (eq 'body mh-yank-from-start-of-msg)
-                           (eq 'attribution
-                               mh-yank-from-start-of-msg)
-                           (eq 'autoattrib
-                               mh-yank-from-start-of-msg))
+                      ((or (eq 'body mh-yank-behavior)
+                           (eq 'attribution mh-yank-behavior)
+                           (eq 'autoattrib mh-yank-behavior))
                        (buffer-substring
                         (save-excursion
                           (goto-char (point-min))
                           (mh-goto-header-end 1)
                           (point))
                         (point-max)))
-                      ((or (eq 'supercite mh-yank-from-start-of-msg)
-                           (eq 'autosupercite mh-yank-from-start-of-msg)
-                           (eq t mh-yank-from-start-of-msg))
+                      ((or (eq 'supercite mh-yank-behavior)
+                           (eq 'autosupercite mh-yank-behavior)
+                           (eq t mh-yank-behavior))
                        (buffer-substring (point-min) (point-max)))
                       (t
                        (buffer-substring (point) (point-max))))))
@@ -1526,8 +1663,8 @@
             (push-mark)                 ;Needed for sc-cite-original
             (goto-char (point-min))     ;Needed for sc-cite-original
             (mh-insert-prefix-string mh-ins-buf-prefix)
-            (when (or (eq 'attribution mh-yank-from-start-of-msg)
-                      (eq 'autoattrib mh-yank-from-start-of-msg))
+            (when (or (eq 'attribution mh-yank-behavior)
+                      (eq 'autoattrib mh-yank-behavior))
               (insert from-attr)
               (mh-identity-insert-attribution-verb nil)
               (insert "\n\n"))
@@ -1570,11 +1707,11 @@
 (defun mh-insert-prefix-string (mh-ins-string)
   "Insert prefix string before each line in buffer.
 The inserted letter is cited using `sc-cite-original' if
-`mh-yank-from-start-of-msg' is one of 'supercite or 'autosupercite. Otherwise,
-simply insert MH-INS-STRING before each line."
+`mh-yank-behavior' is one of 'supercite or 'autosupercite.
+Otherwise, simply insert MH-INS-STRING before each line."
   (goto-char (point-min))
-  (cond ((or (eq mh-yank-from-start-of-msg 'supercite)
-             (eq mh-yank-from-start-of-msg 'autosupercite))
+  (cond ((or (eq mh-yank-behavior 'supercite)
+             (eq mh-yank-behavior 'autosupercite))
          (sc-cite-original))
         (mail-citation-hook
          (run-hooks 'mail-citation-hook))
@@ -1589,8 +1726,12 @@
 
 ;;;###mh-autoload
 (defun mh-fully-kill-draft ()
-  "Kill the draft message file and the draft message buffer.
-Use \\[kill-buffer] if you don't want to delete the draft message file."
+  "Quit editing and delete draft message.
+
+If for some reason you are not happy with the draft, you can use
+this command to kill the draft buffer and delete the draft
+message. Use the command \\[kill-buffer] if you don't want to
+delete the draft message."
   (interactive)
   (if (y-or-n-p "Kill draft message? ")
       (let ((config mh-previous-window-config))
@@ -1617,9 +1758,13 @@
 
 ;;;###mh-autoload
 (defun mh-open-line ()
-  "Insert a newline and leave point after it.
-In addition, insert newline and quoting characters before text after point.
-This is useful in breaking up paragraphs in replies."
+  "Insert a newline and leave point before it.
+
+This command is similar to the command \\[open-line] in that it
+inserts a newline after point. It differs in that it also inserts
+the right number of quoting characters and spaces so that the
+next line begins in the same column as it was. This is useful
+when breaking up paragraphs in replies."
   (interactive)
   (let ((column (current-column))
         (prefix (mh-current-fill-prefix)))
@@ -1636,9 +1781,9 @@
 (defmacro mh-display-completion-list-compat (word choices)
   "Completes WORD from CHOICES using `display-completion-list'.
 Calls `display-completion-list' correctly in older environments.
-Versions of Emacs prior to version 22 lacked a COMMON-SUBSTRING argument
-which is used to highlight the next possible character you can enter
-in the current list of completions."
+Versions of Emacs prior to version 22 lacked a COMMON-SUBSTRING
+argument which is used to highlight the next possible character you
+can enter in the current list of completions."
   (if (>= emacs-major-version 22)
       `(display-completion-list (all-completions ,word ,choices) ,word)
     `(display-completion-list (all-completions ,word ,choices))))
@@ -1656,7 +1801,7 @@
           ((null completion)
            (ignore-errors
              (kill-buffer completions-buffer))
-           (message "No completion for `%s'" word))
+           (message "No completion for %s" word))
           ((stringp completion)
            (if (equal word completion)
                (with-output-to-temp-buffer completions-buffer
@@ -1695,22 +1840,27 @@
     (mh-complete-word folder choices beg end)))
 
 (defvar mh-letter-complete-function-alist
-  '((cc . mh-alias-letter-expand-alias)
-    (bcc . mh-alias-letter-expand-alias)
+  '((bcc . mh-alias-letter-expand-alias)
+    (cc . mh-alias-letter-expand-alias)
     (dcc . mh-alias-letter-expand-alias)
     (fcc . mh-folder-expand-at-point)
     (from . mh-alias-letter-expand-alias)
     (mail-followup-to . mh-alias-letter-expand-alias)
+    (mail-reply-to . mh-alias-letter-expand-alias)
     (reply-to . mh-alias-letter-expand-alias)
     (to . mh-alias-letter-expand-alias))
   "Alist of header fields and completion functions to use.")
 
 (defun mh-letter-complete (arg)
   "Perform completion on header field or word preceding point.
-If the field contains addresses (for example, `To:' or `Cc:') or folders (for
-example, `Fcc:') then this function will provide alias completion. Elsewhere,
-this function runs `mh-letter-complete-function' instead and passes the prefix
-ARG, if present."
+
+If the field contains addresses (for example, \"To:\" or \"Cc:\")
+or folders (for example, \"Fcc:\") then this command will provide
+alias completion. In the body of the message, this command runs
+`mh-letter-complete-function' instead, which is set to
+`ispell-complete-word' by default. This command takes a prefix
+argument ARG that is passed to the
+`mh-letter-complete-function'."
   (interactive "P")
   (let ((func nil))
     (cond ((not (mh-in-header-p))
@@ -1722,13 +1872,11 @@
 
 (defun mh-letter-complete-or-space (arg)
   "Perform completion or insert space.
-If `mh-compose-space-does-completion-flag' is nil (the default) a space is
-inserted.
 
-Otherwise, if point is in the message header and the preceding character is
-not whitespace then do completion. Otherwise insert a space character.
-
-ARG is the number of spaces inserted."
+Turn on the option `mh-compose-space-does-completion-flag' to use
+this command to perform completion in the header. Otherwise, a
+space is inserted; use a prefix argument ARG to specify more than
+one space."
   (interactive "p")
   (let ((func nil)
         (end-of-prev (save-excursion
@@ -1744,7 +1892,11 @@
           (t (self-insert-command arg)))))
 
 (defun mh-letter-confirm-address ()
-  "Flash alias expansion if `mh-alias-flash-on-comma' is non-nil."
+  "Flash alias expansion.
+
+Addresses are separated by a comma\; when you press the comma,
+this command flashes the alias expansion in the minibuffer if
+`mh-alias-flash-on-comma' is turned on."
   (interactive)
   (cond ((not (mh-in-header-p)) (self-insert-command 1))
         ((eq (cdr (assoc (mh-letter-header-field-at-point)
@@ -1758,8 +1910,8 @@
 
 (defun mh-letter-header-field-at-point ()
   "Return the header field name at point.
-A symbol is returned whose name is the string obtained by downcasing the field
-name."
+A symbol is returned whose name is the string obtained by
+downcasing the field name."
   (save-excursion
     (end-of-line)
     (and (re-search-backward mh-letter-header-field-regexp nil t)
@@ -1767,9 +1919,16 @@
 
 ;;;###mh-autoload
 (defun mh-letter-next-header-field-or-indent (arg)
-  "Move to next field or indent depending on point.
-In the message header, go to the next field. Elsewhere call
-`indent-relative' as usual with optional prefix ARG."
+  "Cycle to next field.
+
+Within the header of the message, this command moves between
+fields that are highlighted with the face
+`mh-letter-header-field', skipping those fields listed in
+`mh-compose-skipped-header-fields'. After the last field, this
+command then moves point to the message body before cycling back
+to the first field. If point is already past the first line of
+the message body, then this command indents by calling
+`indent-relative' with the given prefix argument ARG."
   (interactive "P")
   (let ((header-end (save-excursion
                       (goto-char (mh-mail-header-end))
@@ -1781,7 +1940,8 @@
 
 (defun mh-letter-next-header-field ()
   "Cycle to the next header field.
-If we are at the last header field go to the start of the message body."
+If we are at the last header field go to the start of the message
+body."
   (let ((header-end (mh-mail-header-end)))
     (cond ((>= (point) header-end) (goto-char (point-min)))
           ((< (point) (progn
@@ -1801,7 +1961,11 @@
 ;;;###mh-autoload
 (defun mh-letter-previous-header-field ()
   "Cycle to the previous header field.
-If we are at the first header field go to the start of the message body."
+
+This command moves backwards between the fields and cycles to the
+body of the message after the first field. Unlike the command
+\\[mh-letter-next-header-field-or-indent], it will always take
+point to the last field from anywhere in the body."
   (interactive)
   (let ((header-end (mh-mail-header-end)))
     (if (>= (point) header-end)
@@ -1824,8 +1988,8 @@
 
 (defun mh-letter-skip-leading-whitespace-in-header-field ()
   "Skip leading whitespace in a header field.
-If the header field doesn't have at least one space after the colon then a
-space character is added."
+If the header field doesn't have at least one space after the
+colon then a space character is added."
   (let ((need-space t))
     (while (memq (char-after) '(?\t ?\ ))
       (forward-char)
@@ -1843,19 +2007,20 @@
 
 (defun mh-letter-toggle-header-field-display-button (event)
   "Toggle header field display at location of EVENT.
-This function does the same thing as `mh-letter-toggle-header-field-display'
-except that it is callable from a mouse button."
+This function does the same thing as
+`mh-letter-toggle-header-field-display' except that it is
+callable from a mouse button."
   (interactive "e")
   (mh-do-at-event-location event
     (mh-letter-toggle-header-field-display nil)))
 
 (defun mh-letter-toggle-header-field-display (arg)
   "Toggle display of header field at point.
-If the header is long or spread over multiple lines then hiding it will show
-the first few characters and replace the rest with an ellipsis.
 
-If ARG is negative then header is hidden, if positive it is displayed. If ARG
-is the symbol `long' then keep at most the first 4 lines."
+Use this command to display truncated header fields. This command
+is a toggle so entering it again will hide the field. This
+command takes a prefix argument ARG: if negative then the field
+is hidden, if positive then the field is displayed."
   (interactive (list nil))
   (when (and (mh-in-header-p)
              (progn
@@ -1881,6 +2046,8 @@
                  (remove-text-properties begin end '(invisible nil))
                  (search-forward ":" (line-end-position) t)
                  (mh-letter-skip-leading-whitespace-in-header-field))
+                ;; XXX Redesign to make usable by user. Perhaps use a positive
+                ;; numeric prefix to make that many lines visible.
                 ((eq arg 'long)
                  (end-of-line 4)
                  (mh-letter-truncate-header-field end)
@@ -1913,13 +2080,15 @@
 
 (defun mh-interactive-read-address (prompt)
   "Read an address.
-If `mh-compose-prompt-flag' is non-nil, then read an address with PROMPT.
+If `mh-compose-prompt-flag' is non-nil, then read an address with
+PROMPT.
 Otherwise return the empty string."
   (if mh-compose-prompt-flag (mh-read-address prompt) ""))
 
 (defun mh-interactive-read-string (prompt)
   "Read a string.
-If `mh-compose-prompt-flag' is non-nil, then read a string with PROMPT.
+If `mh-compose-prompt-flag' is non-nil, then read a string with
+PROMPT.
 Otherwise return the empty string."
   (if mh-compose-prompt-flag (read-string prompt) ""))
 
@@ -1929,8 +2098,11 @@
     (goto-char (point-max))
     (mh-letter-next-header-field)))
 
-;;; Build the letter-mode keymap:
-;;; If this changes, modify mh-letter-mode-help-messages accordingly, above.
+
+
+;;; Build mh-letter-mode keymap
+
+;; If this changes, modify mh-letter-mode-help-messages accordingly, above.
 (gnus-define-keys  mh-letter-mode-map
   " "                   mh-letter-complete-or-space
   ","                   mh-letter-confirm-address
@@ -1939,44 +2111,50 @@
   "\C-c\C-^"            mh-insert-signature ;if no C-s
   "\C-c\C-c"            mh-send-letter
   "\C-c\C-d"            mh-insert-identity
-  "\C-c\C-e"            mh-edit-mhn
+  "\C-c\C-e"            mh-mh-to-mime
+  "\C-c\C-f\C-a"        mh-to-field
   "\C-c\C-f\C-b"        mh-to-field
   "\C-c\C-f\C-c"        mh-to-field
   "\C-c\C-f\C-d"        mh-to-field
   "\C-c\C-f\C-f"        mh-to-fcc
+  "\C-c\C-f\C-l"        mh-to-field
+  "\C-c\C-f\C-m"        mh-to-field
   "\C-c\C-f\C-r"        mh-to-field
   "\C-c\C-f\C-s"        mh-to-field
   "\C-c\C-f\C-t"        mh-to-field
+  "\C-c\C-fa"           mh-to-field
   "\C-c\C-fb"           mh-to-field
   "\C-c\C-fc"           mh-to-field
   "\C-c\C-fd"           mh-to-field
   "\C-c\C-ff"           mh-to-fcc
+  "\C-c\C-fl"           mh-to-field
+  "\C-c\C-fm"           mh-to-field
   "\C-c\C-fr"           mh-to-field
   "\C-c\C-fs"           mh-to-field
   "\C-c\C-ft"           mh-to-field
   "\C-c\C-i"            mh-insert-letter
   "\C-c\C-m\C-e"        mh-mml-secure-message-encrypt
   "\C-c\C-m\C-f"        mh-compose-forward
-  "\C-c\C-m\C-g"        mh-mhn-compose-anon-ftp
+  "\C-c\C-m\C-g"        mh-mh-compose-anon-ftp
   "\C-c\C-m\C-i"        mh-compose-insertion
   "\C-c\C-m\C-m"        mh-mml-to-mime
   "\C-c\C-m\C-n"        mh-mml-unsecure-message
   "\C-c\C-m\C-s"        mh-mml-secure-message-sign
-  "\C-c\C-m\C-t"        mh-mhn-compose-external-compressed-tar
-  "\C-c\C-m\C-u"        mh-revert-mhn-edit
-  "\C-c\C-m\C-x"        mh-mhn-compose-external-type
+  "\C-c\C-m\C-t"        mh-mh-compose-external-compressed-tar
+  "\C-c\C-m\C-u"        mh-mh-to-mime-undo
+  "\C-c\C-m\C-x"        mh-mh-compose-external-type
   "\C-c\C-mee"          mh-mml-secure-message-encrypt
   "\C-c\C-mes"          mh-mml-secure-message-signencrypt
   "\C-c\C-mf"           mh-compose-forward
-  "\C-c\C-mg"           mh-mhn-compose-anon-ftp
+  "\C-c\C-mg"           mh-mh-compose-anon-ftp
   "\C-c\C-mi"           mh-compose-insertion
   "\C-c\C-mm"           mh-mml-to-mime
   "\C-c\C-mn"           mh-mml-unsecure-message
   "\C-c\C-mse"          mh-mml-secure-message-signencrypt
   "\C-c\C-mss"          mh-mml-secure-message-sign
-  "\C-c\C-mt"           mh-mhn-compose-external-compressed-tar
-  "\C-c\C-mu"           mh-revert-mhn-edit
-  "\C-c\C-mx"           mh-mhn-compose-external-type
+  "\C-c\C-mt"           mh-mh-compose-external-compressed-tar
+  "\C-c\C-mu"           mh-mh-to-mime-undo
+  "\C-c\C-mx"           mh-mh-compose-external-type
   "\C-c\C-o"            mh-open-line
   "\C-c\C-q"            mh-fully-kill-draft
   "\C-c\C-s"            mh-insert-signature
@@ -1992,10 +2170,10 @@
 
 (provide 'mh-comp)
 
-;;; Local Variables:
-;;; indent-tabs-mode: nil
-;;; sentence-end-double-space: nil
-;;; End:
+;; Local Variables:
+;; indent-tabs-mode: nil
+;; sentence-end-double-space: nil
+;; End:
 
-;;; arch-tag: 62865511-e610-4923-b0b5-f45a8ab70a34
+;; arch-tag: 62865511-e610-4923-b0b5-f45a8ab70a34
 ;;; mh-comp.el ends here