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

Update breaks autocomplete in jupyter-emacs org mode code cells #188

Open
MasonProtter opened this issue May 5, 2023 · 11 comments
Open

Comments

@MasonProtter
Copy link

I was using v0.4, but today I was trying to diagnose a problem so tried updating to the latest julia-emacs and it works fine in julia-mode, but when I open an org notebook that has jupyter-julia cells in it, completion no longer functions. Downgrading julia-emacs to v0.4 solves the issue for me.

@ronisbr
Copy link
Contributor

ronisbr commented May 5, 2023

The commit 759e8a8e572488eb7d8295bd0c3662b6c52fc3ec also broke Julia-ts-mode. Previously, I could, for example, press TAB at the beginning of the line to increase the indentation. Now, it shows the autocomplete window. Notice that I do not use TAB to autocomplete in doom emacs, but C-SPC.

If I am under a block string (""") in Julia-ts-mode, I can no longer add indentation steps inside the block string. Previously, it works by pressing TAB.

@ronisbr
Copy link
Contributor

ronisbr commented May 5, 2023

In my case, everything starts to work with this patch:

diff --git a/julia-mode.el b/julia-mode.el
index cc81343..95af6b4 100644
--- a/julia-mode.el
+++ b/julia-mode.el
@@ -918,9 +918,7 @@ buffer where the LaTeX symbol starts."
 (defun julia--company-indent-for-tab-command (arg)
   "Call `indent-for-tab-command' or `company-indent-or-complete-common'."
   (interactive "P")
-  (if company-mode
-      (company-indent-or-complete-common arg)
-    (indent-for-tab-command arg)))
+  (indent-for-tab-command arg))

 (with-eval-after-load 'company
   (define-key julia-mode-map [remap indent-for-tab-command]

I can also replace the latex symbols by typing C-SPC in Doom emacs.

Perhaps the problem is to assume that everybody is using TAB to perform completions?

ronisbr added a commit to ronisbr/doom.d that referenced this issue May 5, 2023
We need to pin julia-emacs until the following issue is fixed:

    JuliaEditorSupport/julia-emacs#188
@MasonProtter
Copy link
Author

MasonProtter commented May 9, 2023

Thanks @ronisbr that fixes it for me.


Edit: no wait, sorry that does not actually fix for me :(

@MasonProtter
Copy link
Author

Okay, I was able to bisect the issue to this commit: f359fd0 cc @non-Jedi

@ronisbr
Copy link
Contributor

ronisbr commented May 9, 2023

Hum, so maybe I am facing another issue. If so, I will open a new one here.

@non-Jedi
Copy link
Contributor

non-Jedi commented May 9, 2023

Addressing the original filed issue: don't have much free time to spend right now, but I can at least direct you towards emacs-jupyter/jupyter#236. That PR probably might not fix the issue without some cleanup since #100 developed quite a bit afterward, but it should be a reasonable starting point. The problem @ronisbr is seeing is completely separate, and I'll address in a separate reply.

EDIT: Actually glancing at emacs-jupyter/jupyter#236, it probably works as is and just needs rebased. Not going to turn it from "Draft" into a full PR until somebody tests it though, and I don't have bandwidth to do so at the moment.

@non-Jedi
Copy link
Contributor

The commit 759e8a8e572488eb7d8295bd0c3662b6c52fc3ec also broke Julia-ts-mode. Previously, I could, for example, press TAB at the beginning of the line to increase the indentation. Now, it shows the autocomplete window. Notice that I do not use TAB to autocomplete in doom emacs, but C-SPC.

If I am under a block string (""") in Julia-ts-mode, I can no longer add indentation steps inside the block string. Previously, it works by pressing TAB.

So the problem you're having is that you're using a capf backend (perhaps eglot) that can always come up with completion candidates. indent-for-tab-command first tries to indent before trying to complete (if tab-always-indent is set to 'complete); I thought this was the same thing company-indent-or-complete-common did, but it sounds like it goes the other way around and tries to complete and then falls back to indent. I think we should probably just remove this feature trying to be smart about how company users want completion to work.

non-Jedi added a commit to non-Jedi/julia-emacs that referenced this issue May 10, 2023
This just causes issues as seen with JuliaEditorSupport#188 (comment). If you're choosing to install a fairly dramatic departure from standard emacs completion like `company`, you can't expect things like `julia-mode` to go out of their way to accomodate the ways `company` breaks normal emacs completion.

The alternative would be to instead manually check `tab-always-indent` within `julia--company-indent-for-tab-command`, but I still feel like this would cause more confusion than it cures.
@tpapp
Copy link
Collaborator

tpapp commented May 10, 2023

Thanks for the quick patch @non-Jedi, just merged #192.

@MasonProtter, @ronisbr: please check if the issue is fixed for you.

@MasonProtter
Copy link
Author

EDIT: Actually glancing at nnicandro/emacs-jupyter#236, it probably works as is and just needs rebased. Not going to turn it from "Draft" into a full PR until somebody tests it though, and I don't have bandwidth to do so at the moment.

Just tried it out and autocomplete of LaTeX is still broken for me.

@MasonProtter, @ronisbr: please check if the issue is fixed for you.

Nope, that doesn't solve it for me.

@ronisbr
Copy link
Contributor

ronisbr commented May 10, 2023

Hi!

Thanks for the quick patch!

My problem is more-or-less solved because I cannot have the previous behavior.

If I use the latest commit with (setq julia-force-tab-complete t) (default), I can replace LaTeX symbols by pressing TAB. For example, "\alpha<TAB>" gives α. However, in this case, TAB always force indentation update. Hence, I am not able, for example, to increase the indentation by pressing TAB repeatedly as I could before.

If I set (setq julia-force-tab-complete nil), now I can increase the indentation by pressing TAB repeatedly. However, I lost the ability to replace LaTeX symbol by hitting TAB. In this case, I must use C-SPC, which is my default completion keystroke.

I am not saying we must revert to the old behavior. I am just saying that the behavior has changed and I am not certain if this is a bug or how the new system must work.

@non-Jedi
Copy link
Contributor

For the problem with jupyter-emacs from the OP, I did some preliminary investigation and commented in emacs-jupyter/jupyter#236. This isn't really a julia-mode bug but a bug in the downstream dependency jupyter-emacs (caused by julia-mode making a breaking change). I'd recommend closing this issue and tracking the jupyter-emacs issue in either emacs-jupyter/jupyter#236 or a new issue against the repo.

For @ronisbr point above, I'm going to open a new issue for discussion.

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

No branches or pull requests

4 participants