aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen2020-12-03 10:21:15 +0100
committerLars Ingebrigtsen2020-12-03 10:21:19 +0100
commit3e6eccc175489bec69bcdb0adc9ab12090116b79 (patch)
treef96ab26d0abe29c48e4d00e8a7235c69c178cf26 /lisp/progmodes/python.el
parent4594d6f59a0f0c229ded9874a38ae5acf9fe5647 (diff)
downloademacs-3e6eccc175489bec69bcdb0adc9ab12090116b79.tar.gz
emacs-3e6eccc175489bec69bcdb0adc9ab12090116b79.zip
Recompute error positions in python-shell-send-region
* lisp/progmodes/python.el (python-shell-send-region): Recompute line positions when evaluating (bug#22934).
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el6
1 files changed, 6 insertions, 0 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 091456aa89a..e9c3b3986aa 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -3197,6 +3197,8 @@ the python shell:
3197 (line-beginning-position) (line-end-position)))) 3197 (line-beginning-position) (line-end-position))))
3198 (buffer-substring-no-properties (point-min) (point-max))))) 3198 (buffer-substring-no-properties (point-min) (point-max)))))
3199 3199
3200(declare-function compilation-forget-errors "compile")
3201
3200(defun python-shell-send-region (start end &optional send-main msg 3202(defun python-shell-send-region (start end &optional send-main msg
3201 no-cookie) 3203 no-cookie)
3202 "Send the region delimited by START and END to inferior Python process. 3204 "Send the region delimited by START and END to inferior Python process.
@@ -3214,6 +3216,10 @@ process running; defaults to t when called interactively."
3214 (original-string (buffer-substring-no-properties start end)) 3216 (original-string (buffer-substring-no-properties start end))
3215 (_ (string-match "\\`\n*\\(.*\\)" original-string))) 3217 (_ (string-match "\\`\n*\\(.*\\)" original-string)))
3216 (message "Sent: %s..." (match-string 1 original-string)) 3218 (message "Sent: %s..." (match-string 1 original-string))
3219 ;; Recalculate positions to avoid landing on the wrong line if
3220 ;; lines have been removed/added.
3221 (with-current-buffer (process-buffer process)
3222 (compilation-forget-errors))
3217 (python-shell-send-string string process))) 3223 (python-shell-send-string string process)))
3218 3224
3219(defun python-shell-send-statement (&optional send-main msg) 3225(defun python-shell-send-statement (&optional send-main msg)