[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 f58452e3ae: Fix 'python-shell-buffer-substring' when START is i
From: |
Eli Zaretskii |
Subject: |
emacs-29 f58452e3ae: Fix 'python-shell-buffer-substring' when START is in middle of 1st line |
Date: |
Sat, 7 Jan 2023 03:58:16 -0500 (EST) |
branch: emacs-29
commit f58452e3ae7ed595566028010128c99e3afb572b
Author: kobarity <kobarity@gmail.com>
Commit: Eli Zaretskii <eliz@gnu.org>
Fix 'python-shell-buffer-substring' when START is in middle of 1st line
* lisp/progmodes/python.el (python-shell-buffer-substring): Instead
of checking whether START is point-min, check whether START is in
the first line. (Bug#60466)
* test/lisp/progmodes/python-tests.el
(python-shell-buffer-substring-18): New test.
---
lisp/progmodes/python.el | 9 +++++----
test/lisp/progmodes/python-tests.el | 10 ++++++++++
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 59164d7d50..c399bbc64f 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -3766,15 +3766,16 @@ the python shell:
(line-beginning-position)
start))))
(substring (buffer-substring-no-properties start end))
- (starts-at-point-min-p (save-restriction
- (widen)
- (= (point-min) start)))
+ (starts-at-first-line-p (save-restriction
+ (widen)
+ (goto-char start)
+ (= (line-number-at-pos) 1)))
(encoding (python-info-encoding))
(toplevel-p (zerop (save-excursion
(goto-char start)
(python-util-forward-comment 1)
(current-indentation))))
- (fillstr (cond (starts-at-point-min-p
+ (fillstr (cond (starts-at-first-line-p
nil)
((not no-cookie)
(concat
diff --git a/test/lisp/progmodes/python-tests.el
b/test/lisp/progmodes/python-tests.el
index eac558db10..df71990278 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -4520,6 +4520,16 @@ def foo():
(python-tests-look-at "\"\"\""))
"# -*- coding: utf-8 -*-\n\nif True:\n a = 1\n b =
2\n\n"))))
+(ert-deftest python-shell-buffer-substring-18 ()
+ "Check substring from the part of the first line."
+ (python-tests-with-temp-buffer
+ "s = 'test'
+"
+ (should (string= (python-shell-buffer-substring
+ (python-tests-look-at "'test'")
+ (pos-eol))
+ "'test'"))))
+
;;; Shell completion
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-29 f58452e3ae: Fix 'python-shell-buffer-substring' when START is in middle of 1st line,
Eli Zaretskii <=