dired-hacks
dired-hacks copied to clipboard
[dired-subtree] Directory shows up incorrectly when the first entry is '..'
When the first entry is .. in a subdirectory listing, the listing is incorrect. It omits entries between .. and .; that can make the subdirectory appear empty or that parts of it are missing. It's rather frustrating and the only workaround in sight is to change the dired-listing-switches.
Aren't . and .. always at the top? Can you past a screenshot of a dired buffer of that particular directory where this happens?
@Fuco1 Hmm, perhaps it's not as clear-cut as I initially thought. Here are some screenshots, although they doesn't exhibit the exact behavior that I described above:


As you can see, the some_dir directory is omitted from the subdir subtree in the 1st screenshot. But, it is clearly there as indicated by the 2nd screenshot.
Hm, it's pretty odd that the indent is also actually negative. What do you use to insert the data? The value of insert-directory-program and also the dired flags dired-listing-switches.
We indeed have code which, if the first entry is a dot . deletes the next two lines
(delete-region
(progn (beginning-of-line) (point))
(progn (forward-line
(if (save-excursion
(forward-line 1)
(end-of-line)
(looking-back "\\."))
3 1)) (point)))
But in your case because . and .. are not next to each other it deletes some other random entry. I think we could redo the code to scan the entire directory and remove . and .. or have a flag that just disables that behaviour (scanning all files can be quite laggy and bad UX).
@Fuco1 The value of insert-directory-program is "gls" which has been installed from MacPorts via sudo port install coreutils. The value of dired-listing-switches is "-lath".
Yes, I think that scanning the entire directory to remove . and .. would be the wrong way to go to solve this problem. As you say, it could very well lead to laggy behavior which will likely be more annoying than the current issue. I think having a flag would be a good solution here. Maybe say something in the flag's description like, "If this flag is disabled, there could be problems in subtrees wherein . and .. are not adjacent. Some entries may be missing and the indentation may be incorrect."