Filter functions

If you are experiencing problems with "Everything", post here for assistance.
Post Reply
void
Developer
Posts: 17152
Joined: Fri Oct 16, 2009 11:31 pm

Filter functions

Post by void »

A filter function is a special filter macro that takes one parameter that can dynamically build a filter search.

Filter functions have been added to Everything 1.4.1.790b:

http://www.voidtools.com/Everything-1.4.1.790b.x86.zip
http://www.voidtools.com/Everything-1.4.1.790b.x64.zip

To create a filter function, append the filter macro name with:
<name>

All occurrences of name: in the filters search will be substituted with the parameter passed to your macro.

For example, to search for files with the content "foo bar", where the files could be utf8 or ansi, you would have to search for:
utf8content:"foo bar" | ansicontent:"foo bar"

With filter functions, you can create a filter (from Search -> Add to filters...) with the macro:
ct<search>

and with the filter search:
utf8content:search: | ansicontent:search:

when searching for ct:"foo bar" the search will be replaced with:
utf8content:"foo bar" | ansicontent:"foo bar"
mwsm
Posts: 21
Joined: Thu Feb 28, 2013 2:01 am

Re: Filter functions

Post by mwsm »

This is an excellent and powerful new feature! For example, I am now able to create a custom Whole Word filter that includes the underscore character as a word boundary, something I've long missed in Everything. I set up the Filter like this:

Code: Select all

Search: regex:"(?:\b|_)word:(?:\b|_)"
Macro: ww<word>
Thank you!
harryray2
Posts: 1104
Joined: Sat Oct 15, 2016 9:56 am

Re: Filter functions

Post by harryray2 »

I'm probably being dense, I don't quite get it....is it possible to put a screenshot up with an example?
void
Developer
Posts: 17152
Joined: Fri Oct 16, 2009 11:31 pm

Re: Filter functions

Post by void »

The search is now used as the filter parameter when a filter with a macro function is active in Everything 795b:
http://www.voidtools.com/Everything-1.4.1.795b.x86.zip
http://www.voidtools.com/Everything-1.4.1.795b.x64.zip

For example, if you have the filter with the search:
parent:search:
and the macro:
myparent<search>

When this filter is active, the search: part is substituted with the current search.
So when searching for c:\windows with the parent filter active, the search is replaced with:
parent:c:\windows

Image
Image
hansolocambo
Posts: 7
Joined: Mon Oct 09, 2017 9:30 am

Re: Filter functions

Post by hansolocambo »

I'm sure this is extremely powerful and even "simple", but sadly it's not accessible to the "ordinary people" who never write a line of code and are used to intuitive UIs with cells to be filled in. :oops:
horst.epp
Posts: 1456
Joined: Fri Apr 04, 2014 3:24 pm

Re: Filter functions

Post by horst.epp »

hansolocambo wrote:I'm sure this is extremely powerful and even "simple", but sadly it's not accessible to the "ordinary people" who never write a line of code and are used to intuitive UIs with cells to be filled in. :oops:
There is no code to write and the examples above are easy to follow even for beginners.
If that is to much you should probably stay with Windows search or only use the basic Everything features.
Stamimail
Posts: 1122
Joined: Sat Aug 31, 2013 9:05 pm

Re: Filter functions

Post by Stamimail »

There is no code to write and the examples above are easy to follow even for beginners.
I don't think so.
Anyway,
<search>
search:
This Syntax where was it taken from? What was its inspiration?
hansolocambo
Posts: 7
Joined: Mon Oct 09, 2017 9:30 am

Re: Filter functions

Post by hansolocambo »

horst.epp wrote: Mon Oct 09, 2017 1:06 pm There is no code to write and the examples above are easy to follow even for beginners.
If that is to much you should probably stay with Windows search or only use the basic Everything features.
If the most helpful things that come to your mind look like this, keep it to yourself.
horst.epp
Posts: 1456
Joined: Fri Apr 04, 2014 3:24 pm

Re: Filter functions

Post by horst.epp »

hansolocambo wrote: Fri May 24, 2019 11:26 am
horst.epp wrote: Mon Oct 09, 2017 1:06 pm There is no code to write and the examples above are easy to follow even for beginners.
If that is to much you should probably stay with Windows search or only use the basic Everything features.
If the most helpful things that come to your mind look like this, keep it to yourself.
You said you want "intuitive UIs with cells to be filled in"
So if that is not available use the basic features of Everything or some other fancy GUI based tool.
For most "simple" usage its all you need.
And I still will comment :)
nod5
Posts: 38
Joined: Fri Aug 19, 2016 9:12 pm

Re: Filter functions

Post by nod5 »

hansolocambo wrote: Mon Oct 09, 2017 9:35 am I'm sure this is extremely powerful and even "simple", but sadly it's not accessible to the "ordinary people" who never write a line of code and are used to intuitive UIs with cells to be filled in. :oops:
Maybe this helps.

How to create and use you own filter functions

