tmux-copycat
tmux-copycat copied to clipboard
Add stored search for matching email addresses
Activate the email address search with prefix C-e
. A cursory search of the web shows this key combo doesn't appear common in tmux configurations or other add-ons.
Email address validation is in line with HTML5 http://www.w3.org/TR/2012/CR-html5-20121217/forms.html#valid-e-mail-address, with one small exception of not matching single-quote characters before the @ sign (see background for more below).
The display_text
function in the tests had to change to quote the output being echoed to avoid being processed by the shell. As a result, one of the existing tests had to be adjusted so it continued working.
This PR also adds debugging information to the tests readme.
Background on why single-quote character isn't matched:
Due to quoting in tmux's config, and how the grepping happens, emails with single-quote characters preceding the @ sign (valid emails; though presumably uncommon, given potential confusion!) will not be completely selected. The match pattern could have been double-quotes rather than single in
copycat.tmux
, but this would force!
to be escaped, and in this case, the escaping with\!
doesn't get removed. If this caveat can be fixed by someone with more tmux/plugin knowledge than me, go for it. As best I can tell, it's either have extremely complicated escaping and no!
with double-quotes or a simpler regex missing the single-quote character.
Thanks for this. From what I see it was a lot of effort, but I think this won't get accepted soon. After merging last stored search a couple weeks back I realized we're just using the global key binding namespace with some searches that aren't used as often. They "sound" convenient, but are rarely if ever used.
Also, the "cost" of adding a new stored search is just one line in tmux.conf
.
You did do a very nice job with this PR, adding tests and all. Let's wait till tmux 2.1 comes out. It will have multiple key bindings feature so we'll be able to more liberally accept new stored searches.
No problem. Take what you want or need from this PR as and when you'd like, perhaps the commit with the documentation updates.
At very least, there's about the best regex possible (with a detailed explanation!) for matching email addresses that others can copy if they'd like it.
On 18 June 2015 at 20:37, Bruno Sutic [email protected] wrote:
Thanks for this. From what I see it was a lot of effort, but I think this won't get accepted soon. After merging last stored search a couple weeks back I realized we're just using the global key binding namespace with some searches that aren't used as often. They "sound" convenient, but are rarely if ever used.
Also, the "cost" of adding a new stored search is just one line in tmux.conf.
You did do a very nice job with this PR, adding tests and all. Let's wait till tmux 2.1 comes out. It will have multiple key bindings feature so we'll be able to more liberally accept new stored searches.
— Reply to this email directly or view it on GitHub https://github.com/tmux-plugins/tmux-copycat/pull/78#issuecomment-113103499 .
Thanks!
Hi, this is a cool idea, thank you!
It happens that I have just made a PR (https://github.com/tmux-plugins/tmux-copycat/pull/91) that helps with global namespace pollution using a custom key table.
For instance, I would map your email search as prefix
+ t
+ {email-binding}. With my current config, that yields C-a t m
.
HTH