Le lun. 14 sept. 2020 à 13:54, Robert Pluim a écrit : > >>>>> On Mon, 14 Sep 2020 09:53:28 +0200, Thibaut Verron < > thibaut.verron@gmail.com> said: > >> > >> We could set 'kill-buffer-hook' to a querying function in buffers > >> created via the toolbar. > >> > > Thibaut> There is already a (buffer-local) variable buffer-offer-save > which, set to > Thibaut> 'always, causes save-some-buffers to query for save the > corresponding > Thibaut> buffer, if non-empty. > > Right, but toolbar-save doesnʼt run save-some-buffers. That could be > added, but it seems people feel toolbar space is precious (here the > default toolbar uses slightly more than 50% of the available width > when running -Q) > The save button runs save-buffer, so it should DTRT already, no? > That covers the 'exiting emacs' scenario, weʼd still need something to > cover the 'clicked the kill-buffer button'. That's correct, I didn't have this usage in mind. Kill-buffer-hook seems to be more for cleanup, but kill-buffer-query-functions could do the job as a first step (as in, "do you really want to kill without saving?"). I believe that the most natural would be to add such a test to kill-buffer, since it already takes care of modified file buffers. All those approaches would also affect other commands killing the buffer, preventing a user from accidentally losing data because of an unfortunate keypress. Or if we really want to go > whole hog, we automatically save the state of buffers created via the > toolbar, and restore them on startup. > Restoring them as-is is what notepad++ does (or did when I last used it 10 years ago). I personally did not like this behavior, and I didn't have remotely as many open files in notepad++ as I do in a typical emacs session. On the other hand, auto-saving and offering to restore could be sensible.