* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
@ 2015-10-03 14:51 Marcus
2015-10-03 17:03 ` Eli Zaretskii
2021-08-16 12:36 ` Lars Ingebrigtsen
0 siblings, 2 replies; 28+ messages in thread
From: Marcus @ 2015-10-03 14:51 UTC (permalink / raw)
To: 21612
[-- Attachment #1: Type: text/plain, Size: 3902 bytes --]
Recipe for recreating:
Start Emacs: `emacs -Q'
Visit a file, e.g.: `C-x C-f RET test-file RET'.
Change the file, e.g.: `M-> Will this auto-save?'
Trigger auto-save, e.g. by idling for 30 seconds
Quit Emacs: `C-x C-c RET'
Don't save the file: `n yes RET'
Start Emacs again: `emacs -Q'
Visit the same file, e.g.: `C-x C-f RET test-file RET'
Message "test-file has auto save data; consider M-x recover-this-file"
appears.
Since the buffer was killed intentionally, shouldn't it be possible to
configure Emacs such that the auto save file will be deleted?
This might even be useful default behavior.
In GNU Emacs 24.5.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.16.6)
of 2015-09-10 on foutrelis
Windowing system distributor `The X.Org Foundation', version 11.0.11702000
System Description: Arch Linux
Configured using:
`configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
--localstatedir=/var --with-x-toolkit=gtk3 --with-xft
'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong
--param=ssp-buffer-size=4' CPPFLAGS=-D_FORTIFY_SOURCE=2
LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro'
Important settings:
value of $LANG: en_DK.UTF-8
locale-coding-system: utf-8-unix
Major mode: Info
Minor modes in effect:
shell-dirtrack-mode: t
evil-mode: t
global-undo-tree-mode: t
undo-tree-mode: t
evil-local-mode: t
tooltip-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
buffer-read-only: t
line-number-mode: t
transient-mark-mode: (only . t)
Recent messages:
Making completion list... [2 times]
user-error: Previous command was not evil-repeat: exit-minibuffer
byte-code: Beginning of line [2 times]
Making completion list... [3 times]
Type C-w C-o to delete the help window.
Making completion list... [4 times]
Making completion list...
Buffer is read-only: #<buffer *Help*>
call-interactively: Buffer is read-only: #<buffer *info*>
Load-path shadows:
None found.
Features:
(shadow sort gnus-util mail-extr jka-compr shell pcomplete comint
ansi-color emacsbug message idna format-spec rfc822 mml mml-sec
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr
mail-utils help-mode cus-edit cus-start cus-load wid-edit evil
evil-integration undo-tree diff evil-maps evil-commands
evil-command-window evil-types evil-search evil-ex evil-macros
evil-repeat evil-states evil-core advice help-fns evil-common windmove
thingatpt rect evil-digraphs evil-vars ring edmacro kmacro cl-loaddefs
cl-lib info easymenu package epg-config time-date tooltip electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list newcomment lisp-mode
prog-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
dbusbind gfilenotify dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)
Memory information:
((conses 16 174790 18817)
(symbols 48 25241 0)
(miscs 40 116 258)
(strings 32 34539 6257)
(string-bytes 1 914163)
(vectors 16 18967)
(vector-slots 8 478501 7318)
(floats 8 83 350)
(intervals 56 841 11)
(buffers 960 16)
(heap 1024 33073 1567))
[-- Attachment #2: Type: text/html, Size: 5247 bytes --]
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2015-10-03 14:51 bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer Marcus
@ 2015-10-03 17:03 ` Eli Zaretskii
2015-10-03 17:53 ` Marcus
2021-08-16 12:36 ` Lars Ingebrigtsen
1 sibling, 1 reply; 28+ messages in thread
From: Eli Zaretskii @ 2015-10-03 17:03 UTC (permalink / raw)
To: Marcus; +Cc: 21612
> Date: Sat, 3 Oct 2015 16:51:12 +0200
> From: Marcus <mrok4a@gmail.com>
>
> This might even be useful default behavior.
People sometimes answer YES by mistake.
I guess it could be OK as an option for people who like to live
dangerously.
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2015-10-03 17:03 ` Eli Zaretskii
@ 2015-10-03 17:53 ` Marcus
2015-10-03 18:00 ` Eli Zaretskii
0 siblings, 1 reply; 28+ messages in thread
From: Marcus @ 2015-10-03 17:53 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 21612
[-- Attachment #1: Type: text/plain, Size: 865 bytes --]
> On Sat, Oct 3, 2015 at 7:03 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> > Date: Sat, 3 Oct 2015 16:51:12 +0200
> > From: Marcus <mrok4a@gmail.com>
> >
> > This might even be useful default behavior.
> People sometimes answer YES by mistake.
Isn't that why the "Modified buffers exist" question is yes/no rather than
y/n?
> I guess it could be OK as an option for people who like to live
dangerously.
I do, and have so far implemented the functionality as (not with an option,
I don't know how):
(add-hook 'kill-buffer-hook 'delete-auto-save-file-if-necessary)
(add-hook 'kill-emacs-hook 'delete-auto-save-file-if-necessary)
If I figure out how to have this controlled by an option, where (and how)
would I send a patch request?
BTW, is my mailing list etiquette (formatting of replies etc.) acceptable?
This is my first bug report to a free software project.
[-- Attachment #2: Type: text/html, Size: 1552 bytes --]
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2015-10-03 17:53 ` Marcus
@ 2015-10-03 18:00 ` Eli Zaretskii
0 siblings, 0 replies; 28+ messages in thread
From: Eli Zaretskii @ 2015-10-03 18:00 UTC (permalink / raw)
To: Marcus; +Cc: 21612
> Date: Sat, 3 Oct 2015 19:53:05 +0200
> From: Marcus <mrok4a@gmail.com>
> Cc: 21612@debbugs.gnu.org
>
> > > This might even be useful default behavior.
> > People sometimes answer YES by mistake.
>
> Isn't that why the "Modified buffers exist" question is yes/no rather than y/n?
Yes, but with minibuffer history, it's easy to type "<up> RET"
thinking the previous reply was "no".
> If I figure out how to have this controlled by an option, where (and how) would
> I send a patch request?
Please send it here, and please accompany it with a ChangeLog entry.
> BTW, is my mailing list etiquette (formatting of replies etc.) acceptable?
I see no problems with it.
Thanks.
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2015-10-03 14:51 bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer Marcus
2015-10-03 17:03 ` Eli Zaretskii
@ 2021-08-16 12:36 ` Lars Ingebrigtsen
2021-08-16 13:06 ` Eli Zaretskii
1 sibling, 1 reply; 28+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-16 12:36 UTC (permalink / raw)
To: Marcus; +Cc: 21612
Marcus <mrok4a@gmail.com> writes:
> Recipe for recreating:
> Start Emacs: `emacs -Q'
> Visit a file, e.g.: `C-x C-f RET test-file RET'.
> Change the file, e.g.: `M-> Will this auto-save?'
> Trigger auto-save, e.g. by idling for 30 seconds
> Quit Emacs: `C-x C-c RET'
> Don't save the file: `n yes RET'
> Start Emacs again: `emacs -Q'
> Visit the same file, e.g.: `C-x C-f RET test-file RET'
> Message "test-file has auto save data; consider M-x recover-this-file"
> appears.
>
> Since the buffer was killed intentionally, shouldn't it be possible to
> configure Emacs such that the auto save file will be deleted?
I think that sounds like a reasonable feature -- I can see people
getting annoyed at Emacs' behaviour here. Perhaps the way to implement
this would be to:
Quit Emacs: `C-x C-c RET'
Save file: `n'
Delete auto-save file?: `yes RET'
That is, introduce a new option that would offer to delete auto-save
files for buffers the user chooses not to save. This could even be done
generally -- not just during shutdown -- afer the
Buffer foo modified; kill anyway? yes RET
dialogue. (This would be an opt-in user option, of course, because the
current behaviour is safer.)
Any opinions?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2021-08-16 12:36 ` Lars Ingebrigtsen
@ 2021-08-16 13:06 ` Eli Zaretskii
2021-08-16 13:52 ` Lars Ingebrigtsen
0 siblings, 1 reply; 28+ messages in thread
From: Eli Zaretskii @ 2021-08-16 13:06 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: mrok4a, 21612
> From: Lars Ingebrigtsen <larsi@gnus.org>
> Date: Mon, 16 Aug 2021 14:36:40 +0200
> Cc: 21612@debbugs.gnu.org
>
> > Since the buffer was killed intentionally, shouldn't it be possible to
> > configure Emacs such that the auto save file will be deleted?
>
> I think that sounds like a reasonable feature -- I can see people
> getting annoyed at Emacs' behaviour here. Perhaps the way to implement
> this would be to:
>
> Quit Emacs: `C-x C-c RET'
> Save file: `n'
> Delete auto-save file?: `yes RET'
>
> That is, introduce a new option that would offer to delete auto-save
> files for buffers the user chooses not to save. This could even be done
> generally -- not just during shutdown -- afer the
>
> Buffer foo modified; kill anyway? yes RET
>
> dialogue. (This would be an opt-in user option, of course, because the
> current behaviour is safer.)
>
> Any opinions?
We all know that people sometimes react to questions without thinking,
so if the user says YES to the question whether to delete auto-save
files, it could be a second before OOPS!
So I think it's okay to have such a feature, but:
. it should be OFF by default; and
. it should NOT by default ask the additional question
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2021-08-16 13:06 ` Eli Zaretskii
@ 2021-08-16 13:52 ` Lars Ingebrigtsen
2021-08-16 14:10 ` Eli Zaretskii
0 siblings, 1 reply; 28+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-16 13:52 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: mrok4a, 21612
Eli Zaretskii <eliz@gnu.org> writes:
> So I think it's okay to have such a feature, but:
>
> . it should be OFF by default; and
> . it should NOT by default ask the additional question
So just delete the auto-save files automatically if you have the option
switched on and you're killing an unsaved buffer?
I think this sounds too dramatic to be useful, even as an option.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2021-08-16 13:52 ` Lars Ingebrigtsen
@ 2021-08-16 14:10 ` Eli Zaretskii
2021-08-16 18:48 ` Lars Ingebrigtsen
2021-08-18 12:45 ` Lars Ingebrigtsen
0 siblings, 2 replies; 28+ messages in thread
From: Eli Zaretskii @ 2021-08-16 14:10 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: mrok4a, 21612
> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: mrok4a@gmail.com, 21612@debbugs.gnu.org
> Date: Mon, 16 Aug 2021 15:52:15 +0200
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> > So I think it's okay to have such a feature, but:
> >
> > . it should be OFF by default; and
> > . it should NOT by default ask the additional question
>
> So just delete the auto-save files automatically if you have the option
> switched on and you're killing an unsaved buffer?
>
> I think this sounds too dramatic to be useful, even as an option.
When the option is switched ON, I'm okay with asking the question. I
just don't think we should ask it when the option is OFF.
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2021-08-16 14:10 ` Eli Zaretskii
@ 2021-08-16 18:48 ` Lars Ingebrigtsen
2021-08-18 12:45 ` Lars Ingebrigtsen
1 sibling, 0 replies; 28+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-16 18:48 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: mrok4a, 21612
Eli Zaretskii <eliz@gnu.org> writes:
> When the option is switched ON, I'm okay with asking the question. I
> just don't think we should ask it when the option is OFF.
Oh, yes, then we're in full agreement. :-)
I'll take a stab at implementing this tomorrowish.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2021-08-16 14:10 ` Eli Zaretskii
2021-08-16 18:48 ` Lars Ingebrigtsen
@ 2021-08-18 12:45 ` Lars Ingebrigtsen
2021-08-18 13:34 ` Eli Zaretskii
1 sibling, 1 reply; 28+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-18 12:45 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 21612, mrok4a, Richard M. Stallman
Argh!
I now implemented this... but then I discovered the
delete-auto-save-files variable, which seems to be providing just what
was requested here, just about.
And it worked in the initial revision:
commit 1ab256cb9997cf15983abc63310cdf32f0533bca
Author: Roland McGrath <roland@gnu.org>
AuthorDate: Mon Jul 15 21:27:11 1991 +0000
Initial revision
diff --git a/src/buffer.c b/src/buffer.c
--- /dev/null
+++ b/src/buffer.c
@@ -0,0 +678,9 @@
+ /* Delete any auto-save file. */
+ if (XTYPE (b->auto_save_file_name) == Lisp_String)
+ {
+ Lisp_Object tem;
+ tem = Fsymbol_value (intern ("delete-auto-save-files"));
+ if (! NULL (tem))
+ unlink (XSTRING (b->auto_save_file_name)->data);
+ }
+
But Richard changed this in 2001:
commit 9cf712eb57c0a1fef56487508e89d08c91f98db1
Author: Richard M. Stallman <rms@gnu.org>
AuthorDate: Tue Nov 6 04:48:15 2001 +0000
(Fkill_buffer): Don't delete auto save file if buffer is modified.
diff --git a/src/buffer.c b/src/buffer.c
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1370,11 +1370,13 @@
- /* Delete any auto-save file, if we saved it in this session. */
+ /* Delete any auto-save file, if we saved it in this session.
+ But not if the buffer is modified. */
if (STRINGP (b->auto_save_file_name)
&& b->auto_save_modified != 0
- && BUF_SAVE_MODIFF (b) < b->auto_save_modified)
+ && BUF_SAVE_MODIFF (b) < b->auto_save_modified
+ && BUF_SAVE_MODIFF (b) < BUF_MODIFF (b))
{
Lisp_Object tem;
tem = Fsymbol_value (intern ("delete-auto-save-files"));
if (! NILP (tem))
internal_delete_file (b->auto_save_file_name);
}
No now this option is basically pointless (when killing buffers) -- the
only reason we'd want to delete an auto-save file is if the buffer is
modified. Otherwise there won't be an auto-save file. (Except when
it's made by a different Emacs, and in that case, we really shouldn't be
deleting it anyway.)
The commit message or the comments don't explain what the reasoning
behind changing the semantics here were.
Richard, do you have any recollection why you made these changes 20
years ago? They seem to make the delete-auto-save-files variable in a
kill-buffer context pointless.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2021-08-18 12:45 ` Lars Ingebrigtsen
@ 2021-08-18 13:34 ` Eli Zaretskii
2021-08-18 13:38 ` Lars Ingebrigtsen
0 siblings, 1 reply; 28+ messages in thread
From: Eli Zaretskii @ 2021-08-18 13:34 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 21612, mrok4a, rms
> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: mrok4a@gmail.com, 21612@debbugs.gnu.org, Richard M. Stallman <rms@gnu.org>
> Date: Wed, 18 Aug 2021 14:45:21 +0200
>
> diff --git a/src/buffer.c b/src/buffer.c
> --- a/src/buffer.c
> +++ b/src/buffer.c
> @@ -1370,11 +1370,13 @@
> - /* Delete any auto-save file, if we saved it in this session. */
> + /* Delete any auto-save file, if we saved it in this session.
> + But not if the buffer is modified. */
> if (STRINGP (b->auto_save_file_name)
> && b->auto_save_modified != 0
> - && BUF_SAVE_MODIFF (b) < b->auto_save_modified)
> + && BUF_SAVE_MODIFF (b) < b->auto_save_modified
> + && BUF_SAVE_MODIFF (b) < BUF_MODIFF (b))
> {
> Lisp_Object tem;
> tem = Fsymbol_value (intern ("delete-auto-save-files"));
> if (! NILP (tem))
> internal_delete_file (b->auto_save_file_name);
> }
>
> No now this option is basically pointless (when killing buffers) -- the
> only reason we'd want to delete an auto-save file is if the buffer is
> modified. Otherwise there won't be an auto-save file. (Except when
> it's made by a different Emacs, and in that case, we really shouldn't be
> deleting it anyway.)
We could make that variable have a third value, which would then
override the above logic, no?
> The commit message or the comments don't explain what the reasoning
> behind changing the semantics here were.
>
> Richard, do you have any recollection why you made these changes 20
> years ago? They seem to make the delete-auto-save-files variable in a
> kill-buffer context pointless.
I guess the reason was the fear of losing edits, as discussed
previously. But if the user explicitly wants to take those risks,
it's okay, especially if we ask for confirmation.
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2021-08-18 13:34 ` Eli Zaretskii
@ 2021-08-18 13:38 ` Lars Ingebrigtsen
2021-08-18 13:48 ` Eli Zaretskii
0 siblings, 1 reply; 28+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-18 13:38 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 21612, mrok4a, rms
Eli Zaretskii <eliz@gnu.org> writes:
> We could make that variable have a third value, which would then
> override the above logic, no?
I think it would make more sense to have the non-nil value query the
user first in this case (and not delete auto-save files produced by
other Emacsen, because that's pretty odd).
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2021-08-18 13:38 ` Lars Ingebrigtsen
@ 2021-08-18 13:48 ` Eli Zaretskii
2021-08-18 14:31 ` Lars Ingebrigtsen
0 siblings, 1 reply; 28+ messages in thread
From: Eli Zaretskii @ 2021-08-18 13:48 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 21612, mrok4a, rms
> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: mrok4a@gmail.com, 21612@debbugs.gnu.org, rms@gnu.org
> Date: Wed, 18 Aug 2021 15:38:11 +0200
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> > We could make that variable have a third value, which would then
> > override the above logic, no?
>
> I think it would make more sense to have the non-nil value query the
> user first in this case
But that would exactly do what I asked not to do, and you agreed: ask
that question by default. Because the default value of the variable
is non-nil...
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2021-08-18 13:48 ` Eli Zaretskii
@ 2021-08-18 14:31 ` Lars Ingebrigtsen
2021-08-18 16:13 ` Eli Zaretskii
0 siblings, 1 reply; 28+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-18 14:31 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 21612, mrok4a, rms
Eli Zaretskii <eliz@gnu.org> writes:
> But that would exactly do what I asked not to do, and you agreed: ask
> that question by default. Because the default value of the variable
> is non-nil...
Oh yeah, I'd forgotten that it was t by default.
Hm...
/* Delete any auto-save file, if we saved it in this session.
But not if the buffer is modified. */
if (STRINGP (BVAR (b, auto_save_file_name))
&& BUF_AUTOSAVE_MODIFF (b) != 0
&& BUF_SAVE_MODIFF (b) < BUF_AUTOSAVE_MODIFF (b)
&& BUF_SAVE_MODIFF (b) < BUF_MODIFF (b)
&& NILP (Fsymbol_value (intern ("auto-save-visited-file-name"))))
{
Lisp_Object delete;
delete = Fsymbol_value (intern ("delete-auto-save-files"));
if (! NILP (delete))
internal_delete_file (BVAR (b, auto_save_file_name));
}
Actually, I'm not sure that my first reading of this code was correct.
Will this code ever trigger a file deletion?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2021-08-18 14:31 ` Lars Ingebrigtsen
@ 2021-08-18 16:13 ` Eli Zaretskii
2021-08-18 16:41 ` Lars Ingebrigtsen
0 siblings, 1 reply; 28+ messages in thread
From: Eli Zaretskii @ 2021-08-18 16:13 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 21612, mrok4a, rms
> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: mrok4a@gmail.com, 21612@debbugs.gnu.org, rms@gnu.org
> Date: Wed, 18 Aug 2021 16:31:49 +0200
>
> Actually, I'm not sure that my first reading of this code was correct.
> Will this code ever trigger a file deletion?
Why not?
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2021-08-18 16:13 ` Eli Zaretskii
@ 2021-08-18 16:41 ` Lars Ingebrigtsen
2021-08-18 16:44 ` Eli Zaretskii
0 siblings, 1 reply; 28+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-18 16:41 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 21612, mrok4a, rms
Eli Zaretskii <eliz@gnu.org> writes:
>> Actually, I'm not sure that my first reading of this code was correct.
>> Will this code ever trigger a file deletion?
>
> Why not?
Under which conditions will it delete anything? Hm... well, I guess if
you set the buffer to non-modified manually and then kills it, it'll
delete the auto-save file?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2021-08-18 16:41 ` Lars Ingebrigtsen
@ 2021-08-18 16:44 ` Eli Zaretskii
2021-08-19 13:05 ` Lars Ingebrigtsen
0 siblings, 1 reply; 28+ messages in thread
From: Eli Zaretskii @ 2021-08-18 16:44 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 21612, mrok4a, rms
> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: mrok4a@gmail.com, 21612@debbugs.gnu.org, rms@gnu.org
> Date: Wed, 18 Aug 2021 18:41:36 +0200
>
> Under which conditions will it delete anything? Hm... well, I guess if
> you set the buffer to non-modified manually and then kills it, it'll
> delete the auto-save file?
Yes. Or any other command that resets the modified status without
also deleting the auto-save file.
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2021-08-18 16:44 ` Eli Zaretskii
@ 2021-08-19 13:05 ` Lars Ingebrigtsen
2021-08-20 6:23 ` Eli Zaretskii
0 siblings, 1 reply; 28+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-19 13:05 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 21612, mrok4a, rms
Eli Zaretskii <eliz@gnu.org> writes:
>> Under which conditions will it delete anything? Hm... well, I guess if
>> you set the buffer to non-modified manually and then kills it, it'll
>> delete the auto-save file?
>
> Yes. Or any other command that resets the modified status without
> also deleting the auto-save file.
Are there any other commands that do this?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2021-08-19 13:05 ` Lars Ingebrigtsen
@ 2021-08-20 6:23 ` Eli Zaretskii
2021-08-20 13:29 ` Lars Ingebrigtsen
0 siblings, 1 reply; 28+ messages in thread
From: Eli Zaretskii @ 2021-08-20 6:23 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 21612, mrok4a, rms
> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: mrok4a@gmail.com, 21612@debbugs.gnu.org, rms@gnu.org
> Date: Thu, 19 Aug 2021 15:05:34 +0200
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> >> Under which conditions will it delete anything? Hm... well, I guess if
> >> you set the buffer to non-modified manually and then kills it, it'll
> >> delete the auto-save file?
> >
> > Yes. Or any other command that resets the modified status without
> > also deleting the auto-save file.
>
> Are there any other commands that do this?
I don't really know of any specific ones, but where there's one, there
could be others.
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2021-08-20 6:23 ` Eli Zaretskii
@ 2021-08-20 13:29 ` Lars Ingebrigtsen
2021-08-22 9:29 ` Eli Zaretskii
0 siblings, 1 reply; 28+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-20 13:29 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 21612, mrok4a, rms
Eli Zaretskii <eliz@gnu.org> writes:
>> >> Under which conditions will it delete anything? Hm... well, I guess if
>> >> you set the buffer to non-modified manually and then kills it, it'll
>> >> delete the auto-save file?
>> >
>> > Yes. Or any other command that resets the modified status without
>> > also deleting the auto-save file.
>>
>> Are there any other commands that do this?
>
> I don't really know of any specific ones, but where there's one, there
> could be others.
I actually tried this instead of making sense of the code, and:
emacs -Q /tmp/foo
insert bar
M-x do-auto-save
M-x not-modified
C-x k RET
The auto-save file is not deleted.
So I'm back to my second interpretation of the code -- I don't
understand under what condition it's actually triggered (if any).
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2021-08-20 13:29 ` Lars Ingebrigtsen
@ 2021-08-22 9:29 ` Eli Zaretskii
2021-08-22 21:55 ` Lars Ingebrigtsen
0 siblings, 1 reply; 28+ messages in thread
From: Eli Zaretskii @ 2021-08-22 9:29 UTC (permalink / raw)
To: Lars Ingebrigtsen, Stefan Monnier; +Cc: 21612, mrok4a, rms
> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: mrok4a@gmail.com, 21612@debbugs.gnu.org, rms@gnu.org
> Date: Fri, 20 Aug 2021 15:29:01 +0200
>
> I actually tried this instead of making sense of the code, and:
>
> emacs -Q /tmp/foo
> insert bar
> M-x do-auto-save
> M-x not-modified
> C-x k RET
>
> The auto-save file is not deleted.
>
> So I'm back to my second interpretation of the code -- I don't
> understand under what condition it's actually triggered (if any).
First, there seems to be an obvious logic bug there:
/* Delete any auto-save file, if we saved it in this session.
But not if the buffer is modified. */
if (STRINGP (BVAR (b, auto_save_file_name))
&& BUF_AUTOSAVE_MODIFF (b) != 0
&& BUF_SAVE_MODIFF (b) < BUF_AUTOSAVE_MODIFF (b)
&& BUF_SAVE_MODIFF (b) < BUF_MODIFF (b) <<<<<<<<<<<<<<<<<<<<<<<<<<
&& NILP (Fsymbol_value (intern ("auto-save-visited-file-name"))))
{
Lisp_Object delete;
delete = Fsymbol_value (intern ("delete-auto-save-files"));
if (! NILP (delete))
internal_delete_file (BVAR (b, auto_save_file_name));
}
The condition I emphasized above should be reversed, because it means
the buffer _is_ modified, whereas according to the comment we need to
test that it _isn't_. Right?
And second, I think the condition before it should be changed to say
&& BUF_SAVE_MODIFF (b) <= BUF_AUTOSAVE_MODIFF (b)
I see no reason to reject the situation where the two are equal. Come
to think of this, I don't see why we need this last condition at all.
In its current form it means that the buffer was auto-saved since the
last save, but if it was auto-saved _before_ the last save, it means
the auto-save file is even less important to keep, right? So maybe we
should remove that condition.
Adding Stefan, who considered this stuff 11 years ago. Stefan, any
comments?
(There's also bug#5314 that's related to this.)
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2021-08-22 9:29 ` Eli Zaretskii
@ 2021-08-22 21:55 ` Lars Ingebrigtsen
2021-08-23 12:21 ` Eli Zaretskii
0 siblings, 1 reply; 28+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-22 21:55 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: mrok4a, 21612, rms, Stefan Monnier
Eli Zaretskii <eliz@gnu.org> writes:
> The condition I emphasized above should be reversed, because it means
> the buffer _is_ modified, whereas according to the comment we need to
> test that it _isn't_. Right?
I... think so.
> And second, I think the condition before it should be changed to say
>
> && BUF_SAVE_MODIFF (b) <= BUF_AUTOSAVE_MODIFF (b)
>
> I see no reason to reject the situation where the two are equal. Come
> to think of this, I don't see why we need this last condition at all.
Me neither.
Since this code (in its current state) seems to mean that we never
delete auto-save files when killing buffers, I think we should change
the documented effect of `delete-auto-save-files' to be what it does
now:
----
Non-nil means delete auto-save file when a buffer is saved.
----
Then delete the bit in `kill-buffer' that tries to act on that variable,
and then introduce the new variable previously discussed in this bug
report.
The two things (deleting auto-save file when saving a file and killing a
buffer) do not seem to be very related functionality, so having one
variable for both things is just confusing.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2021-08-22 21:55 ` Lars Ingebrigtsen
@ 2021-08-23 12:21 ` Eli Zaretskii
2021-08-23 13:58 ` Lars Ingebrigtsen
0 siblings, 1 reply; 28+ messages in thread
From: Eli Zaretskii @ 2021-08-23 12:21 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: mrok4a, 21612, rms, monnier
> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: Stefan Monnier <monnier@iro.umontreal.ca>, mrok4a@gmail.com,
> 21612@debbugs.gnu.org, rms@gnu.org
> Date: Sun, 22 Aug 2021 23:55:05 +0200
>
> Since this code (in its current state) seems to mean that we never
> delete auto-save files when killing buffers, I think we should change
> the documented effect of `delete-auto-save-files' to be what it does
> now:
>
> ----
> Non-nil means delete auto-save file when a buffer is saved.
> ----
I wouldn't do that, because I think there could be situations where we
do delete auto-save files in other cases. The code says: delete if
the file was auto-saved during this session, was auto-saved after
being saved, and was modified after being saved. That's not what we
want, but I don't think it's impossible to have that.
> Then delete the bit in `kill-buffer' that tries to act on that variable,
> and then introduce the new variable previously discussed in this bug
> report.
>
> The two things (deleting auto-save file when saving a file and killing a
> buffer) do not seem to be very related functionality, so having one
> variable for both things is just confusing.
We could have 2 variables, yes.
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2021-08-23 12:21 ` Eli Zaretskii
@ 2021-08-23 13:58 ` Lars Ingebrigtsen
2021-08-23 16:24 ` Eli Zaretskii
0 siblings, 1 reply; 28+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-23 13:58 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: mrok4a, 21612, rms, monnier
Eli Zaretskii <eliz@gnu.org> writes:
>> ----
>> Non-nil means delete auto-save file when a buffer is saved.
>> ----
>
> I wouldn't do that, because I think there could be situations where we
> do delete auto-save files in other cases. The code says: delete if
> the file was auto-saved during this session, was auto-saved after
> being saved, and was modified after being saved. That's not what we
> want, but I don't think it's impossible to have that.
As you say, it's not what we want... and I don't think anybody would
want that...
>> Then delete the bit in `kill-buffer' that tries to act on that variable,
>> and then introduce the new variable previously discussed in this bug
>> report.
>>
>> The two things (deleting auto-save file when saving a file and killing a
>> buffer) do not seem to be very related functionality, so having one
>> variable for both things is just confusing.
>
> We could have 2 variables, yes.
... so I've pushed the two-variable solution now.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2021-08-23 13:58 ` Lars Ingebrigtsen
@ 2021-08-23 16:24 ` Eli Zaretskii
2021-08-23 16:40 ` Lars Ingebrigtsen
0 siblings, 1 reply; 28+ messages in thread
From: Eli Zaretskii @ 2021-08-23 16:24 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: mrok4a, 21612, rms, monnier
> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: monnier@iro.umontreal.ca, mrok4a@gmail.com, 21612@debbugs.gnu.org,
> rms@gnu.org
> Date: Mon, 23 Aug 2021 15:58:54 +0200
>
> >> The two things (deleting auto-save file when saving a file and killing a
> >> buffer) do not seem to be very related functionality, so having one
> >> variable for both things is just confusing.
> >
> > We could have 2 variables, yes.
>
> ... so I've pushed the two-variable solution now.
Hmm... bother. If the new variable kill-buffer-delete-auto-save-files
is non-nil, we ask the user even if we eventually don't delete the
auto-save file, for example if auto-save-visited-mode is in effect.
Is that TRT?
Also, I'd bet people would like to be able to delete them without any
questions asked, so maybe the variable should be a tristate, not a
boolean?
Thanks.
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2021-08-23 16:24 ` Eli Zaretskii
@ 2021-08-23 16:40 ` Lars Ingebrigtsen
2021-08-23 18:57 ` Eli Zaretskii
0 siblings, 1 reply; 28+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-23 16:40 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: mrok4a, 21612, rms, monnier
Eli Zaretskii <eliz@gnu.org> writes:
> Hmm... bother. If the new variable kill-buffer-delete-auto-save-files
> is non-nil, we ask the user even if we eventually don't delete the
> auto-save file, for example if auto-save-visited-mode is in effect.
> Is that TRT?
If that's the case, it's a bug. I'll have a look at this tomorrow.
(Hm... and the code should check whether the auto-save file actually
exists, not just `recent-auto-save-p' -- the user may have deleted the
auto-save file manually.)
> Also, I'd bet people would like to be able to delete them without any
> questions asked, so maybe the variable should be a tristate, not a
> boolean?
I think that's too dangerous, really, so I'd rather not. But if others
feel strongly that that should be a feature, I wouldn't oppose it.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2021-08-23 16:40 ` Lars Ingebrigtsen
@ 2021-08-23 18:57 ` Eli Zaretskii
2021-08-25 9:58 ` Lars Ingebrigtsen
0 siblings, 1 reply; 28+ messages in thread
From: Eli Zaretskii @ 2021-08-23 18:57 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: mrok4a, 21612, rms, monnier
> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: monnier@iro.umontreal.ca, mrok4a@gmail.com, 21612@debbugs.gnu.org,
> rms@gnu.org
> Date: Mon, 23 Aug 2021 18:40:40 +0200
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> > Hmm... bother. If the new variable kill-buffer-delete-auto-save-files
> > is non-nil, we ask the user even if we eventually don't delete the
> > auto-save file, for example if auto-save-visited-mode is in effect.
> > Is that TRT?
>
> If that's the case, it's a bug. I'll have a look at this tomorrow.
Actually, if auto-save-visited-mode is on, the buffer will not be
modified after auto-saving. But the general concern is still there:
we ask the question before we decide whether to delete, which I think
could cause trouble some day.
> > Also, I'd bet people would like to be able to delete them without any
> > questions asked, so maybe the variable should be a tristate, not a
> > boolean?
>
> I think that's too dangerous, really, so I'd rather not. But if others
> feel strongly that that should be a feature, I wouldn't oppose it.
Fair enough.
^ permalink raw reply [flat|nested] 28+ messages in thread
* bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer
2021-08-23 18:57 ` Eli Zaretskii
@ 2021-08-25 9:58 ` Lars Ingebrigtsen
0 siblings, 0 replies; 28+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-25 9:58 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: mrok4a, 21612, rms, monnier
Eli Zaretskii <eliz@gnu.org> writes:
> Actually, if auto-save-visited-mode is on, the buffer will not be
> modified after auto-saving. But the general concern is still there:
> we ask the question before we decide whether to delete, which I think
> could cause trouble some day.
Now fixed.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 28+ messages in thread
end of thread, other threads:[~2021-08-25 9:58 UTC | newest]
Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-03 14:51 bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer Marcus
2015-10-03 17:03 ` Eli Zaretskii
2015-10-03 17:53 ` Marcus
2015-10-03 18:00 ` Eli Zaretskii
2021-08-16 12:36 ` Lars Ingebrigtsen
2021-08-16 13:06 ` Eli Zaretskii
2021-08-16 13:52 ` Lars Ingebrigtsen
2021-08-16 14:10 ` Eli Zaretskii
2021-08-16 18:48 ` Lars Ingebrigtsen
2021-08-18 12:45 ` Lars Ingebrigtsen
2021-08-18 13:34 ` Eli Zaretskii
2021-08-18 13:38 ` Lars Ingebrigtsen
2021-08-18 13:48 ` Eli Zaretskii
2021-08-18 14:31 ` Lars Ingebrigtsen
2021-08-18 16:13 ` Eli Zaretskii
2021-08-18 16:41 ` Lars Ingebrigtsen
2021-08-18 16:44 ` Eli Zaretskii
2021-08-19 13:05 ` Lars Ingebrigtsen
2021-08-20 6:23 ` Eli Zaretskii
2021-08-20 13:29 ` Lars Ingebrigtsen
2021-08-22 9:29 ` Eli Zaretskii
2021-08-22 21:55 ` Lars Ingebrigtsen
2021-08-23 12:21 ` Eli Zaretskii
2021-08-23 13:58 ` Lars Ingebrigtsen
2021-08-23 16:24 ` Eli Zaretskii
2021-08-23 16:40 ` Lars Ingebrigtsen
2021-08-23 18:57 ` Eli Zaretskii
2021-08-25 9:58 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.