From: Lars Ingebrigtsen Date: Tue, 27 Oct 2020 19:29:08 +0000 (+0100) Subject: Tweak how `C-c C-r' computes the region in python-mode X-Git-Tag: emacs-28.0.90~5377 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8c8349e4b57e9772b673cea2594f0a1e01a6f356;p=emacs.git 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. --- 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)))