From: Eshel Yaron Date: Tue, 14 Nov 2023 08:47:15 +0000 (+0100) Subject: Narrow to current query for top-level completion at point X-Git-Tag: V9.1.19-sweep-0.27.1~5 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c1cf491c117c84230b1761a3d78ef98fe6273072;p=sweep.git Narrow to current query for top-level completion at point * sweeprolog.el (sweeprolog-top-level-completion-at-point): New function. (sweeprolog-top-level-mode): Use it. --- diff --git a/sweeprolog.el b/sweeprolog.el index 73dbb0d..00822e3 100644 --- a/sweeprolog.el +++ b/sweeprolog.el @@ -3596,6 +3596,12 @@ GOAL. Otherwise, GOAL is set to a default value specified by sweeprolog-top-level-signal-default-goal))) (sweeprolog-signal-thread sweeprolog-top-level-thread-id goal)) +(defun sweeprolog-top-level-completion-at-point () + "Call `sweeprolog-completion-at-point' while narrowing to current query." + (when-let ((prompt-beg (car comint-last-prompt))) + (with-restriction prompt-beg (point-max) + (sweeprolog-completion-at-point)))) + ;;;###autoload (define-derived-mode sweeprolog-top-level-mode comint-mode "Sweep Top-level" "Major mode for interacting with an inferior Prolog interpreter." @@ -3610,7 +3616,7 @@ GOAL. Otherwise, GOAL is set to a default value specified by comint-highlight-input nil comment-start "%") (add-hook 'post-self-insert-hook #'sweeprolog-top-level--post-self-insert-function nil t) - (add-hook 'completion-at-point-functions #'sweeprolog-completion-at-point nil t) + (add-hook 'completion-at-point-functions #'sweeprolog-top-level-completion-at-point nil t) (add-hook 'after-change-functions #'sweeprolog-colourise-query nil t) (add-hook 'xref-backend-functions #'sweeprolog--xref-backend nil t) (when (and (member sweeprolog-faces-style '(light dark))