treemacs icon indicating copy to clipboard operation
treemacs copied to clipboard

Some git-ignored directories and files not being hidden

Open sammorley-short opened this issue 2 years ago • 11 comments

Perhaps a dupe of https://github.com/Alexander-Miller/treemacs/issues/935, but not quite sure.

I have both __pycache__ and *.pyc added to my project's .gitignore, which are properly causing those files to be ignored by git. However, none of the project's __pycache__ directories, nor the enclosed .pyc files are hidden, despite other git-ignored files (such as TAGS) being hidden correctly. Similarly, although dot-prefixed directories which are in my .gitignore (such as .mypy_cache) are hidden correctly via treemacs-toggle-show-dotfiles, these are not hidden via treemacs-hide-gitignored-files-mode.

Hence, I think the problem seems to be that directories and their contents are not being hidden correctly by the treemacs-hide-gitignored-files-mode command specifically.

Thanks!

sammorley-short avatar Jul 16 '22 10:07 sammorley-short

The basic setup works on my end:

hideshow

Can you give me an example of the directory structure for when it doesn't?

Alexander-Miller avatar Jul 18 '22 20:07 Alexander-Miller

I have /node_modules/ .gitignored but it's displayed anyway in treemacs. 👀

tx46 avatar Aug 08 '22 15:08 tx46

@Alexander-Miller Not sure if this is something wrong with my local version (I am using Doom Emacs and have ran doom upgrade), but here's what I see before and after toggling the setting:

Before: Screenshot 2022-09-06 at 22 22 29

After: Screenshot 2022-09-06 at 22 22 35

As you can see, I am not able to reproduce your behaviour above 😞.

I don't think this should be something to do with my Treemacs config either, which is as follows:

(setq
 treemacs-tag-follow-delay 0.5
 treemacs-recenter-after-tag-follow 'always
 )
(defun turn-on-treemacs-tag-follow-mode ()
  (treemacs-tag-follow-mode 't)
)
(add-hook 'treemacs-mode-hook 'turn-on-treemacs-tag-follow-mode)

Any idea what's going on?

sammorley-short avatar Sep 06 '22 21:09 sammorley-short

Any idea what's going on?

No, and that means we need to do some digging. Basics first:

  • I don't see many different colors in your screenshots. The default is that ignored files look the same as font-lock-comment-face (though your doom theme probably changes that). Is git-mode on, does it actually highlight changes correctly?
  • What does git status --porcelain --ignored=matching . output for you?
  • What about python /treemacs/install/location/treemacs-git-status.py /your/repo/root 9999 "" when run in your examplre repository?

Same questions for you @philiparvidsson. First we need to determine that treemacs recognizes the ignored files, then we can look into its rendering decisions.

(add-hook 'treemacs-mode-hook 'turn-on-treemacs-tag-follow-mode)

You shouldn't need that wrapper. If you want tag-follow-mode always active in doom you can do (after! treemacs (treemacs-tag-follow-mode)). t shouldn't be quoted either.

Alexander-Miller avatar Sep 14 '22 11:09 Alexander-Miller

Thanks for you help. Let's dig.

Is git-mode on, does it actually highlight changes correctly?

Yep, changes are highlighted correctly in the sidebar and magit works without issue.

What does git status --porcelain --ignored=matching . output for you?

?? .gitignore
!! .DS_Store
!! .cask/
!! __pycache__/
!! foo/
!! setup.py

What about python /treemacs/install/location/treemacs-git-status.py /your/repo/root 9999 "" when run in your examplre repository?

#s(hash-table size 6 test equal rehash-size 1.5 rehash-threshold 0.8125 data ("./.gitignore"treemacs-git-untracked-face"./.DS_Store"treemacs-git-ignored-face"./.cask"treemacs-git-ignored-face"./__pycache__"treemacs-git-ignored-face"./foo"treemacs-git-ignored-face"./setup.py"treemacs-git-ignored-face))%

sammorley-short avatar Oct 15 '22 03:10 sammorley-short

Yep, changes are highlighted correctly in the sidebar and magit works without issue.

Does that include the ignored files, if treemacs-hide-gitignored-files-mode is disabled?

Btw, how do you enable hide-gitignored-files-mode? It has to be via (treemacs-hide-gitignored-files-mode t). Depending on you elisp knowledge that might be pretty obvious, but I've had a non-trivial number of issues where inexperienced users just changed the variable value.

#s(hash-table size 6 test equal rehash-size 1.5 rehash-threshold 0.8125 data ("./.gitignore"treemacs-git-untracked-face"./.DS_Store"treemacs-git-ignored-face"./.cask"treemacs-git-ignored-face"./pycache"treemacs-git-ignored-face"./foo"treemacs-git-ignored-face"./setup.py"treemacs-git-ignored-face))%

That % at the end is a typo, right?

Otherwise the script output looks correct, assuming you used . for your directory root instead of the absolute path.

Assuming that's all correct we'll next look into the information treemacs saves about your files. First you need to run this line (ht-clear! treemacs--annotation-store). Then head over to your project and hit refresh once. Then run this code and tell me the output:

(treemacs--maphash treemacs--annotation-store (key value)
 (message "Annotation %s -> %s" key value))

Alexander-Miller avatar Oct 19 '22 19:10 Alexander-Miller

This issue has been automatically marked as stale because it has not had recent activity.

stale[bot] avatar Dec 18 '22 22:12 stale[bot]

:eyes:

Alexander-Miller avatar Dec 21 '22 13:12 Alexander-Miller

This issue has been automatically marked as stale because it has not had recent activity.

stale[bot] avatar Feb 19 '23 22:02 stale[bot]

Today I also met this issue, but after turn off treemacs-tree-mode and re-enable it with Extended or Deferred mode solve this problem. Hope this message can help others.

I am running on Emacs 30 master branch and Doom Emacs.

colawithsauce avatar May 05 '23 15:05 colawithsauce

This issue has been automatically marked as stale because it has not had recent activity.

stale[bot] avatar Jul 09 '23 05:07 stale[bot]