unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#66181: Subject: 29.1; Occur changes don't affect Dired buffer
@ 2023-09-24 11:32 Maske
  2023-09-24 16:21 ` Garjola Dindi
  2023-09-25  7:29 ` Eli Zaretskii
  0 siblings, 2 replies; 9+ messages in thread
From: Maske @ 2023-09-24 11:32 UTC (permalink / raw)
  To: 66181

[-- Attachment #1: Type: text/plain, Size: 322 bytes --]

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


[-- Attachment #2: Type: text/html, Size: 868 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#66181: Subject: 29.1; Occur changes don't affect Dired buffer
  2023-09-24 11:32 bug#66181: Subject: 29.1; Occur changes don't affect Dired buffer Maske
@ 2023-09-24 16:21 ` Garjola Dindi
  2023-09-25  7:29 ` Eli Zaretskii
  1 sibling, 0 replies; 9+ messages in thread
From: Garjola Dindi @ 2023-09-24 16:21 UTC (permalink / raw)
  To: 66181; +Cc: Maske

On Sun 24-Sep-2023 at 13:32:04 +02, Maske <kediez@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






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#66181: Subject: 29.1; Occur changes don't affect Dired buffer
  2023-09-24 11:32 bug#66181: Subject: 29.1; Occur changes don't affect Dired buffer Maske
  2023-09-24 16:21 ` Garjola Dindi
@ 2023-09-25  7:29 ` Eli Zaretskii
  2023-09-25  8:42   ` Eli Zaretskii
  1 sibling, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2023-09-25  7:29 UTC (permalink / raw)
  To: Maske; +Cc: 66181

> From: Maske <kediez@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.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#66181: Subject: 29.1; Occur changes don't affect Dired buffer
  2023-09-25  7:29 ` Eli Zaretskii
@ 2023-09-25  8:42   ` Eli Zaretskii
  2023-09-25 13:07     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2023-09-25  8:42 UTC (permalink / raw)
  To: kediez, Stefan Monnier; +Cc: 66181

> Cc: 66181@debbugs.gnu.org
> Date: Mon, 25 Sep 2023 10:29:17 +0300
> From: Eli Zaretskii <eliz@gnu.org>
> 
> > From: Maske <kediez@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.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#66181: Subject: 29.1; Occur changes don't affect Dired buffer
  2023-09-25  8:42   ` Eli Zaretskii
@ 2023-09-25 13:07     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-25 13:29       ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-09-25 13:07 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 66181, kediez

> 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






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#66181: Subject: 29.1; Occur changes don't affect Dired buffer
  2023-09-25 13:07     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-09-25 13:29       ` Eli Zaretskii
  2023-09-25 13:52         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2023-09-25 13:29 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 66181, kediez

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: kediez@gmail.com,  66181@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?





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#66181: Subject: 29.1; Occur changes don't affect Dired buffer
  2023-09-25 13:29       ` Eli Zaretskii
@ 2023-09-25 13:52         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-25 16:39           ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-09-25 13:52 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 66181, kediez

>> > 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






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#66181: Subject: 29.1; Occur changes don't affect Dired buffer
  2023-09-25 13:52         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-09-25 16:39           ` Eli Zaretskii
  2023-09-25 17:04             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2023-09-25 16:39 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 66181, kediez

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: kediez@gmail.com,  66181@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?





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#66181: Subject: 29.1; Occur changes don't affect Dired buffer
  2023-09-25 16:39           ` Eli Zaretskii
@ 2023-09-25 17:04             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 9+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-09-25 17:04 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 66181, kediez

>> 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






^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-09-25 17:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-24 11:32 bug#66181: Subject: 29.1; Occur changes don't affect Dired buffer Maske
2023-09-24 16:21 ` Garjola Dindi
2023-09-25  7:29 ` Eli Zaretskii
2023-09-25  8:42   ` Eli Zaretskii
2023-09-25 13:07     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-25 13:29       ` Eli Zaretskii
2023-09-25 13:52         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-25 16:39           ` Eli Zaretskii
2023-09-25 17:04             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).