Hide/show toolsclient manually/automatically

Do you need the string-equality (streq) hack I’ve mentioned in my kakscript computability post)?

def list-len-eq0 -params 0 nop  # empty-list test

decl str-list str_test
def streq -params 2 %{
  set         global str_test %arg{1}
  set -remove global str_test %arg{2}
  list-len-eq0 %opt{str_test}
}

Then, you can if-then-else via exceptions:

try %{ streq %arg{1} %opt{toolsclent}
#then code
} catch %{
#else code
}

This is how I defined the +=ssl alias (aka sel-editor-live-new) in sel-editor. If toolsclient is not defined, it automatically resets to %val{client}.

You also probably need a ClientClose hook (I haven’t added added this yet to sel-editor) to remove the toolsclient setting if, well, the toolsclient closes.

My post also details a way to check for a specific exception, so you can make your if-then-else foolproof.

Final note: if you use this, please add a “namespace prefix” to all commands, so they don’t collide with other plugins.