First we can ask: Why use a filter function? What's the point? Answer: use it to simplify a complex search that you do regularly but that Everything doesn't already have any simple menu option or short macro for.

Example where you don't need to create a filter function.
Everything already has the built in filter Compressed to search for compressed files. So if you type zip:food Everything lists files that are compressed (files with the extensions .zip .7z .rar ...) and has food in the filename. In this example zip: is the built-in macro for the filter. You type the macro to tell Everything what filter to apply.

Example where it can help to make a filter function
Imagine you regularly want to do some searches that apply several wildcards, functions and/or modifiers.
(See https://www.voidtools.com/support/everything/searching for built in search syntax.)
For example imagine that you regularly want to search for files in the folder C:\Windows or its subfolders with file extension .txt or .log
To do that first enable Match Path in the Search menu and then type C:\Windows ext:txt;log test

On my computer I get these results
(To see the screenshots either log in to voidtools forum or view them on imgur here https://imgur.com/a/vZT4ELm )
1.png
1.png (11.23 KiB) Viewed 27311 times

A filter function can do the same search with less typing.
To create a filter function go to Search > Organize Filter... > New
The New Filter window is now shown. Enter the details shown in this screenshot and press OK.
2.png
2.png (9.87 KiB) Viewed 27311 times

Now type win:test in Everything to use the filter we created.

The results are the same as before
3.png
3.png (10.29 KiB) Viewed 27311 times

What happens is that Everything behind the scenes transformed win: into C:\Windows ext:txt;log

Three important things to remember when you make filter functions

1. win (blue color in the screenshot). This is the custom macro name. We later type win: in Everything to use the macro. Note that there should be no colon when we create the filter (no colon in the blue part), but a colon when we use the filter.

2. <search> (green color) represents any string the user types after win:

3. search: (red color) also represents any string the user types after win:

Question: why <search> in one field and search: in the other? Answer: I don't know, but that's the way it has to be. :)

To make your own filter functions use my example above but change the blue and pink parts. Examples:
- Change the blue text to xyz and you can later in Everything type xyz: to search with the filter function. For example xyz:test
- Change the pink text to D:\ ext:txt size:<25000 search: to make a filter that searches for files on drive D:\ with extension .txt and a size smaller than 25000 bytes.
- See https://www.voidtools.com/support/everything/searching for all the built in search command you can combine when you make a filter function.

Filter functions without macros

You don't have to use macros. You can instead toggle the filter function on/off in the Search menu or through a hotkey that you set up in the Add Filter window.
Stamimail
Posts: 1122
Joined: Sat Aug 31, 2013 9:05 pm

Re: Filter functions

Post by Stamimail »

@nod5, very nice.
I still think there is something to improve here.
I liked the most this sentence:
nod5 wrote: Sat May 25, 2019 1:20 pm Question: why <search> in one field and search: in the other? Answer: I don't know, but that's the way it has to be. :)
How to produce a clear syntax without causing confusion (like avoid using signs with double meaning and so), is a work of art.
I had a discussion once about such:
Syntax of functions
Stamimail
Posts: 1122
Joined: Sat Aug 31, 2013 9:05 pm

Re: Filter functions

Post by Stamimail »

To improve the syntax I think the placeholder in the 2 fields should have the same characters:

utf8content:search: | ansicontent:search:
ct<search>

Search: regex:"(?:\b|_)word:(?:\b|_)"
Macro: ww<word>

parent:search:
myparent<search>


According to the new suggestion:

utf8content:<<>> | ansicontent:<<>>
ct:<<>>

Search: regex:"(?:\b|_)<<>>(?:\b|_)"
Macro: ww:<<>>

parent:<<>>
myparent:<<>>

(macro and macro: will be the same)
(myparent and myparent: will be the same)

This is also good:

parent:<search>
myparent:<search>

parent:search:
myparent:search:
void
Developer
Posts: 17152
Joined: Fri Oct 16, 2009 11:31 pm

Re: Filter functions

Post by void »

I have put on my TODO list to improve the filter macro syntax.

Ideally, you shouldn't have to define the parameter name in the macro field.

I should add a hard-coded parameter name for the search field.
Maybe something like <<>> or [param:]

eg:
search: parent:[param:]
macro: myparent

Thanks for the suggestions.
void
Developer
Posts: 17152
Joined: Fri Oct 16, 2009 11:31 pm

Re: Filter functions

Post by void »

Everything 1.5.0.1355a improves macros.

Macro names no longer need to specify a parameter.

The parameter passed to a macro can now be reference in the search with $param:

The old macro-name<param> style syntax will still be supported.



Example filter:

Name: My uppercase filter
Search: case:[upper:$param:]
Macro: up

Example usage:

up:abc
=> case:ABC



Only one parameter is now supported.

Multiple parameter filter example:

Name: Width and Height
Search: width:[element:$param:,",",1] height:[element:$param:,",",2]
Macro: wh

Example usage:

wh:800,600
=> width:800 height:600
Post Reply