]> code.delx.au - gnu-emacs/blobdiff - lisp/mh-e/mh-comp.el
Merge from emacs--devo--0
[gnu-emacs] / lisp / mh-e / mh-comp.el
index d9ce48a959b739c2f0e333b807a7d040d98c5ebf..7156b0cf31853ff463f47fb42009682e09af2a88 100644 (file)
 
 (autoload 'easy-menu-add "easymenu")
 (autoload 'mml-insert-tag "mml")
-(autoload 'sc-cite-original "sc"
-  "Workhorse citing function which performs the initial citation.
-This is callable from the various mail and news readers' reply
-function according to the agreed upon standard.  See `sc-describe'
-for more details.  `sc-cite-original' does not do any yanking of the
-original message but it does require a few things:
-
-     1) The reply buffer is the current buffer.
-
-     2) The original message has been yanked and inserted into the
-        reply buffer.
-
-     3) Verbose mail headers from the original message have been
-        inserted into the reply buffer directly before the text of the
-        original message.
-
-     4) Point is at the beginning of the verbose headers.
-
-     5) Mark is at the end of the body of text to be cited.
-
-For Emacs 19's, the region need not be active (and typically isn't
-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.")
 
 \f
 
@@ -76,6 +53,15 @@ before, and `sc-post-hook' is run after the guts of this function.")
   "Name of the MH send program.
 Some sites need to change this because of a name conflict.")
 
+(defvar mh-send-uses-spost-flag nil
+  "Non-nil means \"send\" uses \"spost\" to submit messages.
+
+If the value of \"postproc:\" is \"spost\", you may need to set
+this variable to t to tell MH-E to avoid using features of
+\"post\" that are not supported by \"spost\". You'll know that
+you'll need to do this if sending mail fails with an error of
+\"spost: -msgid unknown\".")
+
 (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
@@ -238,7 +224,7 @@ ignored."
       (setq other-headers (cdr other-headers)))))
 
 ;; Shush compiler.
-(eval-when-compile (mh-do-in-xemacs (defvar sendmail-coding-system)))
+(defvar sendmail-coding-system)         ; XEmacs
 
 ;;;###autoload
 (defun mh-send-letter (&optional arg)
@@ -253,6 +239,13 @@ 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'.
 
+Unless `mh-insert-auto-fields' had previously been called
+manually, the function `mh-insert-auto-fields' is called to
+insert fields based upon the recipients. If fields are added, you
+are given a chance to see and to confirm these fields before the
+message is actually sent. You can do away with this confirmation
+by turning off the option `mh-auto-fields-prompt-flag'.
+
 In case the MH \"send\" program is installed under a different name,
 use `mh-send-prog' to tell MH-E the name."
   (interactive "P")
@@ -283,16 +276,18 @@ use `mh-send-prog' to tell MH-E the name."
                (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 (concat "-mime " mh-send-args)))
+    ;; Older versions of spost do not support -msgid and -mime.
+    (unless mh-send-uses-spost-flag
+      ;; 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 (concat "-mime " mh-send-args))))
     (cond (arg
            (pop-to-buffer mh-mail-delivery-buffer)
            (erase-buffer)
@@ -303,7 +298,7 @@ use `mh-send-prog' to tell MH-E the name."
            (set-buffer draft-buffer))   ; for annotation below
           (t
            (mh-exec-cmd-daemon mh-send-prog nil "-nodraftfolder" "-noverbose"
-                               mh-send-args file-name)))
+                               (split-string mh-send-args) file-name)))
     (if mh-annotate-char
         (mh-annotate-msg mh-sent-from-msg
                          mh-sent-from-folder
@@ -596,14 +591,16 @@ You have several choices here.
 
      Response     Reply Goes To
 
-     from         The person who sent the message.  This is the
+     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.
+     all cc       Forms a reply to the addresses in the
+                  \"Mail-Followup-To:\" header field if one
+                  exists; otherwise forms a reply to the sender,
+                  plus all recipients.
 
 Depending on your answer, \"repl\" is given a different argument
 to form your reply. Specifically, a choice of \"from\" or none at
@@ -613,7 +610,11 @@ all runs \"repl -nocc all\", and a choice of \"to\" runs \"repl
 
 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.
+MH-Letter mode (*note `mh-letter-mode'), is in the other window.
+If the reply draft was not one that you expected, check the
+things that affect the behavior of \"repl\" which include the
+\"repl:\" profile component and the \"replcomps\" and
+\"replgroupcomps\" files.
 
 If you supply a prefix argument INCLUDEP, the message you are
 replying to is inserted in your reply after having first been run
@@ -782,18 +783,9 @@ CONFIG is the window configuration before sending mail."
                        (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
-                                               ;; This is dead code, so
-                                               ;; remove it.
-                                        ;(and (boundp 'mh-etc) mh-etc)
-                                               )))
-                      components)
                      (t
-                      (error "Can't find components file \"%s\""
-                             components))))
+                      (error "Can't find %s in %s or %s"
+                             mh-comp-formfile mh-user-path mh-lib))))
                   nil)))
       (mh-insert-fields "To:" to "Subject:" subject "Cc:" cc)
       (goto-char (point-max))
