Function: dape--repl-input-sender

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

Signature

(dape--repl-input-sender DUMMY-PROCESS INPUT)

Documentation

Send INPUT to DUMMY-PROCESS.

Called by comint-input-sender in dape-repl-mode.

Source Code

;; Defined in /nix/store/1fiaif8pifqj2jh65rbg3fkhg3i56q42-emacs-packages-deps/share/emacs/site-lisp/elpa/dape-0.27.1/dape.el
(defun dape--repl-input-sender (dummy-process input)
  "Send INPUT to DUMMY-PROCESS.
Called by `comint-input-sender' in `dape-repl-mode'."
  (setq input (string-trim-right input "[\n\r]+"))
  (cond
   ;; Run previous input
   ((and (string-empty-p input)
         (not (string-empty-p (car (ring-elements comint-input-ring)))))
    (when-let* ((last (car (ring-elements comint-input-ring))))
      (message "Using last input `%s'" last)
      (dape--repl-input-sender dummy-process last)))
   ;; Run command from `dape-named-commands'
   ((pcase-let* ((`(,cmd . ,args)
                  (split-string (substring-no-properties input)
                                split-string-default-separators))
                 (fn (or (alist-get cmd dape-repl-commands nil nil #'equal)
                         (and dape-repl-use-shorthand
                              (cdr (assoc cmd (dape--repl-shorthand-alist)))))))
      (cond ((eq 'dape-quit fn)
             ;; HACK: `comint-send-input' expects buffer to be live
             ;;       on `comint-input-sender' return.
             (run-with-timer 0 nil #'call-interactively #'dape-quit))
            ((and (commandp fn) args) nil)
            ((commandp fn)
             (dape--repl-insert-prompt)
             (call-interactively fn)
             t)
            (fn
             (dape--repl-insert-prompt)
             (condition-case-unless-debug err
                 (apply fn args)
               (error (dape--warn "%s" (car err))))
             t))))
   ;; Evaluate expression
   (t
    (dape--repl-insert-prompt)
    (dape-evaluate-expression
     (or (dape--live-connection 'stopped t)
         (dape--live-connection 'last))
     (string-trim (substring-no-properties input))))))