jojojames / dired-sidebar

Sidebar for Emacs leveraging Dired
GNU General Public License v3.0
506 stars 22 forks source link

How to make it work well with dired-omit-mode? #84

Open ZelphirKaltstahl opened 9 months ago

ZelphirKaltstahl commented 9 months ago

I like the idea of using dired as a sidebar thing in Emacs, since I like the shortcuts and operations one can use in dired. However, when I used neotree, I could define which files count as hidden files and then hide them. For dired-sidebar I could change the switches given to ls, using C-u s to not include -a, but that only hides dot files.

I have found the following way to hide more than just dot files:

;; Set files to omit with dired-omit-mode, which is by default invoked using C-x M-o.
  (setq dired-omit-files
    (rx
     (or (seq bol (? ".") "#")     ;; emacs autosave files
         (seq bol "." (not (any "."))) ;; dot-files
         (seq "~" eol)                 ;; backup-files
         (seq bol "__pycache__" eol)   ;; python cache files
         (seq bol "__init__.py" eol)   ;; python package files
         )))

And then use dired-omit-mode (C-x M-o (default binding I think)) to toggle hiding of files.

However, when I unfold a directory or fold it, the dired in the sidebar seems to reload or redisplay and forget, that it should not show those files.

How can I make it so that hidden files stay hidden, until I deactivate dired-omit-mode?

haditim commented 3 months ago

I added a hook which, more or less, works with dired-omit-mode with one caveat: one cannot disable dired-omit-mode when a subtree is active. If you want to see hidden files, you need to close subtrees, but I personally have not issues with that.

(add-hook 'dired-subtree-after-insert-hook 'dired-omit-mode)