GNU bug report logs - #66181
Subject: 29.1; Occur changes don't affect Dired buffer

Previous Next

Package: emacs;

Reported by: Maske <kediez <at> gmail.com>

Date: Sun, 24 Sep 2023 14:52:01 UTC

Severity: normal

Tags: confirmed

To reply to this bug, email your comments to 66181 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#66181; Package emacs. (Sun, 24 Sep 2023 14:52:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Maske <kediez <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 24 Sep 2023 14:52:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Maske <kediez <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Subject: 29.1; Occur changes don't affect Dired buffer
Date: Sun, 24 Sep 2023 13:32:04 +0200
[Message part 1 (text/plain, inline)]
I read a post, where Occur is used to edit a Dired buffer. Well, it
doesn't work:

- Tested in emacs -q
- Make Dired buffer writable
- Launch Occur
- Make Occur buffer editable
- Make changes in Occur buffer
- Changes are not saved in Dired buffer.

The mentioned post: https://emacs.ch/@ramin_hal9001/110933437057616428

[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66181; Package emacs. (Sun, 24 Sep 2023 18:02:01 GMT) Full text and rfc822 format available.

Message #8 received at 66181 <at> debbugs.gnu.org (full text, mbox):

From: Garjola Dindi <garjola <at> garjola.net>
To: 66181 <at> debbugs.gnu.org
Cc: Maske <kediez <at> gmail.com>
Subject: Re: bug#66181: Subject: 29.1; Occur changes don't affect Dired buffer
Date: Sun, 24 Sep 2023 18:21:03 +0200
On Sun 24-Sep-2023 at 13:32:04 +02, Maske <kediez <at> gmail.com> wrote: 
> I read a post, where Occur is used to edit a Dired buffer. Well, it
> doesn't work:
>
> - Tested in emacs -q
> - Make Dired buffer writable
> - Launch Occur
> - Make Occur buffer editable
> - Make changes in Occur buffer
> - Changes are not saved in Dired buffer.
>
> The mentioned post: https://emacs.ch/@ramin_hal9001/110933437057616428


Confirmed with GNU Emacs 30.0.50 (build 7, x86_64-pc-linux-gnu, GTK+ Version 3.24.37, cairo version 1.16.0) of 2023-09-16





Added tag(s) confirmed. Request was from Garjola Dindi <garjola <at> garjola.net> to control <at> debbugs.gnu.org. (Sun, 24 Sep 2023 18:02:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66181; Package emacs. (Mon, 25 Sep 2023 07:31:02 GMT) Full text and rfc822 format available.

Message #13 received at 66181 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Maske <kediez <at> gmail.com>
Cc: 66181 <at> debbugs.gnu.org
Subject: Re: bug#66181: Subject: 29.1; Occur changes don't affect Dired buffer
Date: Mon, 25 Sep 2023 10:29:17 +0300
> From: Maske <kediez <at> gmail.com>
> Date: Sun, 24 Sep 2023 13:32:04 +0200
> 
> I read a post, where Occur is used to edit a Dired buffer. Well, it
> doesn't work:
> 
> - Tested in emacs -q
> - Make Dired buffer writable
> - Launch Occur
> - Make Occur buffer editable
> - Make changes in Occur buffer
> - Changes are not saved in Dired buffer.

The last item is inaccurate.  The changes in the Occur buffer _are_
reflected in the Dired buffer, but typing "C-c C-c" in the Dired
buffer doesn't commit the changes to disk; instead it says "No changes
to be performed" and reverts to the previous display of Dired.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66181; Package emacs. (Mon, 25 Sep 2023 08:44:01 GMT) Full text and rfc822 format available.

Message #16 received at 66181 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: kediez <at> gmail.com, Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 66181 <at> debbugs.gnu.org
Subject: Re: bug#66181: Subject: 29.1; Occur changes don't affect Dired buffer
Date: Mon, 25 Sep 2023 11:42:28 +0300
> Cc: 66181 <at> debbugs.gnu.org
> Date: Mon, 25 Sep 2023 10:29:17 +0300
> From: Eli Zaretskii <eliz <at> gnu.org>
> 
> > From: Maske <kediez <at> gmail.com>
> > Date: Sun, 24 Sep 2023 13:32:04 +0200
> > 
> > I read a post, where Occur is used to edit a Dired buffer. Well, it
> > doesn't work:
> > 
> > - Tested in emacs -q
> > - Make Dired buffer writable
> > - Launch Occur
> > - Make Occur buffer editable
> > - Make changes in Occur buffer
> > - Changes are not saved in Dired buffer.
> 
> The last item is inaccurate.  The changes in the Occur buffer _are_
> reflected in the Dired buffer, but typing "C-c C-c" in the Dired
> buffer doesn't commit the changes to disk; instead it says "No changes
> to be performed" and reverts to the previous display of Dired.

This happens because WDired relies on before-change-functions to mark
the portions of the Dired buffer which were edited.  But Occur Edit
mode modifies the target buffer from an after-change function, so
buffer-modification hooks are disabled when the modifications are
performed, and the before-change function installed by WDired isn't
called.

Which also means that any mode that relies on buffer-modification
hooks will fail with the same symptoms when its buffer is edited
indirectly via Occur Edit.

Stefan, do we have any safe means of running the hooks in this case?
I thought about running the buffer-local values of before- and
after-change-functions by hand from occur-after-change-function,
skipping the t entry, but I'm not sure this is safe.  It is certainly
messy, so if there's a more elegant way, I'd like to know.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66181; Package emacs. (Mon, 25 Sep 2023 13:09:01 GMT) Full text and rfc822 format available.

Message #19 received at 66181 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 66181 <at> debbugs.gnu.org, kediez <at> gmail.com
Subject: Re: bug#66181: Subject: 29.1; Occur changes don't affect Dired buffer
Date: Mon, 25 Sep 2023 09:07:42 -0400
> Stefan, do we have any safe means of running the hooks in this case?
> I thought about running the buffer-local values of before- and
> after-change-functions by hand from occur-after-change-function,
> skipping the t entry, but I'm not sure this is safe.  It is certainly
> messy, so if there's a more elegant way, I'd like to know.

Arguably, the `inhibit-modification-hooks` let-binding that surrounds
code run from within modification hooks should be buffer-local, which
would solve these problems, AFAIK.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66181; Package emacs. (Mon, 25 Sep 2023 13:31:02 GMT) Full text and rfc822 format available.

Message #22 received at 66181 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 66181 <at> debbugs.gnu.org, kediez <at> gmail.com
Subject: Re: bug#66181: Subject: 29.1; Occur changes don't affect Dired buffer
Date: Mon, 25 Sep 2023 16:29:34 +0300
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: kediez <at> gmail.com,  66181 <at> debbugs.gnu.org
> Date: Mon, 25 Sep 2023 09:07:42 -0400
> 
> > Stefan, do we have any safe means of running the hooks in this case?
> > I thought about running the buffer-local values of before- and
> > after-change-functions by hand from occur-after-change-function,
> > skipping the t entry, but I'm not sure this is safe.  It is certainly
> > messy, so if there's a more elegant way, I'd like to know.
> 
> Arguably, the `inhibit-modification-hooks` let-binding that surrounds
> code run from within modification hooks should be buffer-local, which
> would solve these problems, AFAIK.

Not sure I understand: we let-bind inhibit-modification-hooks in C,
via specbind, and that binds the global value, since
inhibit-modification-hooks is not a per-buffer variable.  Or am I
missing something.

Do you mean we should add a new specbind_local function that makes
only a buffer-local let-binding?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66181; Package emacs. (Mon, 25 Sep 2023 13:53:02 GMT) Full text and rfc822 format available.

Message #25 received at 66181 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 66181 <at> debbugs.gnu.org, kediez <at> gmail.com
Subject: Re: bug#66181: Subject: 29.1; Occur changes don't affect Dired buffer
Date: Mon, 25 Sep 2023 09:52:36 -0400
>> > Stefan, do we have any safe means of running the hooks in this case?
>> > I thought about running the buffer-local values of before- and
>> > after-change-functions by hand from occur-after-change-function,
>> > skipping the t entry, but I'm not sure this is safe.  It is certainly
>> > messy, so if there's a more elegant way, I'd like to know.
>> 
>> Arguably, the `inhibit-modification-hooks` let-binding that surrounds
>> code run from within modification hooks should be buffer-local, which
>> would solve these problems, AFAIK.
>
> Not sure I understand: we let-bind inhibit-modification-hooks in C,
> via specbind, and that binds the global value, since
> inhibit-modification-hooks is not a per-buffer variable.  Or am I
> missing something.

You're right that's what we currently do.

> Do you mean we should add a new specbind_local function that makes
> only a buffer-local let-binding?

For example, yes.  Or we could call `Fmake_local_variable` before the
`specbind`, or we could make `inhibit-modification-hooks` into one of
those vars that are "really always" buffer-local, like `major-mode`,
`buffer-file-name` and a few others.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66181; Package emacs. (Mon, 25 Sep 2023 16:41:01 GMT) Full text and rfc822 format available.

Message #28 received at 66181 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 66181 <at> debbugs.gnu.org, kediez <at> gmail.com
Subject: Re: bug#66181: Subject: 29.1; Occur changes don't affect Dired buffer
Date: Mon, 25 Sep 2023 19:39:25 +0300
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: kediez <at> gmail.com,  66181 <at> debbugs.gnu.org
> Date: Mon, 25 Sep 2023 09:52:36 -0400
> 
> >> > Stefan, do we have any safe means of running the hooks in this case?
> >> > I thought about running the buffer-local values of before- and
> >> > after-change-functions by hand from occur-after-change-function,
> >> > skipping the t entry, but I'm not sure this is safe.  It is certainly
> >> > messy, so if there's a more elegant way, I'd like to know.
> >> 
> >> Arguably, the `inhibit-modification-hooks` let-binding that surrounds
> >> code run from within modification hooks should be buffer-local, which
> >> would solve these problems, AFAIK.
> >
> > Not sure I understand: we let-bind inhibit-modification-hooks in C,
> > via specbind, and that binds the global value, since
> > inhibit-modification-hooks is not a per-buffer variable.  Or am I
> > missing something.
> 
> You're right that's what we currently do.
> 
> > Do you mean we should add a new specbind_local function that makes
> > only a buffer-local let-binding?
> 
> For example, yes.  Or we could call `Fmake_local_variable` before the
> `specbind`, or we could make `inhibit-modification-hooks` into one of
> those vars that are "really always" buffer-local, like `major-mode`,
> `buffer-file-name` and a few others.

Would it work (and be okay) to make inhibit-modification-hooks
buffer-local in a buffer in which occur-edit-mode is turned on?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66181; Package emacs. (Mon, 25 Sep 2023 17:07:02 GMT) Full text and rfc822 format available.

Message #31 received at 66181 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 66181 <at> debbugs.gnu.org, kediez <at> gmail.com
Subject: Re: bug#66181: Subject: 29.1; Occur changes don't affect Dired buffer
Date: Mon, 25 Sep 2023 13:04:45 -0400
>> For example, yes.  Or we could call `Fmake_local_variable` before the
>> `specbind`, or we could make `inhibit-modification-hooks` into one of
>> those vars that are "really always" buffer-local, like `major-mode`,
>> `buffer-file-name` and a few others.
> Would it work (and be okay) to make inhibit-modification-hooks
> buffer-local in a buffer in which occur-edit-mode is turned on?

It should, yes (tho it will fix only this situation, obviously).


        Stefan





This bug report was last modified 1 year and 265 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.