From e99219b98e1de69f51a2d285bd59c58a29d47d26 Mon Sep 17 00:00:00 2001 From: Juergen Hoetzel Date: Thu, 23 Jan 2025 18:51:19 +0100 Subject: [PATCH] Emacs completion: Include module prefix in completion candidates Fixes a mismatch of the completion START position in the Emacs buffer and the candidatates that didn't include the expected module-prefix. Fixes #455 --- src/top/utop.el | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/top/utop.el b/src/top/utop.el index b473cf6c..f6e6144c 100644 --- a/src/top/utop.el +++ b/src/top/utop.el @@ -604,12 +604,10 @@ it is started." (dolist (prefix utop-completion-prefixes) ;; 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)))))) + (when-let* ((pos (string-match "[^.]*$" prefix)) + ((string-prefix-p (substring prefix pos) argument))) + (push (concat (substring prefix 0 pos) argument) utop-completion) + (throw 'done t))))) ;; End of completion ("completion-stop" (utop-set-state 'edit)