From:	CSBVAX::MRGATE!jeff@colgate.csnet@SMTP 17-JUL-1988 08:57
To:	ARISIA::EVERHART
Subj:	Safer Sendmail


Received: from RELAY.CS.NET by prep.ai.mit.edu; Sun, 17 Jul 88 04:47:33 EST
Message-Id: <8807170947.AA01189@prep.ai.mit.edu>
Received: from relay2.cs.net by RELAY.CS.NET id ab20148; 17 Jul 88 5:26 EDT
Received: from colgate by csnet-relay.csnet id ae25217; 17 Jul 88 5:15 EDT
Received: by colgate (5.51/)
	id AA00200; Sat, 16 Jul 88 18:37:22 EDT
Date: Sat, 16 Jul 88 18:37:22 EDT
From: Jeff Norden <jeff@colgate.csnet>
To: info-gnu-emacs@prep.ai.mit.edu
Subject: Safer Sendmail

Sendmail and Rmail modes are probably one of GNU emacs' best features.  But
lately I've been working late, been kind of tired, etc, and I've noticed
that it's kind of easy to inadvertently drop an un-finished letter in the
mail in sendmail-mode.  (For instance, intend to hit \C-x\C-s to save a
letter and finish it later, but accidently hit \C-c\C-s instead).  The
follwing self-evident diff for sendmail.el makes things a little safer.
(Although the Surgeon General says that the only way to be 100% safe is to
abstain from mail completely.)
				-Jeff Norden

  jeff@colgate.csnet
  Dept of Mathematics, Colgate University, Hamilton, NY  13346.


*** sendmail-orig	Sun Jun 19 19:38:09 1988
--- sendmail.el	Sat Jul 16 18:03:34 1988
***************
*** 51,56 ****
--- 51,60 ----
  (defvar mail-default-reply-to nil
    "*Address to insert as default Reply-to field of outgoing messages.")
  
+ (defvar mail-send-noconfirm nil
+   "*Set non-nil if you don't want emacs to bother asking 
+ \"Send this letter?\" before sending a letter")
+ 
  (defvar mail-abbrevs-loaded nil)
  (defvar mail-mode-map nil)
  
***************
*** 150,156 ****
    "Send message like mail-send, then, if no errors, exit from mail buffer.
  Prefix arg means don't delete this window."
    (interactive "P")
!   (mail-send)
    (bury-buffer (current-buffer))
    (if (and (not arg)
  	   (not (one-window-p))
--- 154,161 ----
    "Send message like mail-send, then, if no errors, exit from mail buffer.
  Prefix arg means don't delete this window."
    (interactive "P")
!   (if (mail-send)
!       (progn
    (bury-buffer (current-buffer))
    (if (and (not arg)
  	   (not (one-window-p))
***************
*** 158,164 ****
  	     (set-buffer (window-buffer (next-window (selected-window) 'not)))
  	     (eq major-mode 'rmail-mode)))
        (delete-window)
!     (switch-to-buffer (other-buffer (current-buffer)))))
  
  (defun mail-send ()
    "Send the message in the current buffer.
--- 163,169 ----
  	     (set-buffer (window-buffer (next-window (selected-window) 'not)))
  	     (eq major-mode 'rmail-mode)))
        (delete-window)
!     (switch-to-buffer (other-buffer (current-buffer)))))))
  
  (defun mail-send ()
    "Send the message in the current buffer.
***************
*** 167,177 ****
  Otherwise any failure is reported in a message back to
  the user from the mailer."
    (interactive)
    (message "Sending...")
    (funcall send-mail-function)
    (set-buffer-modified-p nil)
    (delete-auto-save-file-if-necessary)
!   (message "Sending...done"))
  
  (defun sendmail-send-it ()
    (let ((errbuf (if mail-interactive
--- 172,186 ----
  Otherwise any failure is reported in a message back to
  the user from the mailer."
    (interactive)
+   (if (or mail-send-noconfirm  (y-or-n-p "Send this letter?"))
+       (progn
    (message "Sending...")
    (funcall send-mail-function)
    (set-buffer-modified-p nil)
    (delete-auto-save-file-if-necessary)
!   (message "Sending...done")
!   't)
!     nil))
  
  (defun sendmail-send-it ()
    (let ((errbuf (if mail-interactive

