Added find.exclude

14 views
Skip to first unread message

Neil Hodgson

unread,
Jul 16, 2022, 1:27:32 AMJul 16
to scite-i...@googlegroups.com
   As I was annoyed by .bak and .orig files showing in “Find in Files”, I added a find.exclude property to filter out files and directories that match a set of patterns. This is most commonly needed when the Files item in the dialog is empty or otherwise over-broad.

   For example:
find.exclude=*.bak *.orig debug release
   This doesn’t search in any *.bak or *.orig files or search inside the debug or release directories where there may be object files or other build artifacts.

   As well as avoiding extra results, this can improve performance by excluding binary files based on name rather than reading them.

  Changes available from the repository
hg clone http://hg.code.sf.net/p/scintilla/scite
  or from
https://www.scintilla.org/scite.zip  Source
https://www.scintilla.org/wscite.zip Windows executable (64-bit)

   Neil

Lorenzo Donati

unread,
Jul 22, 2022, 6:58:06 AMJul 22
to scite-i...@googlegroups.com
On 16/07/2022 07:27, 'Neil Hodgson' via scite-interest wrote:
> As I was annoyed by .bak and .orig files showing in “Find in Files”,
> I added a find.exclude property to filter out files and directories
> that match a set of patterns. This is most commonly needed when the
> Files item in the dialog is empty or otherwise over-broad.
>

Nice addition. Thanks.

> For example: find.exclude=*.bak *.orig debug release This doesn’t
> search in any *.bak or *.orig files or search inside the debug or
> release directories where there may be object files or other build
> artifacts.
>

Wouldn't it be better to discriminate directories by adding a final
slash/backslash?

e.g. "debug/"

Otherwise it would be impossible to avoid searching in files that have
no extensions. E.g. how would one avoid searching inside a file simply
named "makefile" or "README"?

> As well as avoiding extra results, this can improve performance by
> excluding binary files based on name rather than reading them.
>

Moreover, how complex is the supported pattern syntax? Is it just a
shell glob or does it support regular expressions (e.g. like the
search/replace dialog)?
Cheers!

-- Lorenzo

Neil Hodgson

unread,
Jul 22, 2022, 6:16:20 PMJul 22
to scite-i...@googlegroups.com
Lorenzo Donati:

> Wouldn't it be better to discriminate directories by adding a final slash/backslash?
>
> e.g. "debug/"

It would be more code. If someone wants to implement it, it can be included.

> Otherwise it would be impossible to avoid searching in files that have no extensions. E.g. how would one avoid searching inside a file simply named "makefile" or "README"?

With
find.exclude=makefile README

Both files and directories that match the patterns are excluded. So if you are excluding the "release" directory you’ll also miss a file called "release".

> Moreover, how complex is the supported pattern syntax? Is it just a shell glob or does it support regular expressions (e.g. like the search/replace dialog)?

These are the extremely simple patterns with just "?" and "*" also allowed for the set of files to search. Its implemented by PatternMatch in FilePath.cxx.

There is another implementation of pattern matching in PathMatch.cxx that was done for EditorConfig support but it is more complex and would change the interpretation of patterns. It includes relative path matching, sets of characters, alternates, and numeric ranges.

https://editorconfig-specification.readthedocs.io/#glob-expressions

Again, this would be more work so if someone wants to do it …

Neil

Reply all
Reply to author
Forward
0 new messages