(define-mail-abbrev): When reading from mailrc, recognize string
[bpt/emacs.git] / lisp / mail / sendmail.el
index c0fcdf8..5293a5a 100644 (file)
@@ -1,17 +1,18 @@
 ;;; 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, 2007 Free Software Foundation, Inc.
+;;   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+;;   Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: mail
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; 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)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,9 +20,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -116,10 +115,15 @@ so you can remove or alter the BCC field to override the default."
   :group 'sendmail)
 
 ;;;###autoload
-(defcustom mail-interactive nil
+(defcustom mail-interactive t
+  ;; We used to use a default of nil rather than t, but nowadays it is very
+  ;; common for sendmail to be misconfigured, so one cannot rely on the
+  ;; bounce message to be delivered anywhere, least of all to the
+  ;; user's mailbox.
   "Non-nil means when sending a message wait for and display errors.
 nil means let mailer mail back a message to report errors."
   :type 'boolean
+  :version "23.1"                      ; changed from nil to t
   :group 'sendmail)
 
 (defcustom mail-yank-ignored-headers
@@ -767,7 +771,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
@@ -985,6 +995,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
@@ -1090,7 +1113,7 @@ external program defined by `sendmail-program'."
                          (/= (point) (point-max)))
                   selected-coding
                   (setq charset
-                        (coding-system-get selected-coding 'mime-charset))
+                        (coding-system-get selected-coding :mime-charset))
                   (goto-char delimline)
                   (insert "MIME-version: 1.0\n"
                           "Content-type: text/plain; charset="
@@ -1129,12 +1152,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
@@ -1546,7 +1565,7 @@ and don't delete any header fields."
           (let ((mail-indentation-spaces (if arg (prefix-numeric-value arg)
                                            mail-indentation-spaces)))
             (if mail-citation-hook
-                ;; Bind mail-citation-hook to the original message's header.
+                ;; Bind mail-citation-header to the original message's header.
                 (let ((mail-citation-header
                        (with-current-buffer buffer
                          (buffer-substring-no-properties
@@ -1729,6 +1748,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)
@@ -1776,7 +1798,7 @@ The seventh argument ACTIONS is a list of actions to take
       (define-key (current-local-map) "v"
        (lambda ()
          (interactive)
-         (let ((coding-system-for-read 'emacs-mule-unix))
+         (let ((coding-system-for-read 'utf-8-emacs-unix))
            (dired-view-file))))
       (define-key (current-local-map) "\C-c\C-c"
        (lambda ()
@@ -1784,13 +1806,13 @@ The seventh argument ACTIONS is a list of actions to take
          (let ((fname (dired-get-filename))
                ;; Auto-saved files are written in the internal
                ;; representation, so they should be read accordingly.
-               (coding-system-for-read 'emacs-mule-unix))
+               (coding-system-for-read 'utf-8-emacs-unix))
            (switch-to-buffer-other-window "*mail*")
            (let ((buffer-read-only nil))
              (erase-buffer)
              (insert-file-contents fname nil)
              ;; insert-file-contents will set buffer-file-coding-system
-             ;; to emacs-mule, which is probably not what they want to
+             ;; to utf-8-emacs, which is probably not what they want to
              ;; use for sending the message.  But we don't know what
              ;; was its value before the buffer was killed or Emacs
              ;; crashed.  We therefore reset buffer-file-coding-system
@@ -1800,6 +1822,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.
 
@@ -1841,7 +1867,7 @@ you can move to one of them and type C-c C-c to recover that one."
                     (buffer-coding buffer-file-coding-system)
                     ;; Auto-save files are written in internal
                     ;; representation of non-ASCII characters.
-                    (coding-system-for-read 'emacs-mule-unix))
+                    (coding-system-for-read 'utf-8-emacs-unix))
                 (erase-buffer)
                 (insert-file-contents file-name nil)
                 (setq buffer-file-coding-system buffer-coding)))))