Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inherit file/folder_exclude_patterns from global settings #121

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

laggingreflex
Copy link
Contributor

@laggingreflex laggingreflex commented Jul 1, 2016

Exclude file|folder_exclude_patterns

If dired_show_excluded_files is set to false, it hides files and folders that match against folder_exclude_patterns and file_exclude_patterns patterns defined in the global settings.

fixes #82

@vovkkk
Copy link
Collaborator

vovkkk commented Jul 1, 2016

Thanks for effort

Please rename setting to dired_use_global_exclude_patterns

The checks should be probably moved to is_hidden method because prepare_filelist is not used in traverse_tree method of Refresh class; alternatively, we could change traverse_tree, but it would be probably harder to do.

Instead of if use_exclude_patterns == None or use_exclude_patterns == True and ...
use if use_exclude_patterns and ...

@laggingreflex laggingreflex force-pushed the exclude_patterns branch 4 times, most recently from 8e80529 to 6b8365e Compare July 1, 2016 21:20
except:
pass
if not show_excluded:
tests = self.view.settings().get('folder_exclude_patterns', []) + self.view.settings().get('file_exclude_patterns', [])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, you see the problem is that mixes folders and files which is wrong because folder pattern may match files which are not supposed to be excluded and vice versa.
So then we have to check if name isdir twice, which seems lame.
I dunno, maybe add new method which would check if hidden and add os.sep for folders then call this method instead of items = [name for name in os.listdir(path) if not self.is_hidden(name, path)] in appropriate places;
that way we would check for isdir once and call is_hidden with additional argument isdir=True/False.
What your thoughts are?

Also, the check for attribute on Windows must be the last one, because it is the heaviest so we should not execute it if name was already defined as hidden by other check.


def listdir_only_dirs(self, path):
return [item for item in self.listdir(path) if item["isdir"] == True]

Copy link
Contributor Author

@laggingreflex laggingreflex Jul 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These methods now return the directory list.
They are the only ones now that do isdir check so no other methods need to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exclude files based on .sublime-settings and .project-settings files ?
2 participants