* lisp/progmodes/python.el (python-shell-buffer-substring): Handle
cornercase when region sent starts at point-min.
This commit is contained in:
parent
a5f38fa1cc
commit
433af0a060
4 changed files with 39 additions and 10 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2014-12-27 Fabián Ezequiel Gallina <fgallina@gnu.org>
|
||||||
|
|
||||||
|
* progmodes/python.el (python-shell-buffer-substring): Handle
|
||||||
|
cornercase when region sent starts at point-min.
|
||||||
|
|
||||||
2014-12-27 Eli Zaretskii <eliz@gnu.org>
|
2014-12-27 Eli Zaretskii <eliz@gnu.org>
|
||||||
|
|
||||||
* language/misc-lang.el (composition-function-table): Add Syriac
|
* language/misc-lang.el (composition-function-table): Add Syriac
|
||||||
|
|
|
@ -2523,17 +2523,16 @@ the python shell:
|
||||||
4. Wraps indented regions under an \"if True:\" block so the
|
4. Wraps indented regions under an \"if True:\" block so the
|
||||||
interpreter evaluates them correctly."
|
interpreter evaluates them correctly."
|
||||||
(let* ((substring (buffer-substring-no-properties start end))
|
(let* ((substring (buffer-substring-no-properties start end))
|
||||||
(buffer-substring-p (save-restriction
|
(starts-at-point-min-p (save-restriction
|
||||||
(widen)
|
(widen)
|
||||||
(not (equal (list (point-min) (point-max))
|
(= (point-min) start)))
|
||||||
(list start end)))))
|
|
||||||
(encoding (python-info-encoding))
|
(encoding (python-info-encoding))
|
||||||
(fillstr (concat
|
(fillstr (when (not starts-at-point-min-p)
|
||||||
(when buffer-substring-p
|
(concat
|
||||||
(format "# -*- coding: %s -*-\n" encoding))
|
(format "# -*- coding: %s -*-\n" encoding)
|
||||||
(make-string
|
(make-string
|
||||||
(- (line-number-at-pos start)
|
;; Substract 2 because of the coding cookie.
|
||||||
(if buffer-substring-p 2 1)) ?\n)))
|
(- (line-number-at-pos start) 2) ?\n))))
|
||||||
(toplevel-block-p (save-excursion
|
(toplevel-block-p (save-excursion
|
||||||
(goto-char start)
|
(goto-char start)
|
||||||
(or (zerop (line-number-at-pos start))
|
(or (zerop (line-number-at-pos start))
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2014-12-27 Fabián Ezequiel Gallina <fgallina@gnu.org>
|
||||||
|
|
||||||
|
(python-shell-buffer-substring-9): New test.
|
||||||
|
|
||||||
2014-12-27 Fabián Ezequiel Gallina <fgallina@gnu.org>
|
2014-12-27 Fabián Ezequiel Gallina <fgallina@gnu.org>
|
||||||
|
|
||||||
* automated/python-tests.el (python-shell-buffer-substring-1)
|
* automated/python-tests.el (python-shell-buffer-substring-1)
|
||||||
|
|
|
@ -2651,6 +2651,27 @@ class Foo(models.Model):
|
||||||
pass
|
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
|
;;; Shell completion
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue