]> code.delx.au - gnu-emacs/blobdiff - lisp/mh-e/mh-comp.el
Some minor fixes
[gnu-emacs] / lisp / mh-e / mh-comp.el
index 6c8ac6c6e7e516fb4ed4129c924999f492ba49c8..95c543db248ee12035151542bf71a82fe2a312d7 100644 (file)
@@ -1,6 +1,7 @@
 ;;; mh-comp.el --- MH-E functions for composing and sending messages
 
-;; Copyright (C) 1993, 1995, 1997, 2000-2011  Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1995, 1997, 2000-2014 Free Software Foundation,
+;; Inc.
 
 ;; Author: Bill Wohler <wohler@newt.com>
 ;; Maintainer: Bill Wohler <wohler@newt.com>
@@ -122,7 +123,7 @@ Used by the \\[mh-edit-again] and \\[mh-extract-rejected-mail] commands.")
   "Syntax table used by MH-E while in MH-Letter mode.")
 
 (defvar mh-regexp-in-field-syntax-table nil
-  "Specify a syntax table for mh-regexp-in-field-p to use instead of determining")
+  "Specify a syntax table for `mh-regexp-in-field-p' to use.")
 
 (defvar mh-fcc-syntax-table
   (let ((syntax-table (make-syntax-table text-mode-syntax-table)))
@@ -428,45 +429,49 @@ See also `mh-send'."
     (mh-clean-msg-header (point-min) mh-new-draft-cleaned-headers nil)
     (mh-insert-header-separator)
     ;; Merge in components
-    (mh-mapc (function (lambda (header-field)
-                         (let ((field (car header-field))
-                               (value (cdr header-field))
-                               (case-fold-search t))
-                           (cond
-                            ;; Address field
-                            ((string-match field "^To$\\|^Cc$\\|^From$")
-                             (cond
-                              ((not (mh-goto-header-field (concat field ":")))
-                              ;; Header field does not exist, add it
-                              (mh-goto-header-end 0)
-                              (insert field ": " value "\n"))
-                             ((string-equal value "")
-                               ;; Header field already exists and no value
-                               )
-                             (t
-                              ;; Header field exists and we have a value
-                              (let (address mailbox (alias (mh-alias-expand value)))
-                                (and alias
-                                     (setq address (ietf-drums-parse-address alias))
-                                     (setq mailbox (car address)))
-                                ;; XXX - Need to parse all addresses out of field
-                                (if (and
-                                     (not (mh-regexp-in-field-p (concat "\\b" (regexp-quote value) "\\b") field))
-                                     mailbox
-                                     (not (mh-regexp-in-field-p (concat "\\b" (regexp-quote mailbox) "\\b") field)))
-                                    (insert " " value ","))
-                                ))))
-                            ((string-match field "^Fcc$")
-                             ;; Folder reference
-                             (mh-modify-header-field field value))
-                            ;; Text field, that's an easy case
-                            (t
-                             (mh-modify-header-field field value))))))
-             (mh-components-to-list (mh-find-components)))
+    (mh-mapc
+     (function
+      (lambda (header-field)
+        (let ((field (car header-field))
+              (value (cdr header-field))
+              (case-fold-search t))
+          (cond
+           ;; Address field
+           ((string-match field "^To$\\|^Cc$\\|^From$")
+            (cond
+             ((not (mh-goto-header-field (concat field ":")))
+              ;; Header field does not exist, add it
+              (mh-goto-header-end 0)
+              (insert field ": " value "\n"))
+             ((string-equal value "")
+              ;; Header field already exists and no value
+              )
+             (t
+              ;; Header field exists and we have a value
+              (let (address mailbox (alias (mh-alias-expand value)))
+                (and alias
+                     (setq address (ietf-drums-parse-address alias))
+                     (setq mailbox (car address)))
+                ;; XXX - Need to parse all addresses out of field
+                (if (and
+                     (not (mh-regexp-in-field-p
+                           (concat "\\b" (regexp-quote value) "\\b") field))
+                     mailbox
+                     (not (mh-regexp-in-field-p
+                           (concat "\\b" (regexp-quote mailbox) "\\b") field)))
+                    (insert " " value ","))
+                ))))
+           ((string-match field "^Fcc$")
+            ;; Folder reference
+            (mh-modify-header-field field value))
+           ;; Text field, that's an easy case
+           (t
+            (mh-modify-header-field field value))))))
+     (mh-components-to-list (mh-find-components)))
     (goto-char (point-min))
     (save-buffer)
-    (mh-compose-and-send-mail draft "" from-folder nil nil nil nil nil nil
-                              config)
+    (mh-compose-and-send-mail
+     draft "" from-folder nil nil nil nil nil nil config)
     (mh-letter-mode-message)
     (mh-letter-adjust-point)))
 
@@ -484,7 +489,7 @@ Returns a list of field name and value (which may be null)."
 
 
 (defun mh-components-to-list (components)
-  "Read in the components file and convert to a list of field names and values."
+  "Convert the COMPONENTS file to a list of field names and values."
   (with-current-buffer (get-buffer-create mh-temp-buffer)
     (erase-buffer)
     (insert-file-contents components)
@@ -582,6 +587,13 @@ See also `mh-compose-forward-as-mime-flag',
              (mh-forwarded-letter-subject orig-from orig-subject)))
         (mh-insert-fields "Subject:" forw-subject)
         (goto-char (point-min))
+        ;; 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)
+             (save-excursion
+               (goto-char (mh-mail-header-end))
+               (buffer-substring-no-properties (point) (mh-line-end-position))))
+        (set (make-local-variable 'mail-header-separator) mh-mail-header-separator) ;override sendmail.el
         ;; If using MML, translate MH-style directive
         (if (equal mh-compose-insertion 'mml)
             (save-excursion
@@ -888,7 +900,7 @@ Optional argument BUFFER can be used to specify the buffer."
      (t
       (error "Can't find %s in %s or %s"
              mh-comp-formfile mh-user-path mh-lib)))))
-  
+
 (defun mh-send-sub (to cc subject config)
   "Do the real work of composing and sending a letter.
 Expects the TO, CC, and SUBJECT fields as arguments.
@@ -1190,21 +1202,20 @@ discarded."
   (let ((old-syntax-table (syntax-table)))
     (unwind-protect
         (save-excursion
-          (let ((search-result nil)
-                (field))
+          (let ((search-result nil))
             (while fields
-              (let ((field (car fields))
-                    (syntax-table mh-regexp-in-field-syntax-table))
-                (if (null syntax-table)
-                    (let ((case-fold-search t))
-                      (cond
-                       ((string-match field "^To$\\|^[BD]?cc$\\|^From$")
-                        (setq syntax-table mh-addr-syntax-table))
-                       ((string-match field "^Fcc$")
-                        (setq syntax-table mh-fcc-syntax-table))
-                       (t
-                        (setq syntax-table (syntax-table)))
-                       )))           
+              (let* ((field (car fields))
+                     (syntax-table
+                      (or mh-regexp-in-field-syntax-table
+                          (let ((case-fold-search t))
+                            (cond
+                             ((string-match field "^To$\\|^[BD]?cc$\\|^From$")
+                              mh-addr-syntax-table)
+                             ((string-match field "^Fcc$")
+                              mh-fcc-syntax-table)
+                             (t
+                              (syntax-table)))
+                            ))))
                 (if (and (mh-goto-header-field field)
                          (set-syntax-table syntax-table)
                          (re-search-forward
@@ -1214,7 +1225,7 @@ discarded."
                   (setq fields (cdr fields)))
                 (set-syntax-table old-syntax-table)))
             search-result))
-    (set-syntax-table old-syntax-table))))
+      (set-syntax-table old-syntax-table))))
 
 (defun mh-ascii-buffer-p ()
   "Check if current buffer is entirely composed of ASCII.