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.el22
1 files changed, 22 insertions, 0 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 08ef471f6b0..2956bfa0419 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -329,6 +329,7 @@ It returns a file name which can be used directly as argument of
329 ;; Shell interaction 329 ;; Shell interaction
330 (define-key map "\C-c\C-p" 'run-python) 330 (define-key map "\C-c\C-p" 'run-python)
331 (define-key map "\C-c\C-s" 'python-shell-send-string) 331 (define-key map "\C-c\C-s" 'python-shell-send-string)
332 (define-key map "\C-c\C-e" 'python-shell-send-statement)
332 (define-key map "\C-c\C-r" 'python-shell-send-region) 333 (define-key map "\C-c\C-r" 'python-shell-send-region)
333 (define-key map "\C-\M-x" 'python-shell-send-defun) 334 (define-key map "\C-\M-x" 'python-shell-send-defun)
334 (define-key map "\C-c\C-c" 'python-shell-send-buffer) 335 (define-key map "\C-c\C-c" 'python-shell-send-buffer)
@@ -368,6 +369,8 @@ It returns a file name which can be used directly as argument of
368 :help "Eval string in inferior Python session"] 369 :help "Eval string in inferior Python session"]
369 ["Eval buffer" python-shell-send-buffer 370 ["Eval buffer" python-shell-send-buffer
370 :help "Eval buffer in inferior Python session"] 371 :help "Eval buffer in inferior Python session"]
372 ["Eval statement" python-shell-send-statement
373 :help "Eval statement in inferior Python session"]
371 ["Eval region" python-shell-send-region 374 ["Eval region" python-shell-send-region
372 :help "Eval region in inferior Python session"] 375 :help "Eval region in inferior Python session"]
373 ["Eval defun" python-shell-send-defun 376 ["Eval defun" python-shell-send-defun
@@ -3162,6 +3165,25 @@ process running; defaults to t when called interactively."
3162 (message "Sent: %s..." (match-string 1 original-string)) 3165 (message "Sent: %s..." (match-string 1 original-string))
3163 (python-shell-send-string string process))) 3166 (python-shell-send-string string process)))
3164 3167
3168(defun python-shell-send-statement (&optional send-main msg)
3169 "Send the statement at point to inferior Python process.
3170The statement is delimited by `python-nav-beginning-of-statement' and
3171`python-nav-end-of-statement', but if the region is active, the text
3172in the region is sent instead via `python-shell-send-region'.
3173Optional argument SEND-MAIN, if non-nil, means allow execution of code
3174inside blocks delimited by \"if __name__ == \\='__main__\\=':\".
3175Interactively, SEND-MAIN is the prefix argument.
3176Optional argument MSG, if non-nil, forces display of a user-friendly
3177message if there's no process running; it defaults to t when called
3178interactively."
3179 (interactive (list current-prefix-arg t))
3180 (if (region-active-p)
3181 (python-shell-send-region (region-beginning) (region-end) send-main msg)
3182 (python-shell-send-region
3183 (save-excursion (python-nav-beginning-of-statement))
3184 (save-excursion (python-nav-end-of-statement))
3185 send-main msg)))
3186
3165(defun python-shell-send-buffer (&optional send-main msg) 3187(defun python-shell-send-buffer (&optional send-main msg)
3166 "Send the entire buffer to inferior Python process. 3188 "Send the entire buffer to inferior Python process.
3167When optional argument SEND-MAIN is non-nil, allow execution of 3189When optional argument SEND-MAIN is non-nil, allow execution of