Fix 2004-03-15 tiny change entry.
[gnus] / contrib / sendmail.el
index ee512b3..fb6abff 100644 (file)
@@ -1,7 +1,7 @@
 ;;; sendmail.el --- mail sending commands for Emacs.  -*- byte-compile-dynamic: t -*-
 
 ;; Copyright (C) 1985, 1986, 1992, 1993, 1994, 1995, 1996, 1998, 2000,
-;;   2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+;;   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: mail
@@ -10,7 +10,7 @@
 
 ;; 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
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
   :group 'sendmail
   :version "22.1")
 
+(defcustom sendmail-program
+  (cond
+    ((file-exists-p "/usr/sbin/sendmail") "/usr/sbin/sendmail")
+    ((file-exists-p "/usr/lib/sendmail") "/usr/lib/sendmail")
+    ((file-exists-p "/usr/ucblib/sendmail") "/usr/ucblib/sendmail")
+    (t "fakemail"))                    ;In ../etc, to interface to /bin/mail.
+  "Program used to send messages."
+  :group 'mail
+  :type 'file)
+
 ;;;###autoload
 (defcustom mail-from-style 'angles
   "Specifies how \"From:\" fields look.
@@ -610,16 +620,16 @@ Like Text Mode but with these additional commands:
 \\[mail-send-and-exit]  mail-send-and-exit (send the message and exit)
 
 Here are commands that move to a header field (and create it if there isn't):
-        \\[mail-to]  move to To:       \\[mail-subject]  move to Subject:
-        \\[mail-cc]  move to CC:       \\[mail-bcc]  move to BCC:
+        \\[mail-to]  move to To:       \\[mail-subject]  move to Subj:
+        \\[mail-bcc]  move to BCC:     \\[mail-cc]  move to CC:
         \\[mail-fcc]  move to FCC:     \\[mail-reply-to] move to Reply-To:
          \\[mail-mail-reply-to]  move to Mail-Reply-To:
          \\[mail-mail-followup-to] move to Mail-Followup-To:
-\\[mail-text]  mail-text (move to beginning of message text).
+\\[mail-text]  move to message text.
 \\[mail-signature]  mail-signature (insert `mail-signature-file' file).
 \\[mail-yank-original]  mail-yank-original (insert current message, in Rmail).
 \\[mail-fill-yanked-message]  mail-fill-yanked-message (fill what was yanked).
-\\[mail-sent-via]  mail-sent-via (add a Sent-via field for each To or CC).
+\\[mail-sent-via]  mail-sent-via (add a sent-via field for each To or CC).
 Turning on Mail mode runs the normal hooks `text-mode-hook' and
 `mail-mode-hook' (in that order)."
   (make-local-variable 'mail-reply-action)
@@ -757,7 +767,13 @@ Prefix arg means don't delete this window."
   "Bury this mail buffer."
   (let ((newbuf (other-buffer (current-buffer))))
     (bury-buffer (current-buffer))
-    (if (and (or (window-dedicated-p (frame-selected-window))
+    (if (and (or nil
+                ;; In this case, we need to go to a different frame.
+                (window-dedicated-p (frame-selected-window))
+                ;; In this mode of operation, the frame was probably
+                ;; made for this buffer, so the user probably wants
+                ;; to delete it now.
+                (and pop-up-frames (one-window-p))
                 (cdr (assq 'mail-dedicated-frame (frame-parameters))))
             (not (null (delq (selected-frame) (visible-frame-list)))))
        (progn
@@ -863,11 +879,14 @@ the user from the mailer."
                (error "Message contains non-ASCII characters"))))
        ;; Complain about any invalid line.
        (goto-char (point-min))
-       (while (< (point) (mail-header-end))
-         (unless (looking-at "[ \t]\\|.*:\\|$")
-           (push-mark opoint)
-           (error "Invalid header line (maybe a continuation line lacks initial whitespace)"))
-         (forward-line 1))
+       (re-search-forward (regexp-quote mail-header-separator) (point-max) t)
+       (let ((header-end (or (match-beginning 0) (point-max))))
+         (goto-char (point-min))
+         (while (< (point) header-end)
+           (unless (looking-at "[ \t]\\|.*:\\|$")
+             (push-mark opoint)
+             (error "Invalid header line (maybe a continuation line lacks initial whitespace)"))
+           (forward-line 1)))
        (goto-char opoint)
        (run-hooks 'mail-send-hook)
        (message "Sending...")
@@ -972,6 +991,19 @@ See also the function `select-message-coding-system'.")
           nil)
          (t (error "Invalid value for `mail-from-style'")))))
 
+;; Normally you will not need to modify these options unless you are
+;; using some non-genuine substitute for sendmail which does not
+;; implement each and every option that the original supports.
+;; E.g., ssmtp does not support "-odb", so, if your site uses it,
+;; you will need to modify `sendmail-error-reporting-non-interactive'
+;; in your site-init.el.
+(defvar sendmail-error-reporting-interactive
+  ;; These mean "report errors to terminal" and "deliver interactively"
+  '("-oep" "-odi"))
+(defvar sendmail-error-reporting-non-interactive
+  ;; These mean "report errors by mail" and "deliver in background".
+  '("-oem" "-odb"))
+
 (defun sendmail-send-it ()
   "Send the current mail buffer using the Sendmail package.
 This is a suitable value for `send-mail-function'.  It sends using the
@@ -1116,12 +1148,8 @@ external program defined by `sendmail-program'."
                              (and mail-alias-file
                                   (list (concat "-oA" mail-alias-file)))
                              (if mail-interactive
-                                 ;; These mean "report errors to terminal"
-                                 ;; and "deliver interactively"
-                                 '("-oep" "-odi")
-                               ;; These mean "report errors by mail"
-                               ;; and "deliver in background".
-                               '("-oem" "-odb"))
+                                  sendmail-error-reporting-interactive
+                                  sendmail-error-reporting-non-interactive)
                              ;; Get the addresses from the message
                              ;; unless this is a resend.
                              ;; We must not do that for a resend
@@ -1379,7 +1407,7 @@ Create a Mail-Followup-To field if none."
       nil)))
 
 (defun mail-text ()
-  "Move point to beginning of message text."
+  "Move point to beginning of text field."
   (interactive)
   (expand-abbrev)
   (goto-char (mail-text-start)))
@@ -1716,6 +1744,9 @@ The seventh argument ACTIONS is a list of actions to take
        (message "Auto save file for draft message exists; consider M-x mail-recover"))
     initialized))
 
+(declare-function dired-view-file "dired" ())
+(declare-function dired-get-filename "dired" (&optional localp no-error-if-not-filep))
+
 (defun mail-recover-1 ()
   "Pop up a list of auto-saved draft messages so you can recover one of them."
   (interactive)
@@ -1787,6 +1818,10 @@ The seventh argument ACTIONS is a list of actions to take
              (setq buffer-file-coding-system
                    default-buffer-file-coding-system))))))))
 
+(declare-function dired-move-to-filename "dired" (&optional raise-error eol))
+(declare-function dired-get-filename "dired" (&optional localp no-error-if-not-filep))
+(declare-function dired-view-file "dired" ())
+
 (defun mail-recover ()
   "Recover interrupted mail composition from auto-save files.