1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-02 10:11:05 -08:00

python-end-of-defun-function now works correctly when comments are not indented properly.

Calling `end-of-defun' on a python file will now do the correct thing,
even for cases like this:

    def fib(n):
        if n < 2:
    #       base cases
            return n
        else:
            return fib(n - 2) + fib(n - 1)
This commit is contained in:
Fabián Ezequiel Gallina 2012-05-17 00:03:36 -03:00 committed by Fabián Ezequiel Gallina
parent dc4f2e5326
commit cd1ed6c8f4

View file

@ -1062,7 +1062,12 @@ Returns nil if point is not in a def or class."
(while (and (forward-line 1)
(not (eobp))
(or (not (current-word))
(> (current-indentation) beg-defun-indent))))
;; This checks if the indentation is less than the base
;; one and if the line is not a comment
(or (> (current-indentation) beg-defun-indent)
(equal
(char-after
(+ (point) (current-indentation))) ?#)))))
(python-util-forward-comment)
(goto-char (line-beginning-position))))