;;; mh-comp --- mh-e functions for composing messages
-;; Time-stamp: <95/04/20 19:16:23 gildea>
+;; Time-stamp: <95/08/19 17:48:59 gildea>
-;; Copyright (C) 1993, 1995 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1995, 1997 Free Software Foundation, Inc.
-;; This file is part of GNU Emacs.
+;; This file is part of mh-e, part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to
-;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; along with GNU Emacs; see the file COPYING. If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
;;; Commentary:
;;; Change Log:
-;; $Id: mh-comp.el,v 1.5 1995/04/20 23:35:49 kwzh Exp kwzh $
+;; $Id: mh-comp.el,v 1.11 1997/09/15 19:45:16 rms Exp rms $
;;; Code:
;;; Site customization (see also mh-utils.el):
+(defgroup mh-compose nil
+ "Mh-e functions for composing messages"
+ :prefix "mh-"
+ :group 'mh)
+
+
(defvar mh-send-prog "send"
"Name of the MH send program.
Some sites need to change this because of a name conflict.")
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.")
+It is semi-obsolete and is only used if `mail-citation-hook' is nil.")
(defvar mail-citation-hook nil
"*Hook for modifying a citation just inserted in the mail buffer.
text as modified.
If this hook is entirely empty (nil), the text of the message is inserted
-with mh-ins-buf-prefix prefixed to each line.
+with `mh-ins-buf-prefix' prefixed to each line.
-See also the variable mh-yank-from-start-of-msg, which controls how
+See also the variable `mh-yank-from-start-of-msg', which controls how
much of the message passed to the hook.")
;;; Copied from sendmail.el for Hyperbole
;;; Personal preferences:
-(defvar mh-delete-yanked-msg-window nil
+(defcustom mh-delete-yanked-msg-window nil
"*Controls window display when a message is yanked by \\<mh-letter-mode-map>\\[mh-yank-cur-msg].
If non-nil, yanking the current message into a draft letter deletes any
-windows displaying the message.")
+windows displaying the message."
+ :type 'boolean
+ :group 'mh-compose)
-(defvar mh-yank-from-start-of-msg t
+(defcustom mh-yank-from-start-of-msg t
"*Controls which part of a message is yanked by \\<mh-letter-mode-map>\\[mh-yank-cur-msg].
If non-nil, include the entire message. If the symbol `body', then yank the
message minus the header. If nil, yank only the portion of the message
following the point. If the show buffer has a region, this variable is
-ignored.")
+ignored."
+ :type '(choice (const t) (const nil) (const body))
+ :group 'mh-compose)
-(defvar mh-ins-buf-prefix "> "
+(defcustom mh-ins-buf-prefix "> "
"*String to put before each non-blank line of a yanked or inserted message.
\\<mh-letter-mode-map>Used when the message is inserted into an outgoing letter
-by \\[mh-insert-letter] or \\[mh-yank-cur-msg].")
+by \\[mh-insert-letter] or \\[mh-yank-cur-msg]."
+ :type 'string
+ :group 'mh-compose)
-(defvar mh-reply-default-reply-to nil
+(defcustom mh-reply-default-reply-to nil
"*Sets the person or persons to whom a reply will be sent.
If nil, prompt for recipient. If non-nil, then \\<mh-folder-mode-map>`\\[mh-reply]' will use this
value and it should be one of \"from\", \"to\", \"cc\", or \"all\".
-The values \"cc\" and \"all\" do the same thing.")
+The values \"cc\" and \"all\" do the same thing."
+ :type '(choice (const :tag "Prompt" nil)
+ (const "from") (const "to")
+ (const "cc") (const "all"))
+ :group 'mh-compose)
-(defvar mh-signature-file-name "~/.signature"
+(defcustom mh-signature-file-name "~/.signature"
"*Name of file containing the user's signature.
-Inserted into message by \\<mh-letter-mode-map>\\[mh-insert-signature].")
+Inserted into message by \\<mh-letter-mode-map>\\[mh-insert-signature]."
+ :type 'file
+ :group 'mh-compose)
-(defvar mh-forward-subject-format "%s: %s"
+(defcustom mh-forward-subject-format "%s: %s"
"*Format to generate the Subject: line contents for a forwarded message.
The two string arguments to the format are the sender of the original
-message and the original subject line.")
+message and the original subject line."
+ :type 'string
+ :group 'mh-compose)
(defvar mh-comp-formfile "components"
"Name of file to be used as a skeleton for composing messages.
-Default is \"components\". If not a complete path name, the file
+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 a complete path name, the file
+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.")
;;; Hooks:
-(defvar mh-letter-mode-hook nil
- "Invoked in `mh-letter-mode' on a new letter.")
+(defcustom mh-letter-mode-hook nil
+ "Invoked in `mh-letter-mode' on a new letter."
+ :type 'hook
+ :group 'mh-compose)
-(defvar mh-compose-letter-function nil
+(defcustom mh-compose-letter-function nil
"Invoked when setting up a letter draft.
-It is passed three arguments: TO recipients, SUBJECT, and CC recipients.")
+It is passed three arguments: TO recipients, SUBJECT, and CC recipients."
+ :type 'function
+ :group 'mh-compose)
-(defvar mh-before-send-letter-hook nil
- "Invoked at the beginning of the \\<mh-letter-mode-map>\\[mh-send-letter] command.")
+(defcustom mh-before-send-letter-hook nil
+ "Invoked at the beginning of the \\<mh-letter-mode-map>\\[mh-send-letter] command."
+ :type 'hook
+ :group 'mh-compose)
(defvar mh-rejected-letter-start
(call-interactively 'mh-send))
+(defvar mh-error-if-no-draft nil) ;raise error over using old draft
+
+
+;;;###autoload
+(defun mh-smail-batch (&rest ignored)
+ "Set up a mail composition draft with the MH mail system.
+This function is an entry point to mh-e, the Emacs front end
+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."
+ (mh-find-path)
+ (let ((mh-error-if-no-draft t))
+ (mh-send "" "" "")))
+
+
(defun mh-edit-again (msg)
"Clean-up a draft or a message previously sent and make it resendable.
Default is the current message.
(mh-read-draft "clean-up" (mh-msg-filename msg) nil)))))
(mh-clean-msg-header (point-min) mh-new-draft-cleaned-headers nil)
(goto-char (point-min))
- (set-buffer-modified-p nil)
+ (save-buffer)
(mh-compose-and-send-mail draft "" from-folder nil nil nil nil nil nil
config)))
(defun mh-extract-rejected-mail (msg)
"Extract a letter returned by the mail system and make it resendable.
-Default is the current message. The variable mh-new-draft-cleaned-headers
+Default is the current message. The variable `mh-new-draft-cleaned-headers'
gives the headers to clean out of the original message.
See also documentation for `\\[mh-send]' function."
(interactive (list (mh-get-msg-num t)))
(t
(message "Does not appear to be a rejected letter.")))
(goto-char (point-min))
- (set-buffer-modified-p nil)
+ (save-buffer)
(mh-compose-and-send-mail draft "" from-folder msg
(mh-get-header-field "To:")
(mh-get-header-field "From:")
(prog1
(mh-read-draft "" draft-name t)
(mh-insert-fields "To:" to "Cc:" cc)
- (set-buffer-modified-p nil)))
+ (save-buffer)))
(t
(mh-read-draft "" draft-name nil)))))
(let (orig-from
(defun mh-redistribute (to cc &optional msg)
"Redistribute a letter.
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."
+setting of the variable `mh-redist-full-contents'. See its documentation."
(interactive (list (mh-read-address "Redist-To: ")
(mh-read-address "Redist-Cc: ")
(mh-get-msg-num t)))
(defun mh-reply (message &optional includep)
"Reply to MESSAGE (default: current message).
If optional prefix argument INCLUDEP provided, then include the message
-in the reply using filter mhl.reply in your MH directory.
+in the reply using filter `mhl.reply' in your MH directory.
Prompts for type of addresses to reply to:
from sender only,
to sender and primary recipients,
(expand-file-name "reply" mh-user-path)
t)))
(delete-other-windows)
- (set-buffer-modified-p nil)
+ (save-buffer)
(let ((to (mh-get-header-field "To:"))
(subject (mh-get-header-field "Subject:"))
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, subject, and cc."
+draft and passed three arguments: TO, SUBJECT, and CC."
(interactive (list
(mh-read-address "To: ")
(mh-read-address "Cc: ")
(delete-file draft-name))))))
(cond ((and initial-contents
(or (zerop (buffer-size))
- (not (y-or-n-p
- (format "A draft exists. Use for %s? " use)))))
+ (if (y-or-n-p
+ (format "A draft exists. Use for %s? " use))
+ (if mh-error-if-no-draft
+ (error "A prior draft exists."))
+ t)))
(erase-buffer)
(insert-file-contents initial-contents)
(if delete-contents-file (delete-file initial-contents))))
mh-signature-file-name (\"~/.signature\")
File to be inserted into message by \\[mh-insert-signature].
-Upon invoking mh-letter-mode, text-mode-hook and mh-letter-mode-hook are
-invoked with no args, if those values are non-nil."
+This command runs the normal hooks `text-mode-hook' and `mh-letter-mode-hook'."
(interactive)
(or mh-user-path (mh-find-path))
(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.
+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)
(defun mh-insert-signature ()
- "Insert the file named by mh-signature-file-name at the current point."
+ "Insert the file named by `mh-signature-file-name' at point."
(interactive)
(insert-file-contents mh-signature-file-name)
(force-mode-line-update))
(defun mh-send-letter (&optional arg)
"Send the draft letter in the current buffer.
If optional prefix argument is provided, monitor delivery.
-Run mh-before-send-letter-hook before doing anything."
+Run `mh-before-send-letter-hook' before actually doing anything."
(interactive "P")
(run-hooks 'mh-before-send-letter-hook)
- (set-buffer-modified-p t) ; Make sure buffer is written
(save-buffer)
(message "Sending...")
(let ((draft-buffer (current-buffer))
(file-name buffer-file-name)
- (config mh-previous-window-config))
+ (config mh-previous-window-config)
+ (coding-system-for-write
+ (if (and (local-variable-p 'buffer-file-coding-system)
+ ;; We're not sure why, but buffer-file-coding-system
+ ;; tends to get set to undecided-unix.
+ (not (memq buffer-file-coding-system
+ '(undecided undecided-unix undecided-dos))))
+ buffer-file-coding-system
+ (or sendmail-coding-system
+ default-buffer-file-coding-system
+ 'iso-latin-1))))
(cond (arg
(pop-to-buffer "MH mail delivery")
(erase-buffer)
(defun mh-insert-letter (folder message verbatim)
"Insert a message into the current letter.
-Removes the message's headers using mh-invisible-headers. Prefixes
-each non-blank line with mh-ins-buf-prefix. Prompts for FOLDER and
+Removes the message's headers using `mh-invisible-headers'. Prefixes
+each non-blank line with `mh-ins-buf-prefix'. 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."
(interactive
(define-key mh-letter-mode-map "\C-c\C-e" 'mh-edit-mhn)
(define-key mh-letter-mode-map "\C-c\C-m\C-u" 'mh-revert-mhn-edit)
+;; "C-c /" prefix is used in mh-letter-mode by pgp.el
;;; autoloads from mh-mime
all the MIME components and header fields.
This step should be done last just before sending the message.
The mhn program is part of MH version 6.8 or later.
-The `\\[mh-revert-mhn-edit]' command undoes this command.
+The \\[mh-revert-mhn-edit] command undoes this command.
For assistance with creating mhn directives to insert
various types of components in a message, see
\\[mh-mhn-compose-insertion] (generic insertion from a file),