Fuco1 / dired-hacks

Collection of useful dired additions
GNU General Public License v3.0
878 stars 77 forks source link

feat(dired-collapse): support-dired-omit-mode #210

Closed Boruch-Baum closed 8 months ago

Boruch-Baum commented 8 months ago

When dired-omit-mode is active, decide whether to collapse a path based upon the number of files that would be visible, ie. exclude the omitted files from the count.

Fuco1 commented 8 months ago

I think this is a nice feature but personally I feel like this should have a toggle. Because you might for example delete a collapsed directory and it would remove files which are "invisible". (there is some issue somewhere about deleting the entire hierarchy instead of just the leaf node). Or it might need to do some warning in that case.

But a feature toggle is not a bad idea.

Boruch-Baum commented 8 months ago

I had thought of that (writing code for the toggle), but then realized that M-x dired-omit-mode itself performs the toggle for me, so there was nothing needed to be added to get the toggle effect.

On 2024-03-21 04:57, Matus Goljer wrote:

I think this is a nice feature but personally I feel like this should have a toggle. Because you might for example delete a collapsed directory and it would remove files which are "invisible". (there is some issue somewhere about deleting the entire hierarchy instead of just the leaf node). Or it might need to do some warning in that case.

But a feature toggle is not a bad idea.

— Reply to this email directly, [1]view it on GitHub, or [2]unsubscribe. You are receiving this because you authored the thread. Message ID: @.***>

References

  1. https://github.com/Fuco1/dired-hacks/pull/210#issuecomment-2012079085
  2. https://github.com/notifications/unsubscribe-auth/AAOE3KDRGWXGZY5PQVYHLP3YZLDLNAVCNFSM6AAAAABEQQEG5SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJSGA3TSMBYGU

-- hkp://keys.gnupg.net CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0

Fuco1 commented 8 months ago

The issue is that when you collapse a directory with 5 files (4 of which are omited) and then ask dired to delete that directory, you will delete those 4 files as well without really knowing they are there (assuming we delete the whole path, which does not happen by default either). So there should either be some warning or a toggle so users explicitly opt-in for this.

Boruch-Baum commented 8 months ago

I beed help reproducing your issue.

When I enable dired-collapse-mode along with dired-omit-mode and test the case of "a directory with 5 files (4 of which are omited)", what happens is that I get prompted only to delete only the visible file, and it only deletes the visible file.

When all the files in a directory are 'omited' and I try to delete the directory, Emacs dired already by default does warn me that the directory isn't empty and asks me whether I want to perform a recursive deletion.

$HOME | aa-dir |- .test1-invisible-file |- .test2-invisible-file |- test3-visible-file

When I test this nested deeper, I get the same warning.

$HOME | aa-dir |- bb-dir |- .test1-invisible-file |- .test2-invisible-file

Fuco1 commented 8 months ago

Ok then it sounds good! Thanks.

Boruch-Baum commented 8 months ago

Thank, Jimmy!

On 2024-03-27 17:50, Jimmy Yuen Ho Wong wrote:

@wyuenho commented on this pull request.

The dired-omit-mode variables and function references may not exist at run time. Please fix.


In [1]dired-collapse.el:

@@ -131,7 +133,8 @@ filename (for example when the final directory is empty)." ;; to them, while dired-collapse requires all the details. So we di sable invisibility here ;; temporarily. (buffer-invisibility-spec nil)

  • (inhibit-read-only t))
  • (inhibit-read-only t)
  • (rgx (and dired-omit-mode (dired-omit-regexp))))

@.*** the var dired-omit-mode and the function dired-omit-regexp may not be defined here as they come from dired-x, which is not required. Either require it or check for the symbols are bound and true and an actual function.


In [3]dired-collapse.el:

@@ -144,6 +147,11 @@ filename (for example when the final directory is empty). " (while (and (file-directory-p path) (file-accessible-directory-p path) (setq files (f-entries path))

  • (or (not dired-omit-mode)

same issue as above

— Reply to this email directly, [4]view it on GitHub, or [5]unsubscribe. You are receiving this because you were mentioned. Message ID: @.***>

References

  1. https://github.com/Fuco1/dired-hacks/pull/210#discussion_r1542187321
  2. https://github.com/Boruch-Baum
  3. https://github.com/Fuco1/dired-hacks/pull/210#discussion_r1542187396
  4. https://github.com/Fuco1/dired-hacks/pull/210#pullrequestreview-1964985049
  5. https://github.com/notifications/unsubscribe-auth/AAOE3KGKBZ2QTIDZERV4KQ3Y2NLMDAVCNFSM6AAAAABEQQEG5SVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTSNRUHE4DKMBUHE

-- hkp://keys.gnupg.net CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0