Filter macro names

Discussion related to "Everything" 1.5 Alpha.
Post Reply
reitwal
Posts: 18
Joined: Sat Apr 09, 2016 9:19 am

Filter macro names

Post by reitwal »

In Everything 1.5 (all 1.5 versions until now) there seems to be a conflict if the macro name of one filter is part of the macro name of another filter, e.g. filter 1 macro name is "inf" and filter 2 macro name is "inf2", as in the following example.
I use the latest version Everything 1.5.0.1253

Example
Filter 1
Search: infolder:search:
Macro: inf<search>

Filter 2
Search: **search:\*
Macro: inf2<search>

When I did a search:
inf2:2_computer
i got no result and in the debug log I found these lines:

2021-04-11 13:32:28.228: search 'inf2:2_computer' filter '' sort 5 ascending 0
2021-04-11 13:32:28.228: parse flags 00000000 type 00c01104
2021-04-11 13:32:28.228: TERM inf2:2_computer
2021-04-11 13:32:28.229: FOLDER TERM START 000000000b610ca8 M 000000000014e8e0 N 000000000014ea00
2021-04-11 13:32:28.229: 000000000b610ca8 e01104 M 000000000014e8e0 N 000000000014ea00 OP 308 inf2:2_computer
2021-04-11 13:32:28.229: FILE TERM START 000000000b610ca8 M 000000000014e8e0 N 000000000014ea00
2021-04-11 13:32:28.229: 000000000b610ca8 e01104 M 000000000014e8e0 N 000000000014ea00 OP 308 inf2:2_computer
2021-04-11 13:32:28.229: set high UI thread priority

After changing the macro name of filter 1 from inf to infx the same search as above
inf2:2_computer
returned the correct results and in the debug log I found these lines:

2021-04-11 13:38:48.904: search 'inf2:2_computer' filter '' sort 5 ascending 0
2021-04-11 13:38:48.904: got 1 keys
2021-04-11 13:38:48.905: 0: keys 'search' value '2_computer'
2021-04-11 13:38:48.905: macro expand **2_computer\*

Summary
The macro inf2 does not work, if a macro inf also exists.
The macro inf2 works if the macro inf is renamed to infx.

I did several tests and saw that the results were not always reproducible.

I discovered this issue when I imported my filters from Everything 1.4, where this behaviour was not present.
void
Developer
Posts: 15096
Joined: Fri Oct 16, 2009 11:31 pm

Re: Filter macro names

Post by void »

Thank you for the bug report reitwal,

I am working on a fix.
void
Developer
Posts: 15096
Joined: Fri Oct 16, 2009 11:31 pm

Re: Filter macro names

Post by void »

Everything 1.5.0.1254a fixes an issue with similarly named macros.

Please let me know if the issue persists.
reitwal
Posts: 18
Joined: Sat Apr 09, 2016 9:19 am

Re: Filter macro names

Post by reitwal »

The example above now works. Thank you very much.

But I found other examples where this problem is still there.
I have the impression that this happens if the macro name contains non-alphanumeric characters.

Example
I had 3 similar named filter macros
macro 1: sz
macro 2: sz>
macro 3: sz-

At the beginning the macro sz- did not work properly.
Then I renamed macro 2 to szz and macro 3 (sz-) began to work as expected.
The strange thing was that as soon as I changed the name of macro 2 back to sz> macro 3 still continued to work properly.
I have noticed this behaviour several times. This makes it difficult to give you a reproducible example.

All the filters above were filter functions. If I remember correctly I haven't had a problem with simple filters so far, but I'm not entirely sure.

I can't say more at the moment but I will continue to monitor this issue.

One thing I also found out is that "<" in the macro name does not work at all.
void
Developer
Posts: 15096
Joined: Fri Oct 16, 2009 11:31 pm

Re: Filter macro names

Post by void »

Thank you for the feedback reitwal,

< in the macro name will define a macro function.

Take the following filter as an example:
Search: case:param:
Macro: sz<param>

The sz<param> macro name defines a macro function, sz is the name and param is the parameter name.
param: in the search is replaced with the parameter passed to sz.

when sz:"abc 123" is called, it is replaced with case:"abc 123"

sz and sz< are treated as the same macro name (the confusion is most likely occurring here)
Everything will use the lowest alphabetically sorted filter Name when the macro is the same.

I try to be lenient with what characters you can use in the macro name.
I not going to stop you from defining names such as @ # $ % ^ & * etc..
However, < cannot be used in a macro name.

Only macros starting with [A-Za-z_] are allowed in search terms.
An example of this is: abc""mymacro:

Could you please change any macros that are using a < in the macro name (that are not being used as a macro function).
Does this fix the issue?
reitwal
Posts: 18
Joined: Sat Apr 09, 2016 9:19 am

Re: Filter macro names

Post by reitwal »

Many thanks for the detailed explanation.

I have already replaced any < in the macro names. I will also try to avoid characters like @ # $ % ^ & * > + - etc..
Right now all my macros are working properly. I will let you know if I find any more problems.

Would it be possible to add a hint to the tooltip about the usable characters for macro names?

I like to use macros instead of selecting the filter in the menu or the filter bar because that way I am sure to always have the Everything filter active when I start a new search.
void
Developer
Posts: 15096
Joined: Fri Oct 16, 2009 11:31 pm

Re: Filter macro names

Post by void »

The next update of Everything 1.5 will disable the OK button if the macro name is invalid.

Macros with an incomplete parameter are invalid.
Otherwise, any name is valid.

For example, the following macros are invalid:
mymacro<
mymacro<partial-param

For example, the following macro is valid:
mymacro<param>

Thanks for the suggestions.
Post Reply