bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#11795: 24.1.50; wdired: C-c C-c loses marks and positions of renamed


From: Michael Heerdegen
Subject: bug#11795: 24.1.50; wdired: C-c C-c loses marks and positions of renamed files
Date: Sat, 27 Oct 2012 14:55:40 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux)

Hello Juri,

> > So, introducing an new option `wdired-keep-marker-rename' would IMHO make
> > sense.  The default value could be t, at least that's what I think would
> > be most intuitive.
>
> I fixed this regression by adding `wdired-keep-marker-rename'.
> Thanks for the suggestion.

Good - thanks!

> When testing it, I noticed a random behavior of `wdired-do-renames'
> when the marker is customized to a character.  The decision what
> character to put depends on the position of point.  When point is at
> the top of the Dired buffer, it uses a customized marker character.
> When point is at the bottom, it restores an old marker character.
>
> The problem is that `dired-remove-file' doesn't remove file entries
> (and neither `dired-rename-file') because files already have new
> renamed names
> in the Dired buffer.  Whereas `dired-add-entry' adds duplicated file
> entries.
>
> Fortunately, `revert-buffer' (called at the end of
> `wdired-finish-edit') sorts out this mess caused by `dired-add-entry'.
> But in `dired-revert' it uses `dired-remember-marks' and
> `dired-restore-positions' to restore markers.  So when duplicated file
> entries were added by `dired-add-entry' at the top of the Dired buffer
> (in front of file entries edited by WDired), it uses a customized
> marker character.  When duplicated file entries were added at the
> bottom, it restores an old marker character because
> `dired-restore-positions' in `dired-revert' gets markers from the
> first duplicated file entry.

Thanks for finding this, and for your analysis.

> Do you have an idea how to fix this problem?  One way would be instead
> of using `dired-add-file' to change markers in the remembered variable
> `wdired-old-marks' and just call `dired-mark-remembered' (before
> `revert-buffer' in `wdired-finish-edit') with the modified list of
> markers for renamed files.

I chose to use `dired-add-file' in my patch so that name changes are
propagated also to other dired buffers where these files may also be
shown.  This is consistent with `dired-do-rename'.

WRT your suggestion: I see two problems:

1. Calling `dired-mark-remembered' before `revert-buffer' is not
reliable, because it may fail to get the right names from places where
changes were made.  I.e., it my not work for the same reason as
`dired-remove-file' doesn't work.

2. Even if this worked well, the remaining old lines of renamed files
are still lying around.  They can still cause trouble.  When
`revert-buffer' is called, these lines are still included for
remembering marks.  This is problematic: there is a chance that the user
has renamed another file in that buffer to that collected name.

My suggestion would be to just delete the according lines so that they
cannot cause trouble, simply with `delete-region'.  That should not do
any harm.

What do you think?


Regards,

Michael.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]