Skip to content

add a check to dired-subtree--readin, if a listing is already indented #231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

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

1 participant