[Fix #358] Fix code completion for module identifiers in utop.el

Without those changes you won't get any completion for things like
"List.m". I'm not very familiar with the code, but it seems that the
backend returns the completion candidates without the module prefix
which caused the problem.

I've opted to fix this by handling prefixes with a "." in them specially
and this works fine in the limited testing I conducted locally.
This commit is contained in:
Bozhidar Batsov 2022-07-16 11:40:48 +03:00 committed by Rudi Grinberg
parent 1a7c112a71
commit e7b1ff36d1
1 changed files with 8 additions and 3 deletions

View File

@ -652,9 +652,14 @@ it is started."
("completion"
(catch 'done
(dolist (prefix utop-completion-prefixes)
(when (string-prefix-p prefix argument)
(push argument utop-completion)
(throw 'done t)))))
;; We need to handle specially prefixes like "List.m" as
;; the responses from utop don't include the module prefix.
(let ((prefix (if (string-match-p "\\." prefix)
(cadr (split-string prefix "\\."))
prefix)))
(when (string-prefix-p prefix argument)
(push argument utop-completion)
(throw 'done t))))))
;; End of completion
("completion-stop"
(utop-set-state 'edit)