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

feat(projectile-rails-choices): use all matches #126

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

danielma
Copy link
Contributor

Allow regular expressions with more than one match group, and
concatenate them to create the final string.

This is useful for me for finding nested resources with similar paths,
and building short selectors based only on the unique elements.

The best example is finding JS components inside the app/javascripts
directory.

The application I work on has two main interfaces, one for
admins, and one for regular consumers. So we have components both
inside the app/javascripts/admin/components and
app/javascripts/consumer/components directories.

With this change, I can do something like

(projectile-rails-find-resource
  "component: "
  '(("app/javascripts/" "/javascripts/\\(.+/\\)components/\\(.+\\).js$")))

and this will generate a list like

admin/money_input
consumer/money_input
shared/error_container

@asok
Copy link
Owner

asok commented Aug 3, 2018

Hi @danielma first of all I'm sorry for responding so late.
Do you think that some of the built-in projectile-rails-find-.*-resource commands would improve from this change? If not I'm afraid I would not merge it. It's a smart solution but it would just make the code a bit more complex without any benefit.

@Silex what do you think?

@danielma
Copy link
Contributor Author

danielma commented Aug 6, 2018

@asok 🤔 honestly, no I don't think any of the built-ins would be improved by this change. I feel like my use case is common but not standard.

This is definitely a projectile-rails power user feature. I have a bunch of extra projectile-rails-find-* commands that I've defined for myself.

If it doesn't seem like it will benefit the project and you decide not to merge, no hard feelings. Thanks for taking a look

@danielma danielma force-pushed the dma/use-all-matches-for-finding-resource branch from 9308625 to ea72ae7 Compare August 13, 2018 20:57
Allow regular expressions with more than one match group, and
concatenate them to create the final string.

This is useful for me for finding nested resources with similar paths,
and building short selectors based only on the unique elements.

The best example is finding JS components inside the `app/javascripts`
directory.

The application I work on has two main interfaces, one for
admins, and one for regular consumers. So we have components both
inside the `app/javascripts/admin/components` and
`app/javascripts/consumer/components` directories.

With this change, I can do something like

```elisp
(projectile-rails-find-resource
  "component: "
  '(("app/javascripts/" "/javascripts/\\(.+/\\)components/\\(.+\\).js$")))
```

and this will generate a list like

```
admin/money_input
consumer/money_input
shared/error_container
```
@danielma danielma force-pushed the dma/use-all-matches-for-finding-resource branch from ea72ae7 to 24a2c23 Compare March 7, 2019 23:54
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.

None yet

2 participants