Skip to content

Conversation

@flokoenig
Copy link

Hi,

this is a patch for my problem in #229
Turns out that it isn't a tramp problem. It's a ls --dired problem.

Example listing:

me@mine:~# ls -l
insgesamt 4
drwxr-xr-x 2 root root 4096 13. Apr 18:15 test
-rw-r--r-- 1 root root    0 13. Apr 18:15 test.txt

vs

me@mine:~# ls -l --dired
  insgesamt 4
  drwxr-xr-x 2 root root 4096 13. Apr 18:15 test
  -rw-r--r-- 1 root root    0 13. Apr 18:15 test.txt
//DIRED// 58 62 107 115
//DIRED-OPTIONS// --quoting-style=shell-escape

If --dired is one of the listing switches, the listing will be indented by two whitespaces, insert-directory will clean up the DIRED lines but not the indentation, and then dired-subtree--readin prepends two additional whitespaces. Due to these additional whitespaces, the directories in the subdirectory will not be identified as such and further levels of subdirectories will not work. This is patched here: if two whitespaces are detected in the beginning of the listing, no further whitespaces will be added.

NB: Since tramp for example will use --dired if it is available, a check if --dired is in dired-listing-switches wouldn't suffice, so we simply check for two whitespaces at the beginning of the listing to decide if we still have to prepend.

If --dired is one of the listing switches, the listing will already be indented by two whitespaces. If two whitespaces are detected in the beginning of the listing, no further whitespaces will be added. Otherwise, i.e. if additional whitespaces are prepended, the directories in the subdirectory will not be identified as such and further levels of subdirectories will not work.
@flokoenig flokoenig changed the title dired-subtree--readin checks if listing already indented add a check to dired-subtree--readin, if a listing is already indented Apr 13, 2025
@rennsax
Copy link

rennsax commented Aug 11, 2025

I've found the same problem, and your observation is totally correct. Your patch probably addresses the bug, but I'm wondering whether we have better choice other than removing the indentation in such a hack. 🤔

@flokoenig
Copy link
Author

There is another ancient and dead PR #179 that addresses this. My hack has been working well for me, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants