Function: dape-evaluate-expression
dape-evaluate-expression is an interactive and natively compiled
function defined in dape.el.
Signature
(dape-evaluate-expression CONN EXPRESSION &optional CONTEXT)
Documentation
Evaluate expression in current session.
If called interactively and region is active evaluate region. EXPRESSION should be a string to be evaluated in CONTEXT. CONN is inferred by either last stopped then last created connection.
Key Bindings
ctl-x-map C-a x dape-global-map x global-map C-x C-a x help-quick-use-map C-x C-a x
Source Code
;; Defined in /nix/store/1fiaif8pifqj2jh65rbg3fkhg3i56q42-emacs-packages-deps/share/emacs/site-lisp/elpa/dape-0.27.1/dape.el
(defun dape-evaluate-expression (conn expression &optional context)
"Evaluate expression in current session.
If called interactively and region is active evaluate region.
EXPRESSION should be a string to be evaluated in CONTEXT.
CONN is inferred by either last stopped then last created connection."
(interactive
(list
(or (dape--live-connection 'stopped t) (dape--live-connection 'last))
(if (region-active-p)
(buffer-substring (region-beginning) (region-end))
(let ((default (thing-at-point 'symbol)))
(read-string (format-prompt "Evaluate" default) nil nil default)))))
(dape--with-request-bind
((&whole body &key variablesReference result &allow-other-keys) error)
(dape--evaluate-expression conn (plist-get (dape--current-stack-frame conn) :id)
expression (or context "repl"))
(cond
(error
(if (string-empty-p error)
(dape--warn "Failed to evaluate `%s'" (substring-no-properties expression))
(dape--repl-insert-error (concat (string-trim-right error) "\n"))))
((and (get-buffer "*dape-repl*")
(numberp variablesReference)
(not (zerop variablesReference)))
(dape--repl-insert
(concat (dape--repl-variable (plist-put body :name expression)) "\n")))
(t
;; Refresh is needed as evaluate can change values
(dape--update conn 'variables nil)
(dape--repl-insert (concat result "\n"))))))