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

Completion broken when running utop from emacs #455

Open
jbulow opened this issue Aug 12, 2023 · 3 comments · May be fixed by #468
Open

Completion broken when running utop from emacs #455

jbulow opened this issue Aug 12, 2023 · 3 comments · May be fixed by #468

Comments

@jbulow
Copy link

jbulow commented Aug 12, 2023

Typing Lis<TAB> correctly completes into either List or ListLabels but when typing List.<TAB> a message "No match" appears in the minibuffer.

 utop -version
The universal toplevel for OCaml, version 2.13.1, compiled for OCaml version 5.0.0

ocamlc -version
5.0.0

emacs --version
GNU Emacs 29.1.50
@steffenhaug steffenhaug linked a pull request Nov 11, 2023 that will close this issue
@rchog
Copy link

rchog commented Feb 25, 2024

I'm having this exact problem still, with utop-20230707.1535 installed from melpa today (I've had the problem for much longer but only got round to looking into it today). I also tried deleting the utop package and copying utop.el straight from this repository, with the same results. My Emacs version is 29.2. My utop version is 2.13.1 and OCaml is 5.1.1. <TAB> is bound to utop-complete.

Edit, next day: turns out I must've messed up when trying the changes in @steffenhaug's branch -- they fix the problem after all. I'll delete my extensive and pointless explanation below. Without the changes above, the completion stops in completion--nth-completion (from minibuffer.el) as no completion styles, at least in my Emacs, will match when given e.g "List.ap" as the string argument and just '("append") as the table.

@steffenhaug
Copy link

There are still some cases where my version determines the incorrect completion prefix, but if I recall correctly, the status quo is broken in the same ways. It is a start, but it would be nice to also be able to complete in the middle of the input, and in the cases where the prefix isn't correctly determined by just looking for .s.

@monkeyjunglejuice
Copy link

monkeyjunglejuice commented Apr 17, 2024

Screenshot 2024-04-17 at 20 06 59

Workaround: Turns out if you turn off merlin-mode in the utop-buffer and then enable merlin-mode again in the utop buffer, then utop suddenly gets full completions from merlin. So that means if you type List. like in the example by @jbulow, you'll see all the completion candidates from the List module (tested with Corfu). What you don't get though, are symbols defined in the source buffer.
Here's an example: the hook turns merlin-mode off and then on again:

(use-package utop
  :ensure t
  :custom
  ;; Utop will start with Dune project awareness:
  (utop-command "opam exec -- dune utop . -- -emacs")
  :hook
  (tuareg-mode . utop-minor-mode)
  ;; HACK Workaround to get completions in Utop from Merlin
  (utop-mode . (lambda ()
                 (merlin-mode -1)
                 (merlin-mode +1)))
  :bind
  ;; Reach `utop' from anywhere via global key binding
  (:map ctl-z-x-map
        ("u" . utop)))

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 a pull request may close this issue.

4 participants