Added 2-1 chording for any command, setting working dir and passing chorded filename. I use it with http://tools.suckless.org/ii/ . Helps create chat windows (win tail -f out, win cat > in) with minimal hassle.
Leaving the comments about the code itself aside, I don't quite get the point of this. What does ii have to do with xplor?
Very short answer: nevermind, I realized that xplor's already existing "exec in body" functionality (the one that sends the path to stdout) solves my problem. Feel free to reject this pull request, and I shall delete the fork I made. Oh, and you might want to mention the B2-in-body feature in the readme or something; it would've prevented this mess I made.
Longer answer: ii doesn't have anything to do with xplor in general, it's just that I use ii through acme. Short version is that a chat window is equivalent to the commands "win cat > in" and "win tail -f out". Both of these commands are to be run in irc channel directories (which have an "in" and "out" file). Doing this from the shell is inconvenient, because one has to change dirs and reenter/paste commands. Running them from the directories opened as acme windows is also inconvenient, because the commands need to be pasted into all the windows.
In contrast, using it with xplor is more convenient, because you can "access" more than one directory at a time in the same window, therefore the commands have to be typed only once and can be executed many times. So all I needed was to somehow pass the paths of the directories/files to the commands. I observed how the Win and Xplor commands were implemented, and I thought why not generalize the 2-1 chording to any command.
Then a day after I made the pull request, I found in the code that if one clicks with B2 on a file in the window body, it sends the full path to stdout. So, I could use that to feed the path to the commands, instead of adding more code to implement a redundant feature.
To summarize, I had an interface problem that I tried to solve by adding a parameter passing functionality for any kind of command, similar to the existing Win and Xplor commands in an xplor window. I realized this can already be done with the "exec in body" thing too, without adding more code. Therefore, you may/should reject this pull request, because now even I agree that it was a bad idea. Sorry for bothering you with a redundant idea and bad code.
Hey don't beat yourself up. I'm always glad to hear that someone uses xplor and likes it, and I'm always open to suggestions. And thanks for the explanation about ii.
I kindof agree that it would be nice, for the sake of consistency with other windows, if xplor supported any command with 2-1 chording. But I don't think it would be that much of a use in the end since I don't see many commands making sense within xplor (apart from Xplor and Win), so I'm not sure it's worth spending time implementing it.
Thanks for the reminder about documenting B2, I'll do it soon.
Are you interested in doing a clean implementation of 2-1 chording for any command that would get added to the tag?
If yes, I'll leave that fork request open and wait for you to improve on it.
If no, no worries, it's not really something I need myself and I don't think it would be very useful. Just nice to have as as symmetry to other windows in acme.
Well, my own needs are covered by the B2-in-body feature just fine, and there are other coding chores that are piling up for me, so, if I had to choose between good code and no code at all, I'd vote for no code. As you said, there's no proper reason yet to implement general chording, even though it would make xplor more consistent with the surrounding interface.
I might come back to this issue later, when I will have more time, or maybe a legitimate use case, but for now, I agree with you on not implementing it. So, you can close this pull request then.
(By the way, the rationale behind the code I initially wrote was to minimize the changes to the already existing structure, and to keep it as short as possible. But that's just a fancy way to spell 'hack'.)