-
Notifications
You must be signed in to change notification settings - Fork 102
Add IPython completion hook in julia.magic #193
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
Adding completion to the cell magic would require ipython/ipython#10722 |
...or I can monkey-patch IPython 😛 https://github.com/tkf/ipyjulia_hacks |
julia/magic.py
Outdated
@@ -80,3 +111,9 @@ def julia(self, line, cell=None): | |||
def load_ipython_extension(ip): | |||
"""Load the extension in IPython.""" | |||
ip.register_magics(JuliaMagics) | |||
ip.set_hook("complete_command", julia_completer, | |||
re_key="%?%julia") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it does not work with cell magic, just use str_key="%julia"
.
julia/magic.py
Outdated
return String[] | ||
end | ||
end | ||
""")(julia_code, julia_pos) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we eval
this function once and cache it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I use cached_property
in my ipyjulia_hacks
. Something like this can be done here. https://github.com/tkf/ipyjulia_hacks/blob/679f6bbd3ed202cde6ec6ebb4b1b537566531cdf/src/ipyjulia_hacks/completers.py#L19
But could you review #190 first? I think that's more fundamental and important. But that PR, in turn, depends on #188.
Pull Request Test Coverage Report for Build 476
💛 - Coveralls |
@Carreau, do you have a sense of what the best approach here is for cell magic? |
Well, tab completion and monkey patching seem like a good approach for now. refactoring, improving and getting for improving completion is in my goals. I don't have anything short term solution though. |
@Carreau Can't wait to see ipython/ipython#10722 (or similar mechanism) arrive on IPython master! @stevengj Do you want the monkey-patch in this PR? This is how I did it: |
(To be rebased after #190)