emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 3e6eccc: Recompute error positions in python-shell-send-region


From: Lars Ingebrigtsen
Subject: master 3e6eccc: Recompute error positions in python-shell-send-region
Date: Thu, 3 Dec 2020 04:21:24 -0500 (EST)

branch: master
commit 3e6eccc175489bec69bcdb0adc9ab12090116b79
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Recompute error positions in python-shell-send-region
    
    * lisp/progmodes/python.el (python-shell-send-region): Recompute
    line positions when evaluating (bug#22934).
---
 lisp/progmodes/python.el | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 091456a..e9c3b39 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -3197,6 +3197,8 @@ the python shell:
            (line-beginning-position) (line-end-position))))
       (buffer-substring-no-properties (point-min) (point-max)))))
 
+(declare-function compilation-forget-errors "compile")
+
 (defun python-shell-send-region (start end &optional send-main msg
                                        no-cookie)
   "Send the region delimited by START and END to inferior Python process.
@@ -3214,6 +3216,10 @@ process running; defaults to t when called 
interactively."
          (original-string (buffer-substring-no-properties start end))
          (_ (string-match "\\`\n*\\(.*\\)" original-string)))
     (message "Sent: %s..." (match-string 1 original-string))
+    ;; Recalculate positions to avoid landing on the wrong line if
+    ;; lines have been removed/added.
+    (with-current-buffer (process-buffer process)
+      (compilation-forget-errors))
     (python-shell-send-string string process)))
 
 (defun python-shell-send-statement (&optional send-main msg)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]