Editing a Draft

[previous] [next] [table of contents] [index]

Note: HTML conversion may not be complete.

There are several variables used during the draft editing phase. Examples include changing the name of the file that holds your signature or telling mh-e about new multimedia types. They are:

Variable            |           Default          |      Description
____________________|____________________________|______________________
mh-yank-from-start- |              t             |  How to yank when re-
of-msg              |                            |  gion not set
mh-ins-buf-prefix   |             "> "           |  Indent  for   yanked
                    |                            |  messages
mail-citation-hook  |             nil            |  Functions to run  on
                    |                            |  yanked messages
mh-delete-yanked-   |             nil            |  Delete message  win-
msg-window          |                            |  dow on yank
mh-mime-content-    |  (("text/plain")           |  List of  valid  con-
types               |  ("text/richtext")         |  tent types
                    |  ("multipart/mixed")       |
                    |  ("multipart/alternative") |
                    |  ("multipart/digest")      |
                    |  ("multipart/parallel")    |
                    |  ("message/rfc822")        |
                    |  ("message/partial")       |
                    |  ("message/external-       |
                    |  body")                    |
                    |  ("application/octet-      |
                    |  stream")                  |
                    |  ("application/postscript")|
                    |  ("image/jpeg")            |
                    |  ("image/gif")             |
                    |  ("audio/basic")           |
                    |  ("video/mpeg"))           |
mh-mhn-args         |             nil            |  Additional arguments
                    |                            |  for mhn
mh-signature-file-  |        "~/.signature"      |  File containing sig-
name                |                            |  nature
mh-before-send-     |             nil            |  Functions to run be-
letter-hook         |                            |  fore sending draft
mh-send-prog        |            "send"          |  MH program  used  to
                    |                            |  send messages

Editing Textual Messages

The following two sections include variables that customize the way you edit a draft. The discussion here applies to editing multimedia messages as well.

Inserting letter to which you're replying

To control how much of the message to which you are replying is yanked by C-c C-y (mh-yank-cur-msg) into your reply, modify mh-yank-from-start-of-msg. The default value of t means that the entire message is copied. If it is set to 'body (don't forget the apostrophe), then only the message body is copied. If it is set to nil , only the part of the message following point (the current cursor position in the message's buffer) is copied. In any case, this variable is ignored if a region is set in the message you are replying to. The string contained in mh-ins-buf-prefix is inserted before each line of a message that is inserted into a draft with C-c C-y (mh-yank-cur-msg). I suggest that you not modify this variable. The default value of " " is the default string for many mailers and news readers: messages are far easier to read if several included messages have all been indented by the same string. The variable mail-citation-hook is nil by default, which means that when a message is inserted into the letter, each line is prefixed by mh-ins-buf-prefix. Otherwise, it can be set to a function that modifies an included citation. (Supercite is an example of a full-bodied, full-featured citation package. It is in Emacs version 19.15 and in later versions, and it can be copied via anonymous FTP from archive.cis.ohio-state.edu:/pub/gnu/emacs/elisp-archive/packages/sc3.1.tar.Z)

If you like to yank all the text from the message you're replying to in one go, set mh-delete-yanked-msg-window to non-nil to delete the window containing the original message after yanking it to make more room on your screen for your reply.

Inserting your signature

You can change the name of the file inserted with C-c C-s (mh-insert-signature) by changing mh-signature-file-name (default: "~/.signature").

Editing Multimedia Messages

The variable mh-mime-content-types contains a list of the currently valid content types. They are listed in the table in Section Editing a Draft. If you encounter a new content type, you can add it like this:
(setq mh-mime-content-types (append mh-mime-content-types '(("new/type"))))

Example vi Macros for entering enriched text showed how vi macros could be used to insert enriched text directives like <bold>. Now I'll show you how to do this in Emacs. The following code will make, for example, C-c C-t b insert the <bold> directive.

Example: Emacs macros for entering enriched text

;; See Example Prepare draft for editing via mh-letter-mode-hook for keybindings.

(defvar enriched-text-types '((?b . "bold") (?i . "italic") (?f . "fixed")
                              (?s . "smaller") (?B . "bigger")
                              (?u . "underline") (?c . "center"))
  "Alist of (final-character . directive) choices for add-enriched-text.
Additional types can be found in RFC 1563.")

(defun add-enriched-text (begin end)
  "Add enriched text directives around region. The directive used
comes from the list enriched-text-types and is specified by the last
keystroke of the command.  When called from Lisp, arguments are BEGIN
and END."
  (interactive "r")
  ;; Set type to the directive indicated by the last keystroke.
  (let ((type (cdr (assoc (logior last-input-char ?`) enriched-text-types))))
    (save-restriction                        ; restores state from narrow-to-region
      (narrow-to-region begin end)           ; narrow view to region
      (goto-char (point-min))                ; move to beginning of text
      (insert "<" type ">")                  ; insert beginning directive
      (goto-char (point-max))                ; move to end of text
      (insert "</" type ">"))))              ; insert terminating directive
To use the function in the Example Emacs macros for entering enriched text, set the mark with C-@ or C-SPC, type in the text to be highlighted, and type C-c C-t b. This adds <bold> where you set the mark and adds </bold> at the location of your cursor, giving you something like: You should be <bold>very</bold>. You may also be interested in investigating sgml-mode.

Readying multimedia messages for sending

If you wish to pass additional arguments to mhn to affect how it builds your message, use the variable mh-mhn-args. For example, you can build a consistency check into the message by setting mh-mhn-args to -check. The recipient of your message can then run mhn -check on the message -- mhn will complain if the message has been corrupted on the way. The C-c C-e (mh-mhn-edit) command only consults this variable when given a prefix argument.

Sending a Message

If you want to check your spelling in your message before sending, use mh-before-send-letter-hook like this:

Example: Spell-check message via mh-before-send-letter-hook

(add-hook 'mh-before-send-letter-hook 'ispell-message)
In case the MH send(1) program is installed under a different name, use mh-send-prog to tell mh-e the name.

[Table of Contents] [Index] [Previous: Sending Mail] [Next: Moving Your Mail Around]


(This section was written by Bill Wohler.)
Last change $Date: 1996/07/14 17:35:00 $

This file is from the third edition of the book MH & xmh: Email for Users & Programmers, ISBN 1-56592-093-7, by Jerry Peek. Copyright 1991, 1992, 1995 by O'Reilly & Associates, Inc. This file is freely-available; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. For more information, see the file copying.htm.

Suggestions are welcome: Bill Wohler <wohler@newt.com>

Questions or problems regarding this web site should be directed to Steve Gielda.
Copyright 1999 www.cotse.com.  All rights reserved.
Last modified: Friday April 02, 1999.