Skip to content

Commit

Permalink
Replace utop-complete with a dispatch function
Browse files Browse the repository at this point in the history
This function either sends the request for completion to utop and lets
the company backend take care of the rest, or calls
`completion-at-point`.
  • Loading branch information
j-shilling committed Dec 2, 2022
1 parent ee7ac41 commit 3d0b249
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/top/utop.el
Original file line number Diff line number Diff line change
Expand Up @@ -721,9 +721,8 @@ If ADD-TO-HISTORY is t then the input will be added to history."
(utop-send-string (concat "data:" line "\n")))
(utop-send-string "end:\n")))

(defun utop-complete ()
"Complete current input."
(interactive)
(defun utop-complete-start ()
"Conditionally begins to request completion candidates from utop."
;; Complete only if the cursor is after the prompt
(when (and (eq utop-state 'edit) (>= (point) utop-prompt-max))
;; Use this buffer
Expand All @@ -735,7 +734,7 @@ If ADD-TO-HISTORY is t then the input will be added to history."
(defun utop-completion-at-point ()
"Complete thing at point."
(setq utop-capf-completion-candidates nil)
(utop-complete)
(utop-complete-start)

(let ((elapsed-time 0))
(while (and (eq utop-state 'comp)
Expand All @@ -749,6 +748,13 @@ If ADD-TO-HISTORY is t then the input will be added to history."
(point)
utop-capf-completion-candidates)))

(defun utop-complete ()
"Complete current input."
(interactive)
(if (utop--supports-company)
(utop-complete-start)
(completion-at-point)))

;; +-----------------------------------------------------------------+
;; | Eval |
;; +-----------------------------------------------------------------+
Expand Down

0 comments on commit 3d0b249

Please sign in to comment.