Allow overriding opts context in eval-str #520
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Allow the caller of
eval-str
to explicitly specify the execution context (opts.context
) instead of having it always be replaced by thenamespace
of the active buffer.Why
I've setup for myself some global keybindings I can run from any buffer to eval code in predefined namespaces such as
user
.Here is an example of one such mapping:
This kinda works except that the auto-extracted
opts.context
can mess with this operation. An example would be if I were to be in the following situation:Then the namespace of the buffer I have open will be evaled by conjure (
(ns a.b.c)
) and so when my (reset) function fires it will fail as it sees my namespace has been loaded but none of the symbols in the namespace are loaded. So I would then need to eval buffer and try again.This is a bit of a convoluted example, but in my workflow this can be quite annoying. The main point is that the context of programatic
eval-str
calls should be controllable by the user/developer.I worked around this issue for a while by using the
conjure.client.clojure.nrepl.action
namespace directly:But this doesn't get the goodies from the higher-level
conjure.eval
implementation, which I want :)Result
After this PR I should be able to do the following in my global mapping:
And everything works as expected.