Enable hook only for specific client

How can I enable a NormalIdle hook only for the current client? For example in my sel-editor, when enabling live-updating for the *selections* summary buffer, I want a NormalHook that applies only to the client that called live-enable; not to other clients, and certainly not to toolsclient (which is where the *selections* buffer is supposed to be displayed).

Should I set up hooks for FocusIn / FocusOut with the current ^%val{client}$ as a regex (hooks which, in turn, enable / disable a global NormalIdle hook)? Is the client name usable as a regex directly like that?

One thing you might be able to do is

hook global NormalIdle .* %{
  trigger-user-hook "%val{client}-selections-idle"

hook global User "(?!%opt{toolsclient})-selections-idle" %{

The contexts might get a little wierd though. When I was playing around with this I noticed a trigger-user-hook in a global hook didn’t trigger a window User hook unless you were in the same window (for example).

1 Like