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 in the *OCaml* buffer #299

Open
Fourchaux opened this issue Sep 30, 2022 · 3 comments
Open

Completion in the *OCaml* buffer #299

Fourchaux opened this issue Sep 30, 2022 · 3 comments

Comments

@Fourchaux
Copy link

Fourchaux commented Sep 30, 2022

Configuration:
OCaml 4.14.0 - Emacs 29.0.50 - Tuareg (v20220929.1327) - Merlin - Linux Box x86_64

By default, I have no completion in the *OCaml* buffer.
Now, if I run 'M-x merlin-mode' I get the message 'Merlin mode disabled in current buffer'
and ,oh surprise, the completion appears (in this *OCaml* buffer).

So,three questions:

  • Why this (strange) behavior? Is it specific to my Emacs setup?
  • Would it be possible to have a completion by default in the OCaml REPL?

Note:
The emacs mode of Merlin provides 3 ways to achieve completion:

  • auto-complete (not tested).
  • company-mode : tested OK.
  • completion-at-point : tested OK.

Eventually, this third way (being the native completion engine of Emacs) seems a good candidate to use.

@bbatsov
Copy link
Contributor

bbatsov commented Oct 1, 2022

There's no way for Merlin to provide completion candidates directly for the top-level, as it operates on source files. utop.el uses utop's completion API to provide completion within the top-level and plays nicely with tuareg-mode.

@Fourchaux
Copy link
Author

Small experiment: (same configuration except for Tuareg now v3.0.1)

Using a very basic init.el (with tuareg, merlin, company, and NOTHING else) I get the same behavior.

e.g. with this ugly code (idem with eval-region & eval-buffer):

(defun my-tuareg-eval-phrase ()
  (interactive)
  (tuareg-eval-phrase)
  (set-buffer "*OCaml*")
  (merlin-mode))

I have the completion in the OCaml REPL. (completion-at-point alone works too).

So I guess it must be possible to properly incorporate a completion in the Tuareg's interactive mode.

@bbatsov
Copy link
Contributor

bbatsov commented Oct 7, 2022

I'll have to take a closer look at where Merlin pulls the candidates from exactly, but I can't imagine how exactly something like this will work. E.g. do completion candidates update after you load stuff in the toplevel or reload the code there? I'm also puzzled by the command you've shared - you first eval something in a source file (I presume), then set the current buffer to the REPL and you enable merlin-mode there? If merlin-mode works in the toplevel buffer you can just enable it there and be done with it.

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

2 participants