ocaml / merlin

Context sensitive completion for OCaml in Vim and Emacs
https://ocaml.github.io/merlin/
MIT License
1.57k stars 233 forks source link

Identifier renaming also for Emacs? #1738

Open dunric opened 6 months ago

dunric commented 6 months ago

Vim's plugin offers a command to rename an identifier under a cursor (or passed as an argument), however I can't find a similar feature for Emacs. There is support for finding/highlight of identifier's occurrences but no for renaming?

edit: Reference to current Vim's implementation: merlin_find#IncrementalRename()

voodoos commented 6 months ago

I would expect there to be a standard way to rename occurrences from the occur-mode but maybe I am wrong ? @xvw do you use the standard merlin-mode for Emacs ? Do you know if such a feature exists ?

Anyway if it doesn't exists natively we would welcome a PR adding support for renaming :-)

xvw commented 6 months ago

From my knowledge of occur, you can only use regular expressions to match specific lines and I must confess I don't know how to use them at all (and I don't think it's possible to rename).

In general, when I want to rename an identifier, I use xref-find-references-and-replace which uses merlin-occurences to find the occurrences of the term to be replaced.

dunric commented 6 months ago

@xvw It seems xref-find-references-and-replace can mitigate the issue. Strange it didn't worked until merlin-eldoc package was installed.

xvw commented 6 months ago

Indeed, I use Doom-emacs with the OCaml layout that includes merlin-eldoc. Interesting that it only works if eldoc is installed. I'll investigate.