emacs-diffs
[Top][All Lists]
Advanced

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

master 0d8c6df 2/2: Tweak previous python-mode region fix


From: Lars Ingebrigtsen
Subject: master 0d8c6df 2/2: Tweak previous python-mode region fix
Date: Fri, 30 Oct 2020 11:16:03 -0400 (EDT)

branch: master
commit 0d8c6df6c1f5e1150b34d4a57acee25471b47340
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Tweak previous python-mode region fix
    
    * lisp/progmodes/python.el (python-shell-buffer-substring): Tweak
    the previous fix for bug#39398 to behave somewhat more like it
    used to.
---
 lisp/progmodes/python.el | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 53542a7..53b6540 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -3138,7 +3138,18 @@ the python shell:
      coding cookie is added.
   4. Wraps indented regions under an \"if True:\" block so the
      interpreter evaluates them correctly."
-  (let* ((substring (buffer-substring-no-properties start end))
+  (let* ((start (save-excursion
+                  ;; If we're at the start of the expression, and
+                  ;; there's just blank space ahead of it, then expand
+                  ;; the region to include the start of the line.
+                  ;; This makes things work better with the rest of
+                  ;; the data we're sending over.
+                  (goto-char start)
+                  (if (string-blank-p
+                       (buffer-substring (line-beginning-position) start))
+                      (line-beginning-position)
+                    start)))
+         (substring (buffer-substring-no-properties start end))
          (starts-at-point-min-p (save-restriction
                                   (widen)
                                   (= (point-min) start)))



reply via email to

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