kakounedotcom / connect.kak

Connect a program to Kakoune clients
https://kakoune.org
The Unlicense
88 stars 18 forks source link

Focus back -- updates from review #15

Closed xxxserxxx closed 4 years ago

xxxserxxx commented 4 years ago

This version: (1) retains tmux support, and (2) retains the ability for users to control refocus based on buffer conditions -- e.g., filetype.

The env files don't get the $kak_opt_* variables unless they're passed in, so I still needed to modify the wrapper; as requested, instead of exporting in connect.kak in imports an env file that does the same thing, sort of.

I changed the logic from a confusing nested if to two separate cases. This has two effects:

  1. It's easier to read
  2. It collects all send commands into one place, as your code did
  3. It's less efficient because it always evaluates at least 2 boolean expressions, and in half the cases, always evaluates 4.

It was necessary to retain the focus for tmux after the send command. The alternative would be to call send twice and use the nested ifs. Despite the unnecessary extra boolean tests, I prefer this version, and it's not in a loop so it probably doesn't matter much.

I don't know git well enough to rebase this cleanly into a single commit, while retaining the merge from your master. Sorry about that.

alexherbo2 commented 4 years ago