diff options
| author | Fabián Ezequiel Gallina | 2013-12-12 02:37:09 -0300 |
|---|---|---|
| committer | Fabián Ezequiel Gallina | 2013-12-12 02:37:09 -0300 |
| commit | 09faee72dd0743a5b46444b5e917ee1259843788 (patch) | |
| tree | 13f65f15d978b036b9fca79cd3803220f1fcf1dd /lisp/progmodes/python.el | |
| parent | 139f528442726be5160120fb13e68240982de92f (diff) | |
| download | emacs-09faee72dd0743a5b46444b5e917ee1259843788.tar.gz emacs-09faee72dd0743a5b46444b5e917ee1259843788.zip | |
* lisp/progmodes/python.el (python-indent-context)
(python-indent-calculate-indentation): Fix auto-identation
behavior for comment blocks.
* test/automated/python-tests.el (python-indent-after-comment-1)
(python-indent-after-comment-2): New tests.
Fixes: debbugs:15916
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 669da135644..33039a4d087 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -686,6 +686,8 @@ Context information is returned with a cons with the form: | |||
| 686 | \(STATUS . START) | 686 | \(STATUS . START) |
| 687 | 687 | ||
| 688 | Where status can be any of the following symbols: | 688 | Where status can be any of the following symbols: |
| 689 | |||
| 690 | * after-comment: When current line might continue a comment block | ||
| 689 | * inside-paren: If point in between (), {} or [] | 691 | * inside-paren: If point in between (), {} or [] |
| 690 | * inside-string: If point is inside a string | 692 | * inside-string: If point is inside a string |
| 691 | * after-backslash: Previous line ends in a backslash | 693 | * after-backslash: Previous line ends in a backslash |
| @@ -704,6 +706,17 @@ START is the buffer position where the sexp starts." | |||
| 704 | (goto-char (line-beginning-position)) | 706 | (goto-char (line-beginning-position)) |
| 705 | (bobp)) | 707 | (bobp)) |
| 706 | 'no-indent) | 708 | 'no-indent) |
| 709 | ;; Comment continuation | ||
| 710 | ((save-excursion | ||
| 711 | (when (and | ||
| 712 | (or | ||
| 713 | (python-info-current-line-comment-p) | ||
| 714 | (python-info-current-line-empty-p)) | ||
| 715 | (progn | ||
| 716 | (forward-comment -1) | ||
| 717 | (python-info-current-line-comment-p))) | ||
| 718 | (setq start (point)) | ||
| 719 | 'after-comment))) | ||
| 707 | ;; Inside string | 720 | ;; Inside string |
| 708 | ((setq start (python-syntax-context 'string ppss)) | 721 | ((setq start (python-syntax-context 'string ppss)) |
| 709 | 'inside-string) | 722 | 'inside-string) |
| @@ -755,6 +768,9 @@ START is the buffer position where the sexp starts." | |||
| 755 | (save-excursion | 768 | (save-excursion |
| 756 | (pcase context-status | 769 | (pcase context-status |
| 757 | (`no-indent 0) | 770 | (`no-indent 0) |
| 771 | (`after-comment | ||
| 772 | (goto-char context-start) | ||
| 773 | (current-indentation)) | ||
| 758 | ;; When point is after beginning of block just add one level | 774 | ;; When point is after beginning of block just add one level |
| 759 | ;; of indentation relative to the context-start | 775 | ;; of indentation relative to the context-start |
| 760 | (`after-beginning-of-block | 776 | (`after-beginning-of-block |