[comp.emacs] Safer Sendmail

jeff@colgate.CSNET (Jeff Norden) (07/17/88)

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