Function: python-shell-send-block
python-shell-send-block is an interactive and byte-compiled function
defined in python.el.gz.
Signature
(python-shell-send-block &optional ARG MSG)
Documentation
Send the block at point to inferior Python process.
The block is delimited by python-nav-beginning-of-block and
python-nav-end-of-block. If optional argument ARG is non-nil
(interactively, the prefix argument), send the block body with
its header. If optional argument MSG is non-nil, force display
of a user-friendly message if there's no process running; this
always happens interactively.
Probably introduced at or before Emacs version 30.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/python.el.gz
(defun python-shell-send-block (&optional arg msg)
"Send the block at point to inferior Python process.
The block is delimited by `python-nav-beginning-of-block' and
`python-nav-end-of-block'. If optional argument ARG is non-nil
\(interactively, the prefix argument), send the block body with
its header. If optional argument MSG is non-nil, force display
of a user-friendly message if there's no process running; this
always happens interactively."
(interactive (list current-prefix-arg t))
(let ((beg (save-excursion
(when (python-nav-beginning-of-block)
(if arg
(beginning-of-line)
(python-nav-end-of-statement)
(beginning-of-line 2)))
(point-marker)))
(end (save-excursion (python-nav-end-of-block)))
(python-indent-guess-indent-offset-verbose nil))
(if (and beg end)
(python-shell-send-region beg end nil msg t)
(user-error "Can't get code block from current position"))))