Page 1 of 1

"-" as master invert operator?

Posted: 23 Sep 2021 13:15
by admin
Currently the first ! is interpreted as a master invert for the entire pattern; that leaves a blatant hole:

Code: Select all

Size: 529 KB | Ext: txt   => (Size = 529 KB) OR (Extension = "txt")
Size: 529 KB | !Ext: txt  => (Size = 529 KB) OR NOT (Extension = "txt")
!Size: 529 KB | Ext: txt  => NOT ((Size = 529 KB) OR (Extension = "txt"))
--- missing ---           => NOT (Size = 529 KB) OR (Extension = "txt")
Idea: Should we introduce - as master invert operator?

Code: Select all

Size: 529 KB | Ext: txt   => (Size = 529 KB) OR (Extension = "txt")
Size: 529 KB | !Ext: txt  => (Size = 529 KB) OR NOT (Extension = "txt")
!Size: 529 KB | Ext: txt  => NOT (Size = 529 KB) OR (Extension = "txt")
-Size: 529 KB | Ext: txt  => NOT ((Size = 529 KB) OR (Extension = "txt"))

Re: "-" as master invert operator?

Posted: 23 Sep 2021 13:18
by admin
PS: For find patterns there is a tweak FindAllowMasterInvert which is 0 by default. Whereas for filter patterns it's currently hard-coded to YES (AllowMasterInvert). So there is an inconsistency as well.

Re: "-" as master invert operator?

Posted: 23 Sep 2021 13:26
by Horst
Sound like a good idea
but the current meaning of ! will change and may be a surprise for some users.

Re: "-" as master invert operator?

Posted: 23 Sep 2021 14:22
by admin
I could handle this by a tweak (auto-set on upgrade) that preserves the old functionality.

Re: "-" as master invert operator?

Posted: 24 Sep 2021 11:16
by eil
while i understand the idea behind the change, why not simply add "!!" as master invert, or make a rule that "!term" = "invert this one", "! term"(must have space) = "master invert".
this way no need for a tweak and any user understands "!" as invert, unlike "-".

Re: "-" as master invert operator?

Posted: 24 Sep 2021 12:25
by admin
I had thought about that, but

a) "!!" is NOT NOT and eats itself (that's what users would rightfully expect).

b) Currently you can use ! term to look for NOT " term", so the space is part of the string.

Re: "-" as master invert operator?

Posted: 24 Sep 2021 12:33
by admin
But here is another idea. Currently Filters don't support complex syntax with parentheses (like Find Files does), but I could make filters understand one simple case:
!(Size: 529 KB | Ext: txt)

Okay, this would destroy the possibility to do something like NOT "(a*)" since !(a*) would be parsed as !a*. But you could escape the parentheses (one of them is enough): !\(a*). So, I don't see many problems here.

Re: "-" as master invert operator?

Posted: 24 Sep 2021 12:42
by highend
Currently Filters don't support complex syntax with parentheses (like Find Files does)
and if you change that?

I'd find !(...) the best and most logical way to do a global negation and parentheses would be a good way to group things anyway...

Re: "-" as master invert operator?

Posted: 24 Sep 2021 12:51
by admin
As you may have noted, the various areas are becoming more and more similar and consistent (and internally more and more use the same code, of course). So one day the complex Boolean syntax with parentheses will be supported all over the place.

(Due to the high degree of optimization, especially in Find Files, this cannot be done quickly.)

Re: "-" as master invert operator?

Posted: 30 Sep 2021 12:17
by Evolve
How about human-readable python-like operators?
Size: 529 KB or Ext: txt
Size: 529 KB or not Ext: txt
not Size: 529 KB or Ext: txt
not (Size: 529 KB or Ext: txt)

Re: "-" as master invert operator?

Posted: 30 Sep 2021 12:19
by admin
Apart from "not " in filters it's all there already.

PS: Next beta "not " is supported everywhere.