Commit bbac1eb8 authored by Fabián Ezequiel Gallina's avatar Fabián Ezequiel Gallina Committed by Fabián Ezequiel Gallina
Browse files

python-indent-guess-indent-offset improvements

parent 183f9296
......@@ -403,11 +403,18 @@ These make `python-indent-calculate-indentation' subtract the value of
(defun python-indent-guess-indent-offset ()
"Guess and set `python-indent-offset' for the current buffer."
(goto-char (point-min))
(let ((found-block))
(while (and (not found-block)
(python-rx line-start block-start) nil t))
(when (not (syntax-ppss-context (syntax-ppss)))
(when (and (not (syntax-ppss-context (syntax-ppss)))
(goto-char (line-end-position))
(forward-comment -1)
(eq ?: (char-before))))
(setq found-block t)))
(if (not found-block)
(message "Can't guess python-indent-offset, using defaults: %s"
......@@ -419,7 +426,7 @@ These make `python-indent-calculate-indentation' subtract the value of
(forward-line 1))
(forward-line 1)
(forward-comment 1)
(setq python-indent-offset (current-indentation))))))
(setq python-indent-offset (current-indentation)))))))
(defun python-indent-context (&optional stop)
"Return information on indentation context.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment