diff options
| author | Carlos Pita | 2020-08-09 20:44:50 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2020-08-09 20:44:55 +0200 |
| commit | b78583cde7d8aaa1fa19c20975c03d689c78baef (patch) | |
| tree | 7c153d1084ff4dd5c6123933d80a466d337d8233 | |
| parent | 5fef06fcf7ba284f206061293c3f9bcfac2daafc (diff) | |
| download | emacs-b78583cde7d8aaa1fa19c20975c03d689c78baef.tar.gz emacs-b78583cde7d8aaa1fa19c20975c03d689c78baef.zip | |
Indent python multiline strings to start and previous levels
* progmodes/python.el (python-indent--calculate-indentation): Add an
additional indentation point to match indentation of previous line in
a multiline string. Then Tab iterates between 0, the start indentation
level and the previous line level (bug#37726).
| -rw-r--r-- | lisp/progmodes/python.el | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 3af55be4a19..dcdadae0c4b 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -1070,11 +1070,18 @@ possibilities can be narrowed to specific indentation points." | |||
| 1070 | (`(:no-indent . ,_) (prog-first-column)) ; usually 0 | 1070 | (`(:no-indent . ,_) (prog-first-column)) ; usually 0 |
| 1071 | (`(,(or :after-line | 1071 | (`(,(or :after-line |
| 1072 | :after-comment | 1072 | :after-comment |
| 1073 | :inside-string | ||
| 1074 | :after-backslash) . ,start) | 1073 | :after-backslash) . ,start) |
| 1075 | ;; Copy previous indentation. | 1074 | ;; Copy previous indentation. |
| 1076 | (goto-char start) | 1075 | (goto-char start) |
| 1077 | (current-indentation)) | 1076 | (current-indentation)) |
| 1077 | (`(,(or :inside-string | ||
| 1078 | :inside-docstring) . ,start) | ||
| 1079 | ;; Copy previous indentation inside string | ||
| 1080 | (let ((prev (progn (forward-line -1) | ||
| 1081 | (current-indentation))) | ||
| 1082 | (base (progn (goto-char start) | ||
| 1083 | (current-column)))) | ||
| 1084 | (sort (delete-dups (list 0 prev base)) #'<))) | ||
| 1078 | (`(,(or :inside-paren-at-closing-paren | 1085 | (`(,(or :inside-paren-at-closing-paren |
| 1079 | :inside-paren-at-closing-nested-paren) . ,start) | 1086 | :inside-paren-at-closing-nested-paren) . ,start) |
| 1080 | (goto-char (+ 1 start)) | 1087 | (goto-char (+ 1 start)) |
| @@ -1083,12 +1090,6 @@ possibilities can be narrowed to specific indentation points." | |||
| 1083 | (current-indentation) | 1090 | (current-indentation) |
| 1084 | ;; Align with opening paren. | 1091 | ;; Align with opening paren. |
| 1085 | (current-column))) | 1092 | (current-column))) |
| 1086 | (`(:inside-docstring . ,start) | ||
| 1087 | (let* ((line-indentation (current-indentation)) | ||
| 1088 | (base-indent (progn | ||
| 1089 | (goto-char start) | ||
| 1090 | (current-indentation)))) | ||
| 1091 | (max line-indentation base-indent))) | ||
| 1092 | (`(,(or :after-block-start | 1093 | (`(,(or :after-block-start |
| 1093 | :after-backslash-first-line | 1094 | :after-backslash-first-line |
| 1094 | :after-backslash-assignment-continuation | 1095 | :after-backslash-assignment-continuation |