Skip to content

Add supporting middleware op for magic requires? #215

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

Closed
expez opened this issue Aug 27, 2015 · 2 comments
Closed

Add supporting middleware op for magic requires? #215

expez opened this issue Aug 27, 2015 · 2 comments

Comments

@expez
Copy link
Member

expez commented Aug 27, 2015

In most projects the use of aliases are consistent (and we should try to nudge people in that direction if they are not). How about making a middleware op to get the alias mappings in the current project and use those to serve up suggestions for magic require?

So if there's some ns on the disk called com.acme.utils which we've seen aliased as util then when the user types util/frobnicate we can prompt if they'd like com.acme.utils added to the ns form.

@Malabarba
Copy link
Member

when the user types util/frobnicate we can prompt if they'd like com.acme.utils added to the ns form

Better not prompt while the user is in the middle of typing. Since magic-requires is already an existing feature, it's probably safe to make it smarter without bothering the user.

@expez
Copy link
Member Author

expez commented Aug 27, 2015

Better not prompt while the user is in the middle of typing.

cljr-magic-requires is either gogogo, prompt or off :)

expez added a commit that referenced this issue Aug 28, 2015
- Without middleware everything works as before.
- `cljr-magic-require-namespaces` is now more of a seed value and if the
  middleware is active only plays a role in new projects.
- On ambiguous aliases we prompt for resolution.  Hopefully this will drive
  users to pick unique aliases which improves readability.
- We keep a cache of aliases around, to keep things snappy.  On larger
  projects the aliases are probably fairly stable.
- The cache is updated,async, on repl init and everytime `clean-ns` is called.

If the caching proves to be annoying we can change this easily to be a
sync request for fresh data. If *that* proves too slow we can also
easily cache the alias data in the middleware so we don't gather alias
data from files that are unchanged since last scan.
@expez expez closed this as completed in 33dd39d Aug 29, 2015
expez added a commit that referenced this issue Aug 29, 2015
[Fix #215] Add middleware op for magic requires
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