             'intero-linkify-process-output
             t t)
   (setq-local comint-prompt-read-only t)
+  (add-hook 'completion-at-point-functions 'intero-completion-at-point nil t)
   (add-to-list (make-local-variable 'company-backends) 'intero-company)
   (company-mode))
 

  (if intero-mode
      (progn (flycheck-select-checker 'intero)
             (flycheck-mode)
             (add-to-list (make-local-variable 'company-backends) 'intero-company)
             (company-mode)
             (setq-local eldoc-documentation-function 'intero-eldoc))

  "In BUFFER, call FUNC with ARGS."
  (with-current-buffer buffer
    (apply func args)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Traditional completion-at-point function

(defun intero-completion-at-point ()
  "A (blocking) function suitable for use in `completion-at-point-functions'."
  (let ((prefix-info (intero-completions-grab-prefix)))
    (when prefix-info
      (cl-destructuring-bind
          (beg end prefix _type) prefix-info
        (let ((completions
               (intero-completion-response-to-list
                (intero-blocking-call
                 'backend
                 (format ":complete repl %S" prefix)))))
          (when completions
            (list beg end completions)))))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Company integration (auto-completion)
