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

RegEx Replace Factoids #36

Open
brigand opened this issue Feb 21, 2014 · 3 comments
Open

RegEx Replace Factoids #36

brigand opened this issue Feb 21, 2014 · 3 comments

Comments

@brigand
Copy link
Contributor

brigand commented Feb 21, 2014

These would be semi-dynamic factoids. A simple example:

<USER> !learn s/lodash (\w+)/_.\1 http://devdocs.io/lodash/index#\1
<USER> !lodash throttle
<bot>  USER: _.throttle http://devdocs.io/lodash/index#throttle
<USER> !lodash map
<bot>  USER: _.map http://devdocs.io/lodash/index#map

If someone gives me the go-ahead, I'll implement it.

Pattern must start with three or more non-dynamic characters followed by a space, e.g. "lodash ". This'll be used to speed up look-up time, by not executing the expression until a match is likely

@ljharb
Copy link
Member

ljharb commented Feb 21, 2014

Non-perfect-matching factoids already show all matching factoids - wouldn't this risk reducing a near-infinite namespace to existing keys plus a few cleverly crafter regexes?

@brigand
Copy link
Contributor Author

brigand commented Feb 21, 2014

Okay, here's an alternate suggestion with that in mind.

<USER> !!learn lodash {{0}} = _.{{0}} http://devdocs.io/lodash/index#{{0}}
<USER> !! lodash throttle
<bot>  USER: _.throttle http://devdocs.io/lodash/index#throttle
<USER> !! lodash map
<bot>  USER: _.map http://devdocs.io/lodash/index#map
<USER> !lodash
<bot>  USER: the default lodash factoid or the usual help prompt

Up to {{2}} may be used (not sure if that's even needed); it's restricted to a new !! namespace (which could still technically collide with !learn ! foo = something, but good enough).

@ljharb, still don't like it, or are there any outstanding problems with this?

@ljharb
Copy link
Member

ljharb commented Feb 21, 2014

Certainly if you're making a new namespace, there's no collision issue. My next question is, what use case is this solving? I can already do !g lodash throttle which links me to the docs, for example.

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

No branches or pull requests

2 participants