]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/python.el
Merge from origin/emacs-24
[gnu-emacs] / lisp / progmodes / python.el
index 4420faf3dfcdc8b822301c92b7f3d6bfb9215989..1c3f7466c8c133e9320a58db7259fb23d0b5f57c 100644 (file)
@@ -843,15 +843,6 @@ keyword
        ;; Beginning of buffer.
        ((= (line-number-at-pos) 1)
         (cons :no-indent 0))
-       ;; Comment continuation (maybe).
-       ((save-excursion
-          (when (and
-                 (or
-                  (python-info-current-line-comment-p)
-                  (python-info-current-line-empty-p))
-                 (forward-comment -1)
-                 (python-info-current-line-comment-p))
-            (cons :after-comment (point)))))
        ;; Inside a string.
        ((let ((start (python-syntax-context 'string ppss)))
           (when start
@@ -963,28 +954,29 @@ keyword
        ((let ((start (python-info-dedenter-statement-p)))
           (when start
             (cons :at-dedenter-block-start start))))
-       ;; After normal line.
-       ((let ((start (save-excursion
-                       (back-to-indentation)
-                       (skip-chars-backward " \t\n")
-                       (python-nav-beginning-of-statement)
-                       (point))))
-          (when start
-            (if (save-excursion
-                  (python-util-forward-comment -1)
-                  (python-nav-beginning-of-statement)
-                  (looking-at (python-rx block-ender)))
-                (cons :after-block-end start)
-              (cons :after-line start)))))
-       ;; Default case: do not indent.
-       (t (cons :no-indent 0))))))
+       ;; After normal line, comment or ender (default case).
+       ((save-excursion
+          (back-to-indentation)
+          (skip-chars-backward " \t\n")
+          (python-nav-beginning-of-statement)
+          (cons
+           (cond ((python-info-current-line-comment-p)
+                  :after-comment)
+                 ((save-excursion
+                    (goto-char (line-end-position))
+                    (python-util-forward-comment -1)
+                    (python-nav-beginning-of-statement)
+                    (looking-at (python-rx block-ender)))
+                  :after-block-end)
+                 (t :after-line))
+           (point))))))))
 
 (defun python-indent--calculate-indentation ()
   "Internal implementation of `python-indent-calculate-indentation'.
 May return an integer for the maximum possible indentation at
 current context or a list of integers.  The latter case is only
 happening for :at-dedenter-block-start context since the
-possibilities can be narrowed to especific indentation points."
+possibilities can be narrowed to specific indentation points."
   (save-restriction
     (widen)
     (save-excursion
@@ -1075,7 +1067,7 @@ minimum."
 (defun python-indent-line (&optional previous)
   "Internal implementation of `python-indent-line-function'.
 Use the PREVIOUS level when argument is non-nil, otherwise indent
-to the maxium available level.  When indentation is the minimum
+to the maximum available level.  When indentation is the minimum
 possible and PREVIOUS is non-nil, cycle back to the maximum
 level."
   (let ((follow-indentation-p
@@ -1110,9 +1102,7 @@ indentation levels from right to left."
   (interactive "*")
   (when (and (not (bolp))
            (not (python-syntax-comment-or-string-p))
-           (= (+ (line-beginning-position)
-                 (current-indentation))
-              (point)))
+           (= (current-indentation) (current-column)))
       (python-indent-line t)
       t))