@@ -870,7 +862,8 @@ Do not insert any pairs whose value is the empty string."
             (value (car (cdr name-values))))
         (if (not (string-match "^.*:$" field-name))
             (setq field-name (concat field-name ":")))
-        (cond ((equal value "")
+        (cond ((or (null value)
+                   (equal value ""))
                nil)
               ((mh-position-on-field field-name)
                (insert " " (or value "")))
@@ -919,15 +912,7 @@ letter."
   (mh-logo-display)
   (mh-make-local-hook 'kill-buffer-hook)
   (add-hook 'kill-buffer-hook 'mh-tidy-draft-buffer nil t)
-  (if (and (boundp 'mh-compose-letter-function)
-           mh-compose-letter-function)
-      ;; run-hooks will not pass arguments.
-      (let ((value mh-compose-letter-function))
-        (if (and (listp value) (not (eq (car value) 'lambda)))
-            (while value
-              (funcall (car value) to subject cc)
-              (setq value (cdr value)))
-          (funcall mh-compose-letter-function to subject cc)))))
+  (run-hook-with-args 'mh-compose-letter-function to subject cc))
 
 (defun mh-insert-x-mailer ()
   "Append an X-Mailer field to the header.
@@ -938,7 +923,10 @@ The versions of MH-E, Emacs, and MH are shown."
           (format "MH-E %s; %s; %sEmacs %s"
                   mh-version mh-variant-in-use
                   (if mh-xemacs-flag "X" "GNU ")
-                  (cond ((not mh-xemacs-flag) emacs-version)
+                  (cond ((not mh-xemacs-flag)
+                         (string-match "[0-9]+\\.[0-9]+\\(\\.[0-9]+\\)?"
+                                       emacs-version)
+                         (match-string 0 emacs-version))
                         ((string-match "[0-9.]*\\( +\([ a-z]+[0-9]+\)\\)?"
                                        emacs-version)
                          (match-string 0 emacs-version))
@@ -966,19 +954,6 @@ If the field already exists, this function does nothing."
         (unless (looking-at "\\(X-Face\\|Face\\|X-Image-URL\\): ")
           (insert "X-Face: "))))))
 
-;;;###mh-autoload
-(defun mh-letter-hide-all-skipped-fields ()
-  "Hide all skipped fields."
-  (save-excursion
-    (goto-char (point-min))
-    (save-restriction
-      (narrow-to-region (point) (mh-mail-header-end))
-      (while (re-search-forward mh-letter-header-field-regexp nil t)
-        (if (mh-letter-skipped-header-field-p (match-string 1))
-            (mh-letter-toggle-header-field-display -1)
-          (mh-letter-toggle-header-field-display 'long))
-        (beginning-of-line 2)))))
-
 (defun mh-tidy-draft-buffer ()
   "Run when a draft buffer is destroyed."
   (let ((buffer (get-buffer mh-recipients-buffer)))
@@ -1011,21 +986,6 @@ sequence."
              (mh-notate nil note
                         (+ mh-cmd-note mh-scan-field-destination-offset)))))))
 
-;;;###mh-autoload
-(defun mh-get-header-field (field)
-  "Find and return the body of FIELD in the mail header.
-Returns the empty string if the field is not in the header of the
-current buffer."
-  (if (mh-goto-header-field field)
-      (progn
-        (skip-chars-forward " \t")      ;strip leading white space in body
-        (let ((start (point)))
-          (mh-header-field-end)
-          (buffer-substring-no-properties start (point))))
-    ""))
-
-(fset 'mh-get-field 'mh-get-header-field) ;MH-E 4 compatibility
-
 (defun mh-insert-header-separator ()
   "Insert `mh-mail-header-separator', if absent."
   (save-excursion
@@ -1038,14 +998,16 @@ current buffer."
 (defun mh-insert-auto-fields (&optional non-interactive)
   "Insert custom fields if recipient is found in `mh-auto-fields-list'.
 
-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.
+Once the header contains one or more recipients, you may run this
+command to insert these fields manually. However, if you use this
+command, the automatic insertion when the message is sent is
+disabled.
 
-Return t if fields added; otherwise return nil."
+In a program, set 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. Return t if fields
+added; otherwise return nil."
   (interactive)
   (when (or (not non-interactive)
             (not mh-insert-auto-fields-done-local))
@@ -1090,7 +1052,7 @@ discarded."
   (cond ((and overwrite-flag
               (mh-goto-header-field (concat field ":")))
          (insert " " value)
-         (delete-region (point) (line-end-position)))
+         (delete-region (point) (mh-line-end-position)))
         ((and (not overwrite-flag)
               (mh-regexp-in-field-p (concat "\\b" value "\\b") field))
          ;; Already there, do nothing.