Subject: Re: bug#38993: 26.3; EBDB saves the database on Emacs exit even when told not to

From: Eric Abrahamsen <[email-masked]>
Date: Tue, 07 Jan 2020 10:42:55 -0800

Jorge P. de Morais Neto <[email-masked]> writes:

> Em [2020-01-06 seg 13:33:55-0800], Eric Abrahamsen escreveu:
>
>> I suppose I could have it do that (prompt for saving) rather than
>> saving silently.  I guess I just assumed that in most cases users
>> would want the database saved, rather than discarding changes.  I
>> don't have very strong feelings about it, though.
>
> In principle I want consistency with the rest of GNU Emacs.  IIRC, Emacs
> generally does not overwrite without asking.  There is the auto-save
> functionality, but it saves to *separate* files.  However I should
> disclaim that I have never studied human-machine interaction and I too
> do not have strong feelings about this.

Yes, I think consistency is the best thing to aim for. FWIW, what we're
talking about isn't auto-save (EBDB has its own mechanism for auto-save,
which is silent), but about behavior during `save-some-buffers'.

>> This is an error, either in Emacs or EBDB, I'm not sure. I originally
>> implemented the ability for special-mode buffers to offer themselves
>> as saveable, but the idea was that, if they saved themselves using
>> their own function, Emacs wouldn't then *also* save the buffer itself
>> in a file.
>>
>> Either my code in Emacs or my code in EBDB has a bug, I haven't gone
>> and figured out which.  I'll try to do that soon.
>
> Yes, by default Emacs should not ask to save the computer-generated
> "*EBDB*" buffer.  Regarding the database, I think that if
> `ebdb-save-on-exit' is nil then either:
> 1. Emacs should not ask to save the database on exit; or
> 2. The EBDB documentation should explicitly mention that Emacs will ask;
>    and the behavior should be altered so that, when the user answers no,
>    then Emacs should not save the database.

The problems is that, when you exit Emacs, it first runs
`save-some-buffers' -- which will prompt the user to possibly save the
database -- and then runs the `kill-emacs-hook'. So if you've said
"don't save" to the `save-some-buffers' prompt, the kill emacs hook
doesn't know that, and might save the database anyway.

To complicate things, the save-some-buffers prompt only runs if you have
live *EBDB* buffers. It's entirely possible to have a loaded database
with unsaved changes, but no buffers, in which case `save-some-buffers'
won't do anything at all.

Give me a bit to chew on this. I think I have a sense of the desired
behavior, it will just be a matter of getting to it.

> Oh, and thank you for this great package! Do you have a mechanism for
> accepting donations? I unfortunately would donate just a little at this
> moment, but I intend to donate more in the future when my financial
> situation improves and/or the Brazilian Real gains value against the US
> dollar.  Also, even very small donations may add up.

I'm glad it's useful to you! I hadn't really thought about donations, I
suppose it makes me a tiny bit uncomfortable. But I see Github has a
sponsorship thing, I suppose it wouldn't hurt to sign up!

Eric