[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-24 433af0a: * lisp/progmodes/python.el (python-shell
From: |
Fabián Ezequiel Gallina |
Subject: |
[Emacs-diffs] emacs-24 433af0a: * lisp/progmodes/python.el (python-shell-buffer-substring): Handle |
Date: |
Sat, 27 Dec 2014 20:22:39 +0000 |
branch: emacs-24
commit 433af0a06089885f5a57ef0f3e7d6283e8d51bd5
Author: Fabián Ezequiel Gallina <address@hidden>
Commit: Fabián Ezequiel Gallina <address@hidden>
* lisp/progmodes/python.el (python-shell-buffer-substring): Handle
cornercase when region sent starts at point-min.
---
lisp/ChangeLog | 5 +++++
lisp/progmodes/python.el | 19 +++++++++----------
test/ChangeLog | 4 ++++
test/automated/python-tests.el | 21 +++++++++++++++++++++
4 files changed, 39 insertions(+), 10 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index cf866fa..4b8f8f6 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2014-12-27 Fabián Ezequiel Gallina <address@hidden>
+
+ * progmodes/python.el (python-shell-buffer-substring): Handle
+ cornercase when region sent starts at point-min.
+
2014-12-27 Eli Zaretskii <address@hidden>
* language/misc-lang.el (composition-function-table): Add Syriac
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 4a4e320..0d80110 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -2523,17 +2523,16 @@ the python shell:
4. Wraps indented regions under an \"if True:\" block so the
interpreter evaluates them correctly."
(let* ((substring (buffer-substring-no-properties start end))
- (buffer-substring-p (save-restriction
- (widen)
- (not (equal (list (point-min) (point-max))
- (list start end)))))
+ (starts-at-point-min-p (save-restriction
+ (widen)
+ (= (point-min) start)))
(encoding (python-info-encoding))
- (fillstr (concat
- (when buffer-substring-p
- (format "# -*- coding: %s -*-\n" encoding))
- (make-string
- (- (line-number-at-pos start)
- (if buffer-substring-p 2 1)) ?\n)))
+ (fillstr (when (not starts-at-point-min-p)
+ (concat
+ (format "# -*- coding: %s -*-\n" encoding)
+ (make-string
+ ;; Substract 2 because of the coding cookie.
+ (- (line-number-at-pos start) 2) ?\n))))
(toplevel-block-p (save-excursion
(goto-char start)
(or (zerop (line-number-at-pos start))
diff --git a/test/ChangeLog b/test/ChangeLog
index 101e9d9..74d4677 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,5 +1,9 @@
2014-12-27 Fabián Ezequiel Gallina <address@hidden>
+ (python-shell-buffer-substring-9): New test.
+
+2014-12-27 Fabián Ezequiel Gallina <address@hidden>
+
* automated/python-tests.el (python-shell-buffer-substring-1)
(python-shell-buffer-substring-2, python-shell-buffer-substring-3)
(python-shell-buffer-substring-4, python-shell-buffer-substring-5)
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el
index 8fcda58..a494857 100644
--- a/test/automated/python-tests.el
+++ b/test/automated/python-tests.el
@@ -2651,6 +2651,27 @@ class Foo(models.Model):
pass
"))))
+(ert-deftest python-shell-buffer-substring-9 ()
+ "Check substring starting from `point-min'."
+ (python-tests-with-temp-buffer
+ "# coding: utf-8
+
+class Foo(models.Model):
+ pass
+
+class Bar(models.Model):
+ pass
+"
+ (should (string= (python-shell-buffer-substring
+ (point-min)
+ (python-tests-look-at "class Bar(models.Model):"))
+ "# coding: utf-8
+
+class Foo(models.Model):
+ pass
+
+"))))
+
;;; Shell completion
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] emacs-24 433af0a: * lisp/progmodes/python.el (python-shell-buffer-substring): Handle,
Fabián Ezequiel Gallina <=