Craig wrote:

>>     Next (Netscape konqueror Mozilla*) WarpToWindow 99 90
>
>This is a nice implementation of an "OR" rule, is there any way of specifying
>and "AND" rule? For example, a rule to match a window with Class "Netscape" 
>and Title "local*". Now that multiple window names can be read, why not
>include one.
>
>For example, i would want these to this expression
>All (Netscape) ThisWindow (local*) ...
>to be reduced to 
>All (Netscape local*)
>
>But this is exactly the syntax used by this patch, hence it means "OR".
>By default, all other conditions must be true, so i propose an alternate
>syntax for window name/class/resource "OR" conditions:
>All (Netscape |konqueror |Mozilla*) ...
>
>Perhaps it's not worth the effort?
>I just thought it was a little counter-intuitive.

Once you add the possibility of "AND" as well as "OR", you get into the
realm of boolean expressions, which require a parser.  For instance, if
someone can write the above, he'd naturally expect to be able to write

        Netscape local* |konqueror |Mozilla*

which presumably would be parsed with the normal boolean precedence, as

        (Netscape AND local*) OR konqueror OR Mozilla*

That sort of parser would be about thirty times as much work for me; and
I figured "OR" was far more useful than "AND" -- it was certainly the
only thing I wanted for my own use.


>This also works well with "not" commands:
>All (Netscape |konqueror |Mozilla* !Opera) ...
>will match all browsers except opera if "!Opera" is read as an "AND NOT"
>(which is subtly different to the patch syntax's implied "OR NOT")

Actually NOTs are all "AND NOT", in the patch; just leave off the '|'s,
and that line'll work fine.  (Yeah, the logic for mixing wanted
window-names with unwanted window-names is a bit confusing; my first
version of the patch, which was implemented differently, simply refused
to accept such mixtures.)  Perhaps a better way of describing it would be
to say that NOTs take priority: if any name with '!' in front of it
matches, then the condition fails, no matter what else matches or doesn't
match.

>I guess one could implement an "OR NOT" rule, but i strongly doubt the 
>usefulness of it.

Yeah, I too figured "AND NOT" was much more useful than "OR NOT".

The way I've used this patch is to program a bunch of hotkeys for
specific windows or classes of windows, and then add one final hotkey for
"all other windows":

Key F1          A  N    Next (CurrentGlobalPage xterm1) goto-window            
Key F2          A  N    Next (CurrentGlobalPage xterm2) goto-window
Key F3          A  N    Next (CurrentGlobalPage xterm3) goto-window
Key F4          A  N    Next (CurrentGlobalPage emacs) goto-window
Key F5          A  N    Next (CurrentGlobalPage Netscape konqueror Mozilla \   
                                                mozilla-bin) goto-window    
Key F6          A  N    Next (CurrentGlobalPage xdvi xpdf Xpdf gv acroread) \
                                                goto-window
Key F7          A  N    Next (CurrentGlobalPage xv ee Gimp) goto-window
Key F8          A  N    Next (CurrentGlobalPage !xterm1 !xterm2 !xterm3 \
                                          !emacs !Netscape !konqueror \
                                          !xdvi !xpdf !gv !acroread !xv !ee \
                                          !Gimp !Mozilla !mozilla-bin) \
                                                goto-window             


>I'd imagine a _full_ implementation of this would require a linked list
>of linked lists so one can specify multiple OR conditions eg.:
>All (Netscape |konqueror  http* |file* !http://www.google*)
>would match all netscape and konqueror windows with titles that start with 
>either http or file but not showing google. Note the "not google" rule needn't
>be applied to a specific list as its evaluation to true anywhere negates the
>rule.

Uh, there you're reversing the normal rule of boolean precedence, which
gives AND a higher precedence than OR.  With the normal rule, that'd be
parsed as

        Netscape OR (konqueror AND http*) OR
                        (file* AND NOT http://www.google*)

whereas you want

        (Netscape OR konqueror) AND (http* OR file*) AND NOT http://www.google*

This sort of thing is why I think the only sensible next step would be a
full-blown boolean-expression parser, which would accept parentheses as
well as AND, OR, and NOT operators, and store the boolean expression as a
tree structure.  (No, I'm too lazy to write such a thing; I don't have
any use for it.)


-- 
Norman Yarvin                                           http://yarchive.net
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [EMAIL PROTECTED]
To report problems, send mail to [EMAIL PROTECTED]

Reply via email to