Function: dape--repl-insert

dape--repl-insert is a natively compiled function defined in dape.el.

Signature

(dape--repl-insert STRING)

Documentation

Insert STRING into REPL.

If REPL buffer is not live STRING will be displayed in minibuffer.

Source Code

;; Defined in /nix/store/1fiaif8pifqj2jh65rbg3fkhg3i56q42-emacs-packages-deps/share/emacs/site-lisp/elpa/dape-0.27.1/dape.el
(defun dape--repl-insert (string)
  "Insert STRING into REPL.
If REPL buffer is not live STRING will be displayed in minibuffer."
  (when (stringp string)
    (if-let* ((buffer (get-buffer "*dape-repl*")))
        (with-current-buffer buffer
          (save-excursion
            (let (start)
              (if comint-last-prompt
                  (goto-char (marker-position (car comint-last-prompt)))
                (goto-char (point-max)))
              (setq start (point-marker))
              (let ((inhibit-read-only t))
                (insert string))
              ;; XXX Inserting at position of `comint-last-prompt'...
              (when comint-last-prompt
                (move-marker (car comint-last-prompt) (point)))
              ;; ...and process marker forcing us to move marker by hand.
              (when-let* ((process (get-buffer-process buffer)))
                (set-marker (process-mark process)
                            (+ (point) (length dape--repl-prompt))))
              ;; HACK Run hooks as if `comint-output-filter' was executed
              (let ((comint-last-output-start start))
                (run-hook-with-args 'comint-output-filter-functions string)))))
      ;; Fallback to `message' if no repl buffer
      (message (string-trim string)))))