[gnu.emacs.bug] Unsent mail messages should be "protected"

ram-ashwin@YALE.EDU (Ashwin Ram) (05/18/89)

GNU Emacs 18.52.26 of Thu May  4 1989 on leo.ring.cs.yale.edu (Domain/OS)

A mail message that is currently being composed should be "protected" in the
sense that:

1. If you M-x kill-emacs while the message is being composed, Emacs should
   prompt you with "modified buffers exist, do you really want to exit" just
   like with other buffers that you don't want to clobber accidently.

2. If you start composing a new message using M-x mail, and a previous unsent
   message exists (as indicated by the presence of the ~/#%*mail* file),
   Emacs should not clobber the old message.  Instead, it should either (a)
   prompt you with "unsent message exists, erase it" or (b) use a different
   name for the checkpoint file.

Also, while I'm at it, the following modification to mail allows the user to
compose >1 message at a time.  If you M-x mail while a mail message is being
composed, you are prompted with "unsent message exists, erase it".  If you
say "y", the old message is clobbered; if you say "n", a new mail buffer is
set up for you.  The arguments are the same as in the standard release.

;; Ashwin Ram, 5/17/89.
(defun mail (&optional noerase to subject in-reply-to cc replybuffer)
   (interactive "P")
   (switch-to-buffer "*mail*")
   (if (not noerase)
       (progn
          (if (or (not (buffer-modified-p))
                  (y-or-n-p "Unsent message being composed; erase it? "))
              (erase-buffer)
              (progn (bury-buffer)
                     (switch-to-buffer (generate-new-buffer "*mail*"))))
          (setq default-directory (expand-file-name "~/"))
          (auto-save-mode auto-save-default)
          (mail-mode)
          (mail-setup to subject in-reply-to cc replybuffer)
          t)))

Feel free to add this to the distribution if you like it.

-- Ashwin.

ARPA:    Ram-Ashwin@cs.yale.edu
UUCP:    {decvax,ucbvax,harvard,cmcl2,...}!yale!Ram-Ashwin
BITNET:  Ram@yalecs

ram-ashwin@YALE.EDU (Ashwin Ram) (05/18/89)

>    > 2. If you start composing a new message using M-x mail, and a
>    >    previous unsent message exists (as indicated by the presence of
>    >    the ~/#%*mail* file), Emacs should not clobber the old message.
>    >    Instead, it should either (a) prompt you with "unsent message
>    >    exists, erase it" or (b) use a different name for the checkpoint
>    >    file.
>   
>   Emacs already does that, at least here.  When I type M-x mail, then type
>   a few characters and then M-x mail again, I get the "Unsent message
>   exists..." query.  We're running 18.52.

[Since I've had a couple of people misunderstand what I meant here, I'm
CC'ing this clarification to bug-gnu-emacs.]

M-x mail looks at the *mail* buffer, not the ~/#%*mail*# file.  If the
checkpoint file exists but the *mail* buffer doesn't, M-x mail does not
realize that you might have an unsent message in the checkpoint file.

E.g., if you start composing a mail message and your Emacs dies, if you
start a fresh Emacs and type M-x mail, it will not offer to restore the
previous message.  You can also duplicate this by typing M-x mail,
typing a few characters, killing the *mail* buffer and then typing M-x
mail again (we're running 18.52).

I was suggesting that Emacs know about the *mail* checkpoint file (just
like it knows about other checkpoint files).

Thanks,

-- Ashwin.