[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#18475: 24.4.50; Wdired: cannot use C-k to delete a dir name if -F sw
From: |
Stephen Berman |
Subject: |
bug#18475: 24.4.50; Wdired: cannot use C-k to delete a dir name if -F switch used |
Date: |
Tue, 30 Apr 2019 23:50:27 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
On Sat, 27 Apr 2019 01:09:16 +0100 "Basil L. Contovounesios" <contovob@tcd.ie>
wrote:
> Drew Adams <drew.adams@oracle.com> writes:
>
>> The `wdired-mode' doc string says: "If you delete the filename of a
>> file, it is flagged for deletion in the Dired buffer." And (emacs)
>> `Wdired' says: "To mark a file for deletion, delete the entire file
>> name."
>>
>> And this applies to directory names also.
>>
>> No problem, except if you use `ls' switch `-F', which appends `/' to
>> directory names. In that case, if you try to use `C-k' anywhere on the
>> dir name text, you get the error "Text is read only".
>>
>> (Yes, you can use other deletion keys besides `C-k' to delete the dir
>> name but not delete the `/'. That looks weird and is not easily
>> guessable by users, but it works. `C-k' should work also, as one would
>> expect.)
>>
>> In GNU Emacs 24.4.50.1 (i686-pc-mingw32)
>> of 2014-08-15 on LEG570
>> Bzr revision: 117706 rgm@gnu.org-20140815043406-p5hbu97cbm7pulcn
>> Windowing system distributor `Microsoft Corp.', version 6.1.7601
>> Configured using:
>> `configure --enable-checking 'CFLAGS=-O0 -g3' CPPFLAGS=-DGLYPH_DEBUG=1'
>
> I can still reproduce this on Emacs 26 and latest master.
This happens not only with `/' but also with the other ls file indicator
characters appended when using the -F switch. Making C-k work as
expected for these cases is a small fix. However, the same issue also
arises with symlinks, whether or not -F is used, and it does not seem as
straightforward to deal with this case. The attached patch (against
master) tries to ensure the following behavior:
- Typing `C-k' with point just before the first character of a file name
ending with an indicator character (using -F), or of link name,
deletes the file name/symlink in WDired, but it is restored but marked
for deletion on returning to Dired. The same also happens when just
deleting the link name in WDired.
- Typing `C-k' with point on such a file or link name, but after the
first character, deletes the rest, resulting in renaming on returning
to Dired.
- Deleting the indicator character is possible in WDired but a noop: the
character is restored on returning to Dired. (In the current code
without the patch, the indicator characters are read-only, but I had
to change that to make C-k work.)
With symlinks:
- The patch preserves the current behavior that an edit of the target
name (possible when wdired-allow-to-redirect-links is non-nil, as it
is by default) is saved on returning to Dired, and if the target name
is deleted, then the new target on returning to Dired is "/dev/null".
- Editing (changing or deleting) the string " -> " between the link and
target names is possible in WDired but a noop: the symlink is
unaltered on returning to Dired. (In the current code without the
patch, " -> " is read-only, but I had to change that to make C-k work.)
I've tested these cases, but it is quite possible that I overlooked some
variants or other cases, so I'd appreciate testing and feedback from
others. (Also, the code still needs more commenting and probably
cleaning up.)
Steve Berman
txtcTmVEEa81i.txt
Description: wdired patch