]> code.delx.au - gnu-emacs/blobdiff - lisp/mail/feedmail.el
Merge changes from emacs-24; up to 2012-04-26T02:03:19Z!ueno@unixuser.org
[gnu-emacs] / lisp / mail / feedmail.el
index 934637ecbbd10bf28fb9de5aa7a5f2c5e00bfad7..df18abbc532d7807e7ddb6250cc4d6d22f2da001 100644 (file)
@@ -10,7 +10,7 @@
 
 ;;; Commentary:
 
-;; A replacement for parts of Emacs' sendmail.el (specifically,
+;; A replacement for parts of sendmail.el (specifically,
 ;; it's what handles your outgoing mail after you hit C-c C-c in mail
 ;; mode).  See below for a list of additional features, including the
 ;; ability to queue messages for later sending.  This replaces
@@ -83,7 +83,7 @@
 ;; work properly.  If you don't know what custom is all about and want
 ;; to edit your user option elisp variables the old fashioned way,
 ;; just imagine that all the "defcustom" stuff you see below is really
-;; "defvar", and ignore everthing else.  For info about custom, see
+;; "defvar", and ignore everything else.  For info about custom, see
 ;; <URL:http://www.dina.kvl.dk/~abraham/custom/>.
 ;;
 ;; This code does in elisp a superset of the stuff that used to be done
 ;;           for FQM files if you're a VM user
 ;;         change buffer-substring calls to buffer-substring-no-properties for
 ;;           speed-up (suggested by Howard Melman <howard@silverstream.com>)
-;;         feedmail-sendmail-f-doesnt-sell-me-out to contol "-f" in call to sendmail
+;;         feedmail-sendmail-f-doesnt-sell-me-out to control "-f" in call to sendmail
 ;;           in feedmail-buffer-to-sendmail
 ;;         better trapping of odd conditions during the running of the queue;
 ;;           thanks to Yigal Hochberg for helping me test much of this by remote
 ;;           systems with non-classic /bin/[r]mail behavior
 ;;         guard against nil user-mail-address in generating MESSAGE-ID:
 ;;         feedmail-queue-slug-suspect-regexp is now a variable to
-;;           accomodate non-ASCII environments (thanks to
+;;           accommodate non-ASCII environments (thanks to
 ;;           Makoto.Nakagawa@jp.compaq.com for this suggestion)
 ;;         feedmail-buffer-to-smtp, to parallel feedmail-buffer-to-smtpmail
 ;; patchlevel 10, 22 April 2001
@@ -428,6 +428,7 @@ any other non-nil value, take the action in both cases.  Even if
 you're not confirming the sending of immediate or queued messages,
 it can still be interesting to see a lot about them as they are
 shuttled robotically onward."
+  :version "24.1"
   :group 'feedmail-misc
   :type 'boolean
   )
@@ -1010,7 +1011,7 @@ If it contains a \"%s\", that will be replaced with the value of
 
 
 (defcustom feedmail-ask-before-queue-reprompt "FQM: Please type q, i, d, or e; or ? for help [%s]: "
-  "A string which will be used for repompting after invalid input.
+  "A string which will be used for reprompting after invalid input.
 If it contains a \"%s\", that will be replaced with the value of
 `feedmail-ask-before-queue-default'."
   :group 'feedmail-queue
@@ -1339,7 +1340,7 @@ Example 'defadvice' for mail-send:
 
 
 (defvar feedmail-queue-runner-is-active nil
-  "*Non-nil means we're inside the logic of the queue-running loop.
+  "Non-nil means we're inside the logic of the queue-running loop.
 That is, iterating over all messages in the queue to send them.  In
 that case, the value is the name of the queued message file currently
 being processed.  This can be used for differentiating customized code
@@ -1356,7 +1357,7 @@ for you.  Add this function to `mail-send-hook' with something like this:
        (add-hook 'mail-send-hook 'feedmail-mail-send-hook-splitter)
 
 Then add the functions you want called to either `feedmail-mail-send-hook-queued'
-or `feedmail-mail-send-hook', as apprpriate.  The distinction is that
+or `feedmail-mail-send-hook', as appropriate.  The distinction is that
 `feedmail-mail-send-hook' will be called when you send mail from a composition
 buffer (typically by typing C-c C-c), whether the message is sent immediately
 or placed in the queue or drafts directory.  `feedmail-mail-send-hook-queued' is
@@ -1365,17 +1366,19 @@ call to `feedmail-run-the-queue'."
   (feedmail-say-debug ">in-> feedmail-mail-send-hook-splitter %s" feedmail-queue-runner-is-active)
   (if feedmail-queue-runner-is-active
       (run-hooks 'feedmail-mail-send-hook-queued)
-    (run-hooks 'feedmail-mail-send-hook))
-  )
-
-
-(defvar feedmail-mail-send-hook nil
-  "*See documentation for `feedmail-mail-send-hook-splitter'.")
+    (run-hooks 'feedmail-mail-send-hook)))
 
+(defcustom feedmail-mail-send-hook nil
+  "Hook run by `feedmail-mail-send-hook-splitter' for immediate mail.
+See documentation of `feedmail-mail-send-hook-splitter' for details."
+  :type 'hook
+  :group 'feedmail)
 
-(defvar feedmail-mail-send-hook-queued nil
-  "*See documentation for `feedmail-mail-send-hook-splitter'.")
-
+(defcustom feedmail-mail-send-hook-queued nil
+  "Hook run by `feedmail-mail-send-hook-splitter' for queued mail.
+See documentation of `feedmail-mail-send-hook-splitter' for details."
+  :type 'hook
+  :group 'feedmail)
 
 (defun feedmail-confirm-addresses-hook-example ()
   "An example of a `feedmail-last-chance-hook'.
@@ -1386,9 +1389,7 @@ It shows the simple addresses and gets a confirmation.  Use as:
     (erase-buffer)
     (insert (mapconcat 'identity feedmail-address-list " "))
     (if (not (y-or-n-p "How do you like them apples? "))
-       (error "FQM: Sending...gave up in last chance hook")
-      )))
-
+       (error "FQM: Sending...gave up in last chance hook"))))
 
 (defcustom feedmail-last-chance-hook nil
   "User's last opportunity to modify the message on its way out.
@@ -1513,7 +1514,7 @@ function, for example, to archive all of your sent messages someplace
 
 
 (defvar feedmail-is-a-resend nil
-  "*Non-nil means the message is a Resend (in the RFC-822 sense).
+  "Non-nil means the message is a Resend (in the RFC-822 sense).
 This affects the composition of certain headers.  feedmail sets this
 variable as soon as it starts prepping the message text buffer, so any
 user-supplied functions can rely on it.  Users shouldn't set or change this
@@ -1585,7 +1586,7 @@ messages to make sure it works as expected."
 
 
 ;; feedmail-buffer-to-binmail, feedmail-buffer-to-sendmail, and
-;; feedmail-buffer-to-smptmail are the only things provided for values
+;; feedmail-buffer-to-smtpmail are the only things provided for values
 ;; for the variable feedmail-buffer-eating-function.  It's pretty easy
 ;; to write your own, though.
 (defun feedmail-buffer-to-binmail (prepped errors-to addr-listoid)
@@ -1633,22 +1634,21 @@ local gurus."
   ;; no evil.
   (feedmail-say-debug ">in-> feedmail-buffer-to-smtpmail %s" addr-listoid)
   (require 'smtpmail)
-  (if (not (smtpmail-via-smtp addr-listoid prepped))
-      (progn
-       (set-buffer errors-to)
-       (insert "Send via smtpmail failed.  Probable SMTP protocol error.\n")
-       (insert "Look for details below or in the *Messages* buffer.\n\n")
-       (let ((case-fold-search t)
-             ;; don't be overconfident about the name of the trace buffer
-             (tracer (concat "trace.*smtp.*" (regexp-quote smtpmail-smtp-server))))
-         (mapcar
-          (lambda (buffy)
-             (if (string-match tracer (buffer-name buffy))
-                 (progn
-                   (insert "SMTP Trace from " (buffer-name buffy) "\n---------------")
-                   (insert-buffer-substring buffy)
-                   (insert "\n\n"))))
-          (buffer-list))))))
+  (let ((result (smtpmail-via-smtp addr-listoid prepped)))
+    (when result
+      (set-buffer errors-to)
+      (insert "Send via smtpmail failed: %s" result)
+      (let ((case-fold-search t)
+           ;; don't be overconfident about the name of the trace buffer
+           (tracer (concat "trace.*smtp.*" (regexp-quote smtpmail-smtp-server))))
+       (mapcar
+        (lambda (buffy)
+          (if (string-match tracer (buffer-name buffy))
+              (progn
+                (insert "SMTP Trace from " (buffer-name buffy) "\n---------------")
+                (insert-buffer-substring buffy)
+                (insert "\n\n"))))
+        (buffer-list))))))
 
 (declare-function smtp-via-smtp "ext:smtp" (sender recipients smtp-text-buffer))
 (defvar smtp-server)
@@ -2027,12 +2027,6 @@ backup file names and the like)."
              (if (looking-at ".*\r\n.*\r\n")
                  (while (search-forward "\r\n" nil t)
                    (replace-match "\n" nil t)))
-;;                ;; work around text-vs-binary wierdness
-;;                ;; if we don't find the normal M-H-S, try reading the file a different way
-;;                (if (not (feedmail-find-eoh t))
-;;                        (let ((file-name-buffer-file-type-alist nil) (default-buffer-file-type nil))
-;;                              (erase-buffer)
-;;                              (insert-file-contents maybe-file)))
              (funcall feedmail-queue-runner-mode-setter arg)
              (condition-case signal-stuff ; don't give up the loop if user skips some
                  (let ((feedmail-enable-queue nil)
@@ -2189,7 +2183,7 @@ you can set `feedmail-queue-reminder-alist' to nil."
            (if (or (eq user-sez ?\C-m) (eq user-sez ?\C-j) (eq user-sez ?y))
                (setq user-sez d-char))
            ;; these char-to-int things are because of some
-           ;; incomprensible difference between the two in
+           ;; incomprehensible difference between the two in
            ;; byte-compiled stuff between Emacs and XEmacs
            ;; (well, I'm sure someone could comprehend it,
            ;; but I say 'uncle')
@@ -2262,9 +2256,9 @@ the counts."
   (while (string-match feedmail-queue-slug-suspect-regexp slug) (setq slug (replace-match "-" nil nil slug)))
   ;; collapse multiple hyphens to one
   (while (string-match "--+" slug) (setq slug (replace-match "-" nil nil slug)))
-  ;; for tidyness, peel off leading hyphens
+  ;; for tidiness, peel off leading hyphens
   (if (string-match "^-*" slug) (setq slug (replace-match "" nil nil slug)))
-  ;; for tidyness, peel off trailing hyphens
+  ;; for tidiness, peel off trailing hyphens
   (if (string-match "-*$" slug) (setq slug (replace-match "" nil nil slug)))
   slug
   )
@@ -2411,7 +2405,7 @@ mapped to mostly alphanumerics for safety."
        (a-re-dtcb  "^\\(To\\|Cc\\|Bcc\\):")
        (a-re-dtc   "^\\(To\\|Cc\\):")
        (a-re-db    "^Bcc:")
-       ;; to get a temporary changable copy
+       ;; to get a temporary changeable copy
        (mail-header-separator mail-header-separator)
        )
     (unwind-protect