aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el25
1 files changed, 25 insertions, 0 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index ecbec18f518..57cdf68fc25 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -350,6 +350,7 @@ To customize the Python interpreter for interactive use, modify
350 (define-key map "\C-c\C-e" #'python-shell-send-statement) 350 (define-key map "\C-c\C-e" #'python-shell-send-statement)
351 (define-key map "\C-c\C-r" #'python-shell-send-region) 351 (define-key map "\C-c\C-r" #'python-shell-send-region)
352 (define-key map "\C-\M-x" #'python-shell-send-defun) 352 (define-key map "\C-\M-x" #'python-shell-send-defun)
353 (define-key map "\C-c\C-b" #'python-shell-send-block)
353 (define-key map "\C-c\C-c" #'python-shell-send-buffer) 354 (define-key map "\C-c\C-c" #'python-shell-send-buffer)
354 (define-key map "\C-c\C-l" #'python-shell-send-file) 355 (define-key map "\C-c\C-l" #'python-shell-send-file)
355 (define-key map "\C-c\C-z" #'python-shell-switch-to-shell) 356 (define-key map "\C-c\C-z" #'python-shell-switch-to-shell)
@@ -390,6 +391,8 @@ To customize the Python interpreter for interactive use, modify
390 :help "Switch to running inferior Python process"] 391 :help "Switch to running inferior Python process"]
391 ["Eval string" python-shell-send-string 392 ["Eval string" python-shell-send-string
392 :help "Eval string in inferior Python session"] 393 :help "Eval string in inferior Python session"]
394 ["Eval block" python-shell-send-block
395 :help "Eval block in inferior Python session"]
393 ["Eval buffer" python-shell-send-buffer 396 ["Eval buffer" python-shell-send-buffer
394 :help "Eval buffer in inferior Python session"] 397 :help "Eval buffer in inferior Python session"]
395 ["Eval statement" python-shell-send-statement 398 ["Eval statement" python-shell-send-statement
@@ -4141,6 +4144,27 @@ interactively."
4141 (save-excursion (python-nav-end-of-statement)) 4144 (save-excursion (python-nav-end-of-statement))
4142 send-main msg t))) 4145 send-main msg t)))
4143 4146
4147(defun python-shell-send-block (&optional arg msg)
4148 "Send the block at point to inferior Python process.
4149The block is delimited by `python-nav-beginning-of-block' and
4150`python-nav-end-of-block'. When optional argument ARG is non-nil, send
4151the block body without its header. When optional argument MSG is
4152non-nil, forces display of a user-friendly message if there's no process
4153running; defaults to t when called interactively."
4154 (interactive (list current-prefix-arg t))
4155 (let ((beg (save-excursion
4156 (when (python-nav-beginning-of-block)
4157 (if (null arg)
4158 (beginning-of-line)
4159 (python-nav-end-of-statement)
4160 (beginning-of-line 2)))
4161 (point-marker)))
4162 (end (save-excursion (python-nav-end-of-block)))
4163 (python-indent-guess-indent-offset-verbose nil))
4164 (if (and beg end)
4165 (python-shell-send-region beg end nil msg t)
4166 (user-error "Can't get code block from current position."))))
4167
4144(defun python-shell-send-buffer (&optional send-main msg) 4168(defun python-shell-send-buffer (&optional send-main msg)
4145 "Send the entire buffer to inferior Python process. 4169 "Send the entire buffer to inferior Python process.
4146When optional argument SEND-MAIN is non-nil, allow execution of 4170When optional argument SEND-MAIN is non-nil, allow execution of
@@ -7181,6 +7205,7 @@ implementations: `python-mode' and `python-ts-mode'."
7181 python-nav-if-name-main 7205 python-nav-if-name-main
7182 python-nav-up-list 7206 python-nav-up-list
7183 python-remove-import 7207 python-remove-import
7208 python-shell-send-block
7184 python-shell-send-buffer 7209 python-shell-send-buffer
7185 python-shell-send-defun 7210 python-shell-send-defun
7186 python-shell-send-statement 7211 python-shell-send-statement