]> code.delx.au - gnu-emacs/blobdiff - lisp/mail/mh-comp.el
(report-emacs-bug-text-prompt): New variable.
[gnu-emacs] / lisp / mail / mh-comp.el
index ceb38043e11dfc88da00e777073de9adee874808..bc6556cc31b8d1b5a820307cfa9a6800e745d34a 100644 (file)
@@ -1,9 +1,13 @@
-;;; mh-comp --- mh-e functions for composing messages
-;; Time-stamp: <95/08/19 17:48:59 gildea>
+;;; mh-comp.el --- mh-e functions for composing messages
+;; Time-stamp: <2001-12-20 18:55:07 pavel>
 
-;; Copyright (C) 1993, 1995, 1997 Free Software Foundation, Inc.
+;; Copyright (C) 1993,1995,1997,2000  Free Software Foundation, Inc.
 
-;; This file is part of mh-e, part of GNU Emacs.
+;; Maintainer: Bill Wohler <wohler@newt.com>
+;; Keywords: mail
+;; Bug-reports: include `M-x mh-version' output in any correspondence
+
+;; This file is 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
@@ -26,7 +30,7 @@
 
 ;;; Change Log:
 
-;; $Id: mh-comp.el,v 1.14 1999/03/01 03:47:07 kwzh Exp rms $
+;; $Id: mh-comp.el,v 1.22 2001/07/15 19:53:53 pj Exp $
 
 ;;; Code:
 
@@ -164,7 +168,7 @@ MH lib directory.")
 (defcustom mh-compose-letter-function nil
   "Invoked when setting up a letter draft.
 It is passed three arguments: TO recipients, SUBJECT, and CC recipients."
-  :type 'function
+  :type '(choice (const nil) function)
   :group 'mh-compose)
 
 (defcustom mh-before-send-letter-hook nil
@@ -233,7 +237,7 @@ 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 to "" subject)))
+    (mh-send (or to "") "" (or subject ""))))
 
 
 (defun mh-edit-again (msg)
@@ -515,6 +519,12 @@ See also documentation for `\\[mh-send]' function."
                       (setq components
                             (expand-file-name mh-comp-formfile mh-lib)))
                      components)
+                    ((file-exists-p
+                      (setq components
+                            (expand-file-name mh-comp-formfile
+                                              ;; What is this mh-etc ??  -sm
+                                              (and (boundp 'mh-etc) mh-etc))))
+                     components)
                     (t
                      (error (format "Can't find components file \"%s\""
                                     components)))))
@@ -530,7 +540,7 @@ See also documentation for `\\[mh-send]' function."
 (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.
-  ;; INITIAL-CONTENTS is filename that is read into an empty buffer, or NIL
+  ;; 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
   ;; DELETE-CONTENTS-FILE flag is set.
   ;; Returns the draft folder's name.
@@ -566,7 +576,7 @@ See also documentation for `\\[mh-send]' function."
                  (if (y-or-n-p
                        (format "A draft exists.  Use for %s? " use))
                      (if mh-error-if-no-draft
-                         (error "A prior draft exists."))
+                         (error "A prior draft exists"))
                    t)))
         (erase-buffer)
         (insert-file-contents initial-contents)
@@ -641,7 +651,7 @@ See also documentation for `\\[mh-send]' function."
 (defun mh-goto-header-field (field)
   ;; Move to FIELD in the message header.
   ;; Move to the end of the FIELD name, which should end in a colon.
-  ;; Returns T if found, NIL if not.
+  ;; Returns t if found, nil if not.
   (goto-char (point-min))
   (let ((case-fold-search t)
        (headers-end (save-excursion
@@ -687,7 +697,7 @@ See also documentation for `\\[mh-send]' function."
 (put 'mh-letter-mode 'mode-class 'special)
 
 ;;;###autoload
-(defun mh-letter-mode ()
+(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.
@@ -716,8 +726,6 @@ Variables controlling this mode (defaults in parentheses):
     File to be inserted into message by \\[mh-insert-signature].
 
 This command runs the normal hooks `text-mode-hook' and `mh-letter-mode-hook'."
-
-  (interactive)
   (or mh-user-path (mh-find-path))
   (make-local-variable 'paragraph-start)
   (setq paragraph-start (concat "^[ \t]*[-_][-_][-_]+$\\|" paragraph-start))
@@ -732,19 +740,10 @@ This command runs the normal hooks `text-mode-hook' and `mh-letter-mode-hook'."
   (make-local-variable 'mh-sent-from-msg)
   (make-local-variable 'mail-header-separator)
   (setq mail-header-separator "--------") ;for Hyperbole
-  (use-local-map mh-letter-mode-map)
-  (setq major-mode 'mh-letter-mode)
-  (mh-set-mode-name "MH-Letter")
-  (set-syntax-table mh-letter-mode-syntax-table)
-  (run-hooks 'text-mode-hook)
   ;; if text-mode-hook turned on auto-fill, tune it for messages
-  (cond ((and (boundp 'auto-fill-hook) auto-fill-hook) ;emacs 18
-        (make-local-variable 'auto-fill-hook)
-        (setq auto-fill-hook 'mh-auto-fill-for-letter)))
-  (cond ((and (boundp 'auto-fill-function) auto-fill-function) ;emacs 19
-        (make-local-variable 'auto-fill-function)
-        (setq auto-fill-function 'mh-auto-fill-for-letter)))
-  (run-hooks 'mh-letter-mode-hook))
+  (when auto-fill-function
+    (make-local-variable 'auto-fill-function)
+    (setq auto-fill-function 'mh-auto-fill-for-letter)))
 
 
 (defun mh-auto-fill-for-letter ()
@@ -1007,10 +1006,9 @@ yanked message will be deleted."
         (run-hooks 'mh-yank-hooks))
        (t
         (or (bolp) (forward-line 1))
-        (let ((zmacs-regions nil))     ;so "(mark)" works in XEmacs
-          (while (< (point) (mark))
-            (insert mh-ins-string)
-            (forward-line 1))))))
+        (while (< (point) (mark))
+          (insert mh-ins-string)
+          (forward-line 1)))))
 
 
 (defun mh-fully-kill-draft ()
@@ -1105,3 +1103,5 @@ various types of components in a message, see
 (autoload 'mh-revert-mhn-edit "mh-mime"
   "Undoes the effect of \\[mh-edit-mhn] by reverting to the backup file.
 Optional non-nil argument means don't ask for confirmation." t)
+
+;;; mh-comp.el ends here