Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stored search for matching email addresses #78

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

davidjb
Copy link

@davidjb davidjb commented Jun 18, 2015

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.

davidjb added 2 commits June 18, 2015 13:47
Email address validation is in line with HTML5
http://www.w3.org/TR/2012/CR-html5-20121217/forms.html#valid-e-mail-address.  Due to quoting in tmux, emails with single-quote characters preceding the @ sign will not be completely selected.

Activate the email address search with ``prefix C-e``.
@bruno-
Copy link
Member

bruno- commented Jun 18, 2015

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.

@davidjb
Copy link
Author

davidjb commented Jun 18, 2015

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
#78 (comment)
.

@bruno-
Copy link
Member

bruno- commented Jun 18, 2015

Thanks!

@bosr
Copy link

bosr commented Jan 29, 2016

Hi, this is a cool idea, thank you!

It happens that I have just made a PR (#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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants