diff options
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index d0a83087554..5842be7cf64 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -810,15 +810,6 @@ keyword | |||
| 810 | ;; Beginning of buffer. | 810 | ;; Beginning of buffer. |
| 811 | ((= (line-number-at-pos) 1) | 811 | ((= (line-number-at-pos) 1) |
| 812 | (cons :no-indent 0)) | 812 | (cons :no-indent 0)) |
| 813 | ;; Comment continuation (maybe). | ||
| 814 | ((save-excursion | ||
| 815 | (when (and | ||
| 816 | (or | ||
| 817 | (python-info-current-line-comment-p) | ||
| 818 | (python-info-current-line-empty-p)) | ||
| 819 | (forward-comment -1) | ||
| 820 | (python-info-current-line-comment-p)) | ||
| 821 | (cons :after-comment (point))))) | ||
| 822 | ;; Inside a string. | 813 | ;; Inside a string. |
| 823 | ((let ((start (python-syntax-context 'string ppss))) | 814 | ((let ((start (python-syntax-context 'string ppss))) |
| 824 | (when start | 815 | (when start |
| @@ -930,21 +921,22 @@ keyword | |||
| 930 | ((let ((start (python-info-dedenter-statement-p))) | 921 | ((let ((start (python-info-dedenter-statement-p))) |
| 931 | (when start | 922 | (when start |
| 932 | (cons :at-dedenter-block-start start)))) | 923 | (cons :at-dedenter-block-start start)))) |
| 933 | ;; After normal line. | 924 | ;; After normal line, comment or ender (default case). |
| 934 | ((let ((start (save-excursion | 925 | ((save-excursion |
| 935 | (back-to-indentation) | 926 | (back-to-indentation) |
| 936 | (skip-chars-backward " \t\n") | 927 | (skip-chars-backward " \t\n") |
| 937 | (python-nav-beginning-of-statement) | 928 | (python-nav-beginning-of-statement) |
| 938 | (point)))) | 929 | (cons |
| 939 | (when start | 930 | (cond ((python-info-current-line-comment-p) |
| 940 | (if (save-excursion | 931 | :after-comment) |
| 941 | (python-util-forward-comment -1) | 932 | ((save-excursion |
| 942 | (python-nav-beginning-of-statement) | 933 | (goto-char (line-end-position)) |
| 943 | (looking-at (python-rx block-ender))) | 934 | (python-util-forward-comment -1) |
| 944 | (cons :after-block-end start) | 935 | (python-nav-beginning-of-statement) |
| 945 | (cons :after-line start))))) | 936 | (looking-at (python-rx block-ender))) |
| 946 | ;; Default case: do not indent. | 937 | :after-block-end) |
| 947 | (t (cons :no-indent 0)))))) | 938 | (t :after-line)) |
| 939 | (point)))))))) | ||
| 948 | 940 | ||
| 949 | (defun python-indent--calculate-indentation () | 941 | (defun python-indent--calculate-indentation () |
| 950 | "Internal implementation of `python-indent-calculate-indentation'. | 942 | "Internal implementation of `python-indent-calculate-indentation'. |