]> code.delx.au - gnu-emacs/blobdiff - lisp/mail/sendmail.el
mailheader.el comments.
[gnu-emacs] / lisp / mail / sendmail.el
index beba6be12fe9086bcd278c24a043b394df4c0ce3..40d6b94cb4078b31cfc428a4d6e973142efa428a 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, 2007, 2008, 2009
+;;   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
@@ -170,6 +170,8 @@ This is used by the default mail-sending commands.  See also
   :initialize 'custom-initialize-delay
   :group 'sendmail)
 
+;;;###autoload(custom-initialize-delay 'send-mail-function nil)
+
 ;;;###autoload
 (defcustom mail-header-separator (purecopy "--text follows this line--")
   "Line used to separate headers from text in messages being composed."
@@ -283,14 +285,14 @@ regardless of what part of it (if any) is included in the cited text.")
 
 ;;;###autoload
 (defcustom mail-citation-prefix-regexp
-  (purecopy "\\([ \t]*\\(\\w\\|[_.]\\)+>+\\|[ \t]*[]>|}]\\)+")
+  (purecopy "\\([ \t]*\\(\\w\\|[_.]\\)+>+\\|[ \t]*[]>|]\\)+")
   "Regular expression to match a citation prefix plus whitespace.
 It should match whatever sort of citation prefixes you want to handle,
 with whitespace before and after; it should also match just whitespace.
 The default value matches citations like `foo-bar>' plus whitespace."
   :type 'regexp
   :group 'sendmail
-  :version "20.3")
+  :version "24.1")
 
 (defvar mail-abbrevs-loaded nil)
 (defvar mail-mode-map
@@ -415,9 +417,11 @@ and should insert whatever you want to insert."
 
 ;;;###autoload
 (defcustom mail-default-directory (purecopy "~/")
-  "Directory for mail buffers.
-Value of `default-directory' for mail buffers.
-This directory is used for auto-save files of mail buffers."
+  "Value of `default-directory' for Mail mode buffers.
+This directory is used for auto-save files of Mail mode buffers.
+
+Note that Message mode does not use this variable; it auto-saves
+in `message-auto-save-directory'."
   :type '(directory :tag "Directory")
   :group 'sendmail
   :version "22.1")
@@ -714,7 +718,7 @@ Leave point at the start of the delimiter line."
   "Carry out Auto Fill for Mail mode.
 If within the headers, this makes the new lines into continuation lines."
   (if (< (point) (mail-header-end))
-      (let ((old-line-start (save-excursion (beginning-of-line) (point))))
+      (let ((old-line-start (line-beginning-position)))
        (if (do-auto-fill)
            (save-excursion
              (beginning-of-line)
@@ -1092,23 +1096,23 @@ external program defined by `sendmail-program'."
              ;; Delete Resent-BCC ourselves
              (if (save-excursion (beginning-of-line)
                                  (looking-at "resent-bcc"))
-                 (delete-region (save-excursion (beginning-of-line) (point))
-                                (save-excursion (end-of-line) (1+ (point))))))
-;;;  Apparently this causes a duplicate Sender.
-;;;        ;; If the From is different than current user, insert Sender.
-;;;        (goto-char (point-min))
-;;;        (and (re-search-forward "^From:"  delimline t)
-;;;             (progn
-;;;               (require 'mail-utils)
-;;;               (not (string-equal
-;;;                     (mail-strip-quoted-names
-;;;                      (save-restriction
-;;;                        (narrow-to-region (point-min) delimline)
-;;;                        (mail-fetch-field "From")))
-;;;                     (user-login-name))))
-;;;             (progn
-;;;               (forward-line 1)
-;;;               (insert "Sender: " (user-login-name) "\n")))
+                 (delete-region (line-beginning-position)
+                                (line-beginning-position 2))))
+            ;; Apparently this causes a duplicate Sender.
+           ;; ;; If the From is different than current user, insert Sender.
+           ;; (goto-char (point-min))
+           ;; (and (re-search-forward "^From:"  delimline t)
+           ;;      (progn
+           ;;        (require 'mail-utils)
+           ;;        (not (string-equal
+           ;;           (mail-strip-quoted-names
+           ;;            (save-restriction
+           ;;              (narrow-to-region (point-min) delimline)
+           ;;              (mail-fetch-field "From")))
+           ;;           (user-login-name))))
+           ;;      (progn
+           ;;        (forward-line 1)
+           ;;        (insert "Sender: " (user-login-name) "\n")))
            ;; Don't send out a blank subject line
            (goto-char (point-min))
            (if (re-search-forward "^Subject:\\([ \t]*\n\\)+\\b" delimline t)
@@ -1145,8 +1149,7 @@ external program defined by `sendmail-program'."
                   ;; should override any specified in the message itself.
                     (when where-content-type
                       (goto-char where-content-type)
-                      (beginning-of-line)
-                      (delete-region (point)
+                      (delete-region (point-at-bol)
                                      (progn (forward-line 1) (point)))))))
            ;; Insert an extra newline if we need it to work around
            ;; Sun's bug that swallows newlines.
@@ -1175,9 +1178,9 @@ external program defined by `sendmail-program'."
                                    nil errbuf nil "-oi")
                              (and envelope-from
                                   (list "-f" envelope-from))
-;;;                          ;; Don't say "from root" if running under su.
-;;;                          (and (equal (user-real-login-name) "root")
-;;;                               (list "-f" (user-login-name)))
+                             ;; ;; Don't say "from root" if running under su.
+                             ;; (and (equal (user-real-login-name) "root")
+                             ;;      (list "-f" (user-login-name)))
                              (and mail-alias-file
                                   (list (concat "-oA" mail-alias-file)))
                              (if mail-interactive
@@ -1505,14 +1508,18 @@ and don't delete any header fields."
   (interactive "P")
   (if mail-reply-action
       (let ((start (point))
-           (original mail-reply-action))
+           (original mail-reply-action)
+           (omark (mark t)))
        (and (consp original) (eq (car original) 'insert-buffer)
             (setq original (nth 1 original)))
        (if (consp original)
-           (apply (car original) (cdr original))
-         ;; If the original message is in another window in the same frame,
-         ;; delete that window to save screen space.
-         ;; t means don't alter other frames.
+           (progn
+             ;; Call yank function, and set the mark if it doesn't.
+             (apply (car original) (cdr original))
+             (if (eq omark (mark t))
+                 (push-mark (point))))
+         ;; If the original message is in another window in the same
+         ;; frame, delete that window to save space.
          (delete-windows-on original t)
          (with-no-warnings
            ;; We really want this to set mark.
@@ -1655,6 +1662,7 @@ If the current line has `mail-yank-prefix', insert it on the new line."
 ;; in middle of loading the file.
 
 ;;;###autoload (add-hook 'same-window-buffer-names (purecopy "*mail*"))
+;;;###autoload (add-hook 'same-window-buffer-names (purecopy "*unsent mail*"))
 
 ;;;###autoload
 (defun mail (&optional noerase to subject in-reply-to cc replybuffer actions)
@@ -1705,48 +1713,48 @@ The seventh argument ACTIONS is a list of actions to take
  when the message is sent, we apply FUNCTION to ARGS.
  This is how Rmail arranges to mark messages `answered'."
   (interactive "P")
-;;;  This is commented out because I found it was confusing in practice.
-;;;  It is easy enough to rename *mail* by hand with rename-buffer
-;;;  if you want to have multiple mail buffers.
-;;;  And then you can control which messages to save. --rms.
-;;;  (let ((index 1)
-;;;    buffer)
-;;;    ;; If requested, look for a mail buffer that is modified and go to it.
-;;;    (if noerase
-;;;    (progn
-;;;      (while (and (setq buffer
-;;;                        (get-buffer (if (= 1 index) "*mail*"
-;;;                                      (format "*mail*<%d>" index))))
-;;;                  (not (buffer-modified-p buffer)))
-;;;        (setq index (1+ index)))
-;;;      (if buffer (switch-to-buffer buffer)
-;;;        ;; If none exists, start a new message.
-;;;        ;; This will never re-use an existing unmodified mail buffer
-;;;        ;; (since index is not 1 anymore).  Perhaps it should.
-;;;        (setq noerase nil))))
-;;;    ;; Unless we found a modified message and are happy, start a new message.
-;;;    (if (not noerase)
-;;;    (progn
-;;;      ;; Look for existing unmodified mail buffer.
-;;;      (while (and (setq buffer
-;;;                        (get-buffer (if (= 1 index) "*mail*"
-;;;                                      (format "*mail*<%d>" index))))
-;;;                  (buffer-modified-p buffer))
-;;;        (setq index (1+ index)))
-;;;      ;; If none, make a new one.
-;;;      (or buffer
-;;;          (setq buffer (generate-new-buffer "*mail*")))
-;;;      ;; Go there and initialize it.
-;;;      (switch-to-buffer buffer)
-;;;      (erase-buffer)
-;;;          (setq default-directory (expand-file-name "~/"))
-;;;          (auto-save-mode auto-save-default)
-;;;          (mail-mode)
-;;;          (mail-setup to subject in-reply-to cc replybuffer actions)
-;;;      (if (and buffer-auto-save-file-name
-;;;               (file-exists-p buffer-auto-save-file-name))
-;;;          (message "Auto save file for draft message exists; consider M-x mail-recover"))
-;;;          t))
+ ;; This is commented out because I found it was confusing in practice.
+ ;; It is easy enough to rename *mail* by hand with rename-buffer
+ ;; if you want to have multiple mail buffers.
+ ;; And then you can control which messages to save. --rms.
+ ;; (let ((index 1)
+ ;;        buffer)
+ ;;   ;; If requested, look for a mail buffer that is modified and go to it.
+ ;;   (if noerase
+ ;;        (progn
+ ;;          (while (and (setq buffer
+ ;;                        (get-buffer (if (= 1 index) "*mail*"
+ ;;                                      (format "*mail*<%d>" index))))
+ ;;                  (not (buffer-modified-p buffer)))
+ ;;            (setq index (1+ index)))
+ ;;          (if buffer (switch-to-buffer buffer)
+ ;;            ;; If none exists, start a new message.
+ ;;            ;; This will never re-use an existing unmodified mail buffer
+ ;;            ;; (since index is not 1 anymore).  Perhaps it should.
+ ;;            (setq noerase nil))))
+ ;;   ;; Unless we found a modified message and are happy, start a new message.
+ ;;   (if (not noerase)
+ ;;        (progn
+ ;;          ;; Look for existing unmodified mail buffer.
+ ;;          (while (and (setq buffer
+ ;;                        (get-buffer (if (= 1 index) "*mail*"
+ ;;                                      (format "*mail*<%d>" index))))
+ ;;                  (buffer-modified-p buffer))
+ ;;            (setq index (1+ index)))
+ ;;          ;; If none, make a new one.
+ ;;          (or buffer
+ ;;              (setq buffer (generate-new-buffer "*mail*")))
+ ;;          ;; Go there and initialize it.
+ ;;          (switch-to-buffer buffer)
+ ;;          (erase-buffer)
+ ;;         (setq default-directory (expand-file-name "~/"))
+ ;;         (auto-save-mode auto-save-default)
+ ;;         (mail-mode)
+ ;;         (mail-setup to subject in-reply-to cc replybuffer actions)
+ ;;          (if (and buffer-auto-save-file-name
+ ;;               (file-exists-p buffer-auto-save-file-name))
+ ;;              (message "Auto save file for draft message exists; consider M-x mail-recover"))
+ ;;         t))
 
   (if (eq noerase 'new)
       (pop-to-buffer (generate-new-buffer "*mail*"))
@@ -1767,7 +1775,7 @@ The seventh argument ACTIONS is a list of actions to take
   (mail-mode)
   ;; Disconnect the buffer from its visited file
   ;; (in case the user has actually visited a file *mail*).
-;;;  (set-visited-file-name nil)
+  ;; (set-visited-file-name nil)
   (let (initialized)
     (and (not (and noerase
                   (not (eq noerase 'new))))
@@ -1946,5 +1954,4 @@ you can move to one of them and type C-c C-c to recover that one."
 
 (provide 'sendmail)
 
-;; arch-tag: 48bc1025-d993-4d31-8d81-2a29491f0626
 ;;; sendmail.el ends here