diff options
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index da38152558f..856ed322ec6 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -844,7 +844,9 @@ keyword | |||
| 844 | ;; Inside a string. | 844 | ;; Inside a string. |
| 845 | ((let ((start (python-syntax-context 'string ppss))) | 845 | ((let ((start (python-syntax-context 'string ppss))) |
| 846 | (when start | 846 | (when start |
| 847 | (cons :inside-string start)))) | 847 | (cons (if (python-info-docstring-p) |
| 848 | :inside-docstring | ||
| 849 | :inside-string) start)))) | ||
| 848 | ;; Inside a paren. | 850 | ;; Inside a paren. |
| 849 | ((let* ((start (python-syntax-context 'paren ppss)) | 851 | ((let* ((start (python-syntax-context 'paren ppss)) |
| 850 | (starts-in-newline | 852 | (starts-in-newline |
| @@ -989,6 +991,12 @@ possibilities can be narrowed to specific indentation points." | |||
| 989 | ;; Copy previous indentation. | 991 | ;; Copy previous indentation. |
| 990 | (goto-char start) | 992 | (goto-char start) |
| 991 | (current-indentation)) | 993 | (current-indentation)) |
| 994 | (`(:inside-docstring . ,start) | ||
| 995 | (let* ((line-indentation (current-indentation)) | ||
| 996 | (base-indent (progn | ||
| 997 | (goto-char start) | ||
| 998 | (current-indentation)))) | ||
| 999 | (max line-indentation base-indent))) | ||
| 992 | (`(,(or :after-block-start | 1000 | (`(,(or :after-block-start |
| 993 | :after-backslash-first-line | 1001 | :after-backslash-first-line |
| 994 | :inside-paren-newline-start) . ,start) | 1002 | :inside-paren-newline-start) . ,start) |
| @@ -1138,14 +1146,15 @@ Called from a program, START and END specify the region to indent." | |||
| 1138 | (not line-is-comment-p)) | 1146 | (not line-is-comment-p)) |
| 1139 | (python-info-current-line-empty-p))))) | 1147 | (python-info-current-line-empty-p))))) |
| 1140 | ;; Don't mess with strings, unless it's the | 1148 | ;; Don't mess with strings, unless it's the |
| 1141 | ;; enclosing set of quotes. | 1149 | ;; enclosing set of quotes or a docstring. |
| 1142 | (or (not (python-syntax-context 'string)) | 1150 | (or (not (python-syntax-context 'string)) |
| 1143 | (eq | 1151 | (eq |
| 1144 | (syntax-after | 1152 | (syntax-after |
| 1145 | (+ (1- (point)) | 1153 | (+ (1- (point)) |
| 1146 | (current-indentation) | 1154 | (current-indentation) |
| 1147 | (python-syntax-count-quotes (char-after) (point)))) | 1155 | (python-syntax-count-quotes (char-after) (point)))) |
| 1148 | (string-to-syntax "|"))) | 1156 | (string-to-syntax "|")) |
| 1157 | (python-info-docstring-p)) | ||
| 1149 | ;; Skip if current line is a block start, a | 1158 | ;; Skip if current line is a block start, a |
| 1150 | ;; dedenter or block ender. | 1159 | ;; dedenter or block ender. |
| 1151 | (save-excursion | 1160 | (save-excursion |