On Wed, 24 May 2023 14:05:43 +0300 Eli Zaretskii wrote: >> From: Peter Mao >> Date: Tue, 23 May 2023 21:51:01 -0700 >> >> I'm testing: GNU Emacs 29.0.91 (build 1, x86_64-pc-linux-gnu, GTK+ Version >> 3.24.33, cairo >> version 1.16.0) of 2023-05-15 >> >> Dired behavior has multiple problems if subdirectories are present in the >> buffer and writable mode is >> entered and then cancelled >> >> To reproduce the problem >> 1. Open a directory in dired >> 2. Insert a subdirectory with "i" >> 3. Enter writable mode "C-x C-q" >> 4. Cancel writable mode "C-c ESC" >> >> Now the subdirectory is in the buffer, but it can't be folded or removed >> with "C-u k" and the top dir files >> can no longer be accessed. > > I seem to be unable to reproduce this. But your recipe lack some > details, so I'm unsure. Would you please describe exactly what to > type after "C-c ESC" to demonstrate that some commands don't work, and > what did you expect those command to do? I can reproduce the problem: After step 4 above, with point within the subdirectory, typing `$' should hide just the subdirectory, but it hides the entire directory structure, i.e. the topmost directory and all subdirectories. After typing `$' to show the directory, which also shows the previously inserted subdirectory, with point on the first line of the subdirectory (i.e. the line containing the name of the subdirectory), typing `C-u k' should remove the display of the subdirectory, but it does not and instead errors with the message "Can only kill file lines". The OP noted that typing `g' after step 4 makes subsequently typing `$' and `C-u k' in the subdirectory work as expected. In fact, `g' in dired does not call revert-buffer but dired-revert, which properly restores subdirectories. And indeed, with the patch below I don't see the problems any more. Steve Berman