From 55777d5f6cb71accd2dd8782e001e14608f52659 Mon Sep 17 00:00:00 2001 From: laggingreflex Date: Fri, 1 Jul 2016 21:06:29 +0530 Subject: [PATCH] Exclude file|folder_exclude_patterns If `use_global_exclude_patterns: true` is set, uses `folder_exclude_patterns` and `file_exclude_patterns` patterns (from global settings) to match against directories and files respectively, and not include them in the index. --- README.md | 5 +++++ common.py | 13 +++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bf85068..23a281b 100644 --- a/README.md +++ b/README.md @@ -301,6 +301,11 @@ such patterns: { "dired_hidden_files_patterns": [".*", "__pycache__", "*.pyc"] } ``` +### Exclude Patterns + +By default, FileBrowser shows all files and directories otherwise excluded by your `file_exclude_patterns` and `folder_exclude_patterns`. +To exclude those set `use_global_exclude_patterns: true` + ### VCS integration In case `git status`(or `hg status`) returns a colorable output in current directory, the modified and untracked files will be designated by orange and green icons respectively. diff --git a/common.py b/common.py index 67b419c..53018ad 100644 --- a/common.py +++ b/common.py @@ -386,15 +386,20 @@ def prepare_filelist(self, names, path, goto, indent): level = indent * int((len(ind) / tab) + 1) if ind else indent files = [] index_dirs = [] + exclude_dirs = self.view.settings().get('folder_exclude_patterns') index_files = [] + exclude_files = self.view.settings().get('file_exclude_patterns') + use_exclude_patterns = self.view.settings().get('use_global_exclude_patterns') for name in names: full_name = join(path, goto, name) if isdir(full_name): - index_dirs.append(u'%s%s' % (full_name, os.sep)) - items.append(''.join([level, u"▸ ", name, os.sep])) + if use_exclude_patterns == None or use_exclude_patterns == True and not any(fnmatch.fnmatch(name, p) for p in exclude_dirs): + index_dirs.append(u'%s%s' % (full_name, os.sep)) + items.append(''.join([level, u"▸ ", name, os.sep])) else: - index_files.append(full_name) - files.append(''.join([level, u"≡ ", name])) + if use_exclude_patterns == None or use_exclude_patterns == True and not any(fnmatch.fnmatch(name, p) for p in exclude_files): + index_files.append(full_name) + files.append(''.join([level, u"≡ ", name])) index = index_dirs + index_files self.index = self.index[:self.number_line] + index + self.index[self.number_line:] items += files