Subject: Re: bug#28843: 26.0.90; gnus kills unsaved message buffer

From: Nick Helm <[email-masked]>
Date: Thu, 26 Oct 2017 13:52:13 +1300

On Sun, 15 Oct 2017 at 20:46:25 +1300, Nick Helm wrote:

> When gnus is the mail-user-agent, quitting gnus causes unsaved messages
> to be lost.
>
> Emacs -Q
> (setq mail-user-agent 'gnus-user-agent)
> M-x gnus
> C-x 5 m "xxx" ;make and modify a new message
> C-x 5 b "*Group*" ;back to gnus
> q, yes
>
> Gnus exits, and the unsaved message buffer dies with it, without prompts
> to save.

I got stung by this one again today, so I did a bit more looking into it.

It seems the behaviour is intentional (see bug#26862 and commit
4b35dd653d35ba95c4d304bee69b69d41301ec3b).

This commit changed `gnus-clear-system' to include this:

  #+begin_src emacs-lisp
  ;; Kill Gnus buffers.
  (do-auto-save t)
  (dolist (buffer (gnus-buffers))
    (when (gnus-buffer-exists-p buffer)
      (with-current-buffer buffer
  	   (set-buffer-modified-p nil)
  	   (when (local-variable-p 'kill-buffer-hook)
  	     (setq kill-buffer-hook nil))))
    (gnus-kill-buffer buffer))
  #+end_src

So gnus is at least auto-saving draft messages before zapping them.

Is there a better way to do this though? I think the user should at
least have some warning that an unsaved buffer is about to be
automatically killed.

Also, relying on auto-save means the next time I save a draft message
(either manually or automatically) it silently clobbers the previous
auto-save. At least that's what I see here. Only the latest draft is
retained.