Fuco1 / dired-hacks

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

fix(collapse): Ensure dir actually readable before getting entries #207

Closed amake closed 8 months ago

amake commented 11 months ago

On macOS the ~/.Trash directory is "accessible" according to file-accessible-directory-p but it is not "readable", causing f-entries to fail. This makes opening ~/ in dired fail on macOS when dired-collapse-mode is on.

Also reported at https://github.com/Fuco1/dired-hacks/pull/182#issuecomment-1481062747

amake commented 11 months ago

Here is a workaround you can apply while this remains unaddressed:

(defun amk-safe-f-entries (old-func &rest args)
  "Swallow errors to return nil."
  (condition-case nil
      (apply old-func args)
    (file-error nil)))

(defun amk-dired-collapse-207 (old-func &rest args)
  "A workaround for https://github.com/Fuco1/dired-hacks/pull/207."
  (advice-add #'f-entries :around #'amk-safe-f-entries)
  (apply old-func args)
  (advice-remove #'f-entries #'amk-safe-f-entries))

(advice-add #'dired-collapse :around #'amk-dired-collapse-207)

(cc @MagielBruntink)

Fuco1 commented 8 months ago

Thank you for the patch and sorry for taking so long!