bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#28843: 26.0.90; gnus kills unsaved message buffer


From: Eric Abrahamsen
Subject: bug#28843: 26.0.90; gnus kills unsaved message buffer
Date: Wed, 08 Nov 2017 08:22:58 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux)

Nick Helm <address@hidden> writes:

> On Tue,  7 Nov 2017 at 18:41:24 -0800, Eric Abrahamsen wrote:
>
>> Nick Helm <address@hidden> writes:
>>
>>> On Thu, 26 Oct 2017 at 13:52:13 +1300, Nick Helm wrote:
>>>
>>>> On Sun, 15 Oct 2017 at 20:46:25 +1300, Nick Helm wrote:
>>>>
>>>>> Gnus exits, and the unsaved message buffer dies with it, without prompts
>>>>> to save.
>>>>
>>>> It seems the behaviour is intentional ... 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.
>>>
>>> One solution (though not a very good one IMHO) would be to make the
>>> auto-save depend on the user's value of guns-interactive-exit. For
>>> example:
>>>
>>> --- a/lisp/gnus/gnus-start.el       2017-10-26 12:49:43.000000000 +1300
>>> +++ b/lisp/gnus/gnus-start.el       2017-10-26 12:45:12.000000000 +1300
>>> @@ -731,11 +731,12 @@
>>>      (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
>>>    (gnus-kill-buffer nntp-server-buffer)
>>>    ;; 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)
>>> +        (unless gnus-interactive-exit
>>> +          (do-auto-save t t)
>>> +   (set-buffer-modified-p nil))
>>>     (when (local-variable-p 'kill-buffer-hook)
>>>       (setq kill-buffer-hook nil))))
>>>      (gnus-kill-buffer buffer))
>>
>> We could also consider mirroring the behavior of Emacs itself: if
>> `gnus-interactive-exit' is non-nil, prompt the user whether to save
>> changed buffers or not.
>
> Yes, that would be better. 
>
> One way to do that might be to kill unsaved message buffers earlier in
> the gnus exit process, say with `gnus-exit-gnus-hook', and rely on
> Emacs's standard unsaved buffer query to do `save-buffer' or
> `message-dont-send'. Gnus is still running at that point, so it should
> save to the drafts group just fine.

I guess it might be better to create an explicit function to do this. If
you look at `gnus-group-exit' versus `gnus-group-quit', the former calls
`gnus-offer-save-summaries' while the latter does not. I think the
offer-save-summaries situation is analogous to draft saving: ie, "group
quit" is expected to discard data; "group exit" is not.

For extra safety we could check `gnus-expert-user' and, if it's nil,
prompt anyway.

If the function were called a bit earlier, the prompt could also allow a
key saying "whoops, I didn't want to quit after all", which would abort
the process.

> Also, the doc for `message-dont-send' says it does an auto-save, but the
> code says it actually does `save-buffer'. 

I think that's just poor doc wording -- obviously we can't actually call
`do-auto-save' there, I think this "auto-save" just shorthand for
"automatically save".






reply via email to

[Prev in Thread] Current Thread [Next in Thread]