diff options
| author | Christoph Wedler | 2015-06-19 13:38:24 +0000 |
|---|---|---|
| committer | Christoph Wedler | 2015-07-05 08:52:03 +0000 |
| commit | 044d4cc0c0debd4648ec637d63bcd72d4253b1cb (patch) | |
| tree | 5141ad9cfb3ab68795a80b4b87e0829d427226ed /test | |
| parent | 4fff58dd1ec11543e2b0195f10cefc1746748499 (diff) | |
| download | emacs-044d4cc0c0debd4648ec637d63bcd72d4253b1cb.tar.gz emacs-044d4cc0c0debd4648ec637d63bcd72d4253b1cb.zip | |
Respect `prog-indentation-context' in python.el
* lisp/progmodes/python.el (python-indent-guess-indent-offset)
(python-indent-context, python-indent--calculate-indentation)
(python-info-current-defun)
(python-info-dedenter-opening-block-message)
(python-info-line-ends-backslash-p)
(python-info-beginning-of-backslash)
(python-info-continuation-line-p): Use `prog-widen'.
(python-indent--calculate-indentation)
(python-indent--calculate-levels)
(python-indent-calculate-indentation): Use `prog-first-column'.
(python-indent--calculate-levels): Simplify.
Ignore also initial empty lines for syntax calculation.
* lisp/progmodes/python.el (python-indent-context): Return
:no-indent for first non-empty line, not just in line 1.
* test/automated/python-tests.el (python-indent-base-case)
(python-indent-inside-paren-1, python-indent-inside-paren-2)
(python-indent-inside-paren-3, python-indent-inside-paren-4)
(python-indent-inside-paren-5, python-indent-inside-paren-6)
(python-indent-after-backslash-1)
(python-indent-after-backslash-2)
(python-indent-after-backslash-3)
(python-indent-after-backslash-4, python-indent-inside-string-1):
Expect :no-indent for first non-empty line.
Diffstat (limited to 'test')
| -rw-r--r-- | test/automated/python-tests.el | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el index ae4323ba8af..4585e7f9614 100644 --- a/test/automated/python-tests.el +++ b/test/automated/python-tests.el | |||
| @@ -267,10 +267,10 @@ foo = long_function_name( | |||
| 267 | (should (eq (car (python-indent-context)) :no-indent)) | 267 | (should (eq (car (python-indent-context)) :no-indent)) |
| 268 | (should (= (python-indent-calculate-indentation) 0)) | 268 | (should (= (python-indent-calculate-indentation) 0)) |
| 269 | (forward-line 1) | 269 | (forward-line 1) |
| 270 | (should (eq (car (python-indent-context)) :after-line)) | 270 | (should (eq (car (python-indent-context)) :no-indent)) |
| 271 | (should (= (python-indent-calculate-indentation) 0)) | 271 | (should (= (python-indent-calculate-indentation) 0)) |
| 272 | (forward-line 1) | 272 | (forward-line 1) |
| 273 | (should (eq (car (python-indent-context)) :after-line)) | 273 | (should (eq (car (python-indent-context)) :no-indent)) |
| 274 | (should (= (python-indent-calculate-indentation) 0)))) | 274 | (should (= (python-indent-calculate-indentation) 0)))) |
| 275 | 275 | ||
| 276 | (ert-deftest python-indent-after-comment-1 () | 276 | (ert-deftest python-indent-after-comment-1 () |
| @@ -392,7 +392,7 @@ data = { | |||
| 392 | } | 392 | } |
| 393 | " | 393 | " |
| 394 | (python-tests-look-at "data = {") | 394 | (python-tests-look-at "data = {") |
| 395 | (should (eq (car (python-indent-context)) :after-line)) | 395 | (should (eq (car (python-indent-context)) :no-indent)) |
| 396 | (should (= (python-indent-calculate-indentation) 0)) | 396 | (should (= (python-indent-calculate-indentation) 0)) |
| 397 | (python-tests-look-at "'key':") | 397 | (python-tests-look-at "'key':") |
| 398 | (should (eq (car (python-indent-context)) :inside-paren-newline-start)) | 398 | (should (eq (car (python-indent-context)) :inside-paren-newline-start)) |
| @@ -455,7 +455,7 @@ data = {'key': { | |||
| 455 | }} | 455 | }} |
| 456 | " | 456 | " |
| 457 | (python-tests-look-at "data = {") | 457 | (python-tests-look-at "data = {") |
| 458 | (should (eq (car (python-indent-context)) :after-line)) | 458 | (should (eq (car (python-indent-context)) :no-indent)) |
| 459 | (should (= (python-indent-calculate-indentation) 0)) | 459 | (should (= (python-indent-calculate-indentation) 0)) |
| 460 | (python-tests-look-at "'objlist': [") | 460 | (python-tests-look-at "'objlist': [") |
| 461 | (should (eq (car (python-indent-context)) :inside-paren-newline-start)) | 461 | (should (eq (car (python-indent-context)) :inside-paren-newline-start)) |
| @@ -494,7 +494,7 @@ data = ('these', | |||
| 494 | 'tokens') | 494 | 'tokens') |
| 495 | " | 495 | " |
| 496 | (python-tests-look-at "data = ('these',") | 496 | (python-tests-look-at "data = ('these',") |
| 497 | (should (eq (car (python-indent-context)) :after-line)) | 497 | (should (eq (car (python-indent-context)) :no-indent)) |
| 498 | (should (= (python-indent-calculate-indentation) 0)) | 498 | (should (= (python-indent-calculate-indentation) 0)) |
| 499 | (forward-line 1) | 499 | (forward-line 1) |
| 500 | (should (eq (car (python-indent-context)) :inside-paren)) | 500 | (should (eq (car (python-indent-context)) :inside-paren)) |
| @@ -514,7 +514,7 @@ data = [ [ 'these', 'are'], | |||
| 514 | ['the', 'tokens' ] ] | 514 | ['the', 'tokens' ] ] |
| 515 | " | 515 | " |
| 516 | (python-tests-look-at "data = [ [ 'these', 'are'],") | 516 | (python-tests-look-at "data = [ [ 'these', 'are'],") |
| 517 | (should (eq (car (python-indent-context)) :after-line)) | 517 | (should (eq (car (python-indent-context)) :no-indent)) |
| 518 | (should (= (python-indent-calculate-indentation) 0)) | 518 | (should (= (python-indent-calculate-indentation) 0)) |
| 519 | (forward-line 1) | 519 | (forward-line 1) |
| 520 | (should (eq (car (python-indent-context)) :inside-paren)) | 520 | (should (eq (car (python-indent-context)) :inside-paren)) |
| @@ -530,7 +530,7 @@ while ((not some_condition) and | |||
| 530 | with_some_arg) | 530 | with_some_arg) |
| 531 | " | 531 | " |
| 532 | (python-tests-look-at "while ((not some_condition) and") | 532 | (python-tests-look-at "while ((not some_condition) and") |
| 533 | (should (eq (car (python-indent-context)) :after-line)) | 533 | (should (eq (car (python-indent-context)) :no-indent)) |
| 534 | (should (= (python-indent-calculate-indentation) 0)) | 534 | (should (= (python-indent-calculate-indentation) 0)) |
| 535 | (forward-line 1) | 535 | (forward-line 1) |
| 536 | (should (eq (car (python-indent-context)) :inside-paren)) | 536 | (should (eq (car (python-indent-context)) :inside-paren)) |
| @@ -551,7 +551,7 @@ CHOICES = (('some', 'choice'), | |||
| 551 | ('more', 'choices')) | 551 | ('more', 'choices')) |
| 552 | " | 552 | " |
| 553 | (python-tests-look-at "CHOICES = (('some', 'choice'),") | 553 | (python-tests-look-at "CHOICES = (('some', 'choice'),") |
| 554 | (should (eq (car (python-indent-context)) :after-line)) | 554 | (should (eq (car (python-indent-context)) :no-indent)) |
| 555 | (should (= (python-indent-calculate-indentation) 0)) | 555 | (should (= (python-indent-calculate-indentation) 0)) |
| 556 | (forward-line 1) | 556 | (forward-line 1) |
| 557 | (should (eq (car (python-indent-context)) :inside-paren)) | 557 | (should (eq (car (python-indent-context)) :inside-paren)) |
| @@ -612,7 +612,7 @@ from foo.bar.baz import something, something_1 \\\\ | |||
| 612 | something_4, something_5 | 612 | something_4, something_5 |
| 613 | " | 613 | " |
| 614 | (python-tests-look-at "from foo.bar.baz import something, something_1") | 614 | (python-tests-look-at "from foo.bar.baz import something, something_1") |
| 615 | (should (eq (car (python-indent-context)) :after-line)) | 615 | (should (eq (car (python-indent-context)) :no-indent)) |
| 616 | (should (= (python-indent-calculate-indentation) 0)) | 616 | (should (= (python-indent-calculate-indentation) 0)) |
| 617 | (python-tests-look-at "something_2 something_3,") | 617 | (python-tests-look-at "something_2 something_3,") |
| 618 | (should (eq (car (python-indent-context)) :after-backslash-first-line)) | 618 | (should (eq (car (python-indent-context)) :after-backslash-first-line)) |
| @@ -639,7 +639,7 @@ objects = Thing.objects.all() \\\\ | |||
| 639 | .values_list() | 639 | .values_list() |
| 640 | " | 640 | " |
| 641 | (python-tests-look-at "objects = Thing.objects.all()") | 641 | (python-tests-look-at "objects = Thing.objects.all()") |
| 642 | (should (eq (car (python-indent-context)) :after-line)) | 642 | (should (eq (car (python-indent-context)) :no-indent)) |
| 643 | (should (= (python-indent-calculate-indentation) 0)) | 643 | (should (= (python-indent-calculate-indentation) 0)) |
| 644 | (python-tests-look-at ".filter(") | 644 | (python-tests-look-at ".filter(") |
| 645 | (should (eq (car (python-indent-context)) | 645 | (should (eq (car (python-indent-context)) |
| @@ -682,7 +682,7 @@ with open('/path/to/some/file/you/want/to/read') as file_1, \\\\ | |||
| 682 | " | 682 | " |
| 683 | (python-tests-look-at | 683 | (python-tests-look-at |
| 684 | "with open('/path/to/some/file/you/want/to/read') as file_1, \\\\") | 684 | "with open('/path/to/some/file/you/want/to/read') as file_1, \\\\") |
| 685 | (should (eq (car (python-indent-context)) :after-line)) | 685 | (should (eq (car (python-indent-context)) :no-indent)) |
| 686 | (should (= (python-indent-calculate-indentation) 0)) | 686 | (should (= (python-indent-calculate-indentation) 0)) |
| 687 | (python-tests-look-at | 687 | (python-tests-look-at |
| 688 | "open('/path/to/some/file/being/written', 'w') as file_2") | 688 | "open('/path/to/some/file/being/written', 'w') as file_2") |
| @@ -703,7 +703,7 @@ super_awful_assignment = some_calculation() and \\\\ | |||
| 703 | " | 703 | " |
| 704 | (python-tests-look-at | 704 | (python-tests-look-at |
| 705 | "super_awful_assignment = some_calculation() and \\\\") | 705 | "super_awful_assignment = some_calculation() and \\\\") |
| 706 | (should (eq (car (python-indent-context)) :after-line)) | 706 | (should (eq (car (python-indent-context)) :no-indent)) |
| 707 | (should (= (python-indent-calculate-indentation) 0)) | 707 | (should (= (python-indent-calculate-indentation) 0)) |
| 708 | (python-tests-look-at "another_calculation() and \\\\") | 708 | (python-tests-look-at "another_calculation() and \\\\") |
| 709 | (should (eq (car (python-indent-context)) | 709 | (should (eq (car (python-indent-context)) |
| @@ -992,7 +992,7 @@ lines | |||
| 992 | ''' | 992 | ''' |
| 993 | " | 993 | " |
| 994 | (python-tests-look-at "multiline = '''") | 994 | (python-tests-look-at "multiline = '''") |
| 995 | (should (eq (car (python-indent-context)) :after-line)) | 995 | (should (eq (car (python-indent-context)) :no-indent)) |
| 996 | (should (= (python-indent-calculate-indentation) 0)) | 996 | (should (= (python-indent-calculate-indentation) 0)) |
| 997 | (python-tests-look-at "bunch") | 997 | (python-tests-look-at "bunch") |
| 998 | (should (eq (car (python-indent-context)) :inside-string)) | 998 | (should (eq (car (python-indent-context)) :inside-string)) |