From 8c8349e4b57e9772b673cea2594f0a1e01a6f356 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Tue, 27 Oct 2020 20:29:08 +0100 Subject: [PATCH] Tweak how `C-c C-r' computes the region in python-mode * lisp/progmodes/python.el (python-shell-buffer-substring): Don't extend the region to the start of the line (bug#39398), but allow sending the actual region as marked. --- etc/NEWS | 7 +++++++ lisp/progmodes/python.el | 6 +----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 71749d1b1ff..5e159480e00 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -239,6 +239,13 @@ the buffer cycles the whole buffer between "only top-level headings", * Changes in Specialized Modes and Packages in Emacs 28.1 +** Python mode + +*** 'C-c C-r' can now be used on arbitrary regions. +The command previously extended the start of the region to the start +of the line, but will now actually send the marked region, as +documented. + ** Ruby mode *** 'ruby-use-smie' is declared obsolete. diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 0487964d815..53542a75f58 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -3138,11 +3138,7 @@ the python shell: coding cookie is added. 4. Wraps indented regions under an \"if True:\" block so the interpreter evaluates them correctly." - (let* ((start (save-excursion - ;; Normalize start to the line beginning position. - (goto-char start) - (line-beginning-position))) - (substring (buffer-substring-no-properties start end)) + (let* ((substring (buffer-substring-no-properties start end)) (starts-at-point-min-p (save-restriction (widen) (= (point-min) start))) -- 2.39.2