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

Add IPython completion hook in julia.magic #193

Closed
wants to merge 1 commit into from

Conversation

tkf
Copy link
Member

@tkf tkf commented Aug 24, 2018

(To be rebased after #190)

image

@tkf tkf changed the title Add IPython completion hook in julia.magic WIP: Add IPython completion hook in julia.magic Aug 25, 2018
@tkf
Copy link
Member Author

tkf commented Aug 25, 2018

Adding completion to the cell magic would require ipython/ipython#10722

@tkf
Copy link
Member Author

tkf commented Aug 27, 2018

...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")
Copy link
Member Author

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)
Copy link
Member

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?

Copy link
Member Author

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.

@coveralls
Copy link

coveralls commented Sep 5, 2018

Pull Request Test Coverage Report for Build 476

  • 23 of 27 (85.19%) changed or added relevant lines in 1 file are covered.
  • 3 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.7%) to 79.159%

Changes Missing Coverage Covered Lines Changed/Added Lines %
julia/magic.py 23 27 85.19%
Files with Coverage Reduction New Missed Lines %
julia/core.py 1 84.87%
julia/find_libpython.py 2 78.15%
Totals Coverage Status
Change from base Build 469: 0.7%
Covered Lines: 414
Relevant Lines: 523

💛 - Coveralls

@tkf tkf changed the title WIP: Add IPython completion hook in julia.magic Add IPython completion hook in julia.magic Sep 6, 2018
@stevengj
Copy link
Member

@Carreau, do you have a sense of what the best approach here is for cell magic?

@Carreau
Copy link
Contributor

Carreau commented Sep 10, 2018

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.

@tkf
Copy link
Member Author

tkf commented Sep 10, 2018

@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:
https://github.com/tkf/ipyjulia_hacks/blob/579f43fb260e0c3e66f6e7b6f059aebe29a56c19/src/ipyjulia_hacks/ipy/completers.py#L89-L98

@tkf tkf closed this in #252 Mar 25, 2019
@tkf tkf deleted the ipy_completion branch March 30, 2019 17:58
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.

4 participants