diff options
| author | Fabián Ezequiel Gallina | 2012-05-17 00:03:36 -0300 |
|---|---|---|
| committer | Fabián Ezequiel Gallina | 2012-05-17 00:03:36 -0300 |
| commit | cd1ed6c8f4a50c0bc499bdcf78bbd4e39bdfc4d2 (patch) | |
| tree | faebce2fe4a1076e5d5ea6c8d373d463b769124b /lisp/progmodes/python.el | |
| parent | dc4f2e532630fa58381b9d3e52350279c98e89b7 (diff) | |
| download | emacs-cd1ed6c8f4a50c0bc499bdcf78bbd4e39bdfc4d2.tar.gz emacs-cd1ed6c8f4a50c0bc499bdcf78bbd4e39bdfc4d2.zip | |
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)
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index ff790bdc25c..7f4aa940d8d 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -1062,7 +1062,12 @@ Returns nil if point is not in a def or class." | |||
| 1062 | (while (and (forward-line 1) | 1062 | (while (and (forward-line 1) |
| 1063 | (not (eobp)) | 1063 | (not (eobp)) |
| 1064 | (or (not (current-word)) | 1064 | (or (not (current-word)) |
| 1065 | (> (current-indentation) beg-defun-indent)))) | 1065 | ;; This checks if the indentation is less than the base |
| 1066 | ;; one and if the line is not a comment | ||
| 1067 | (or (> (current-indentation) beg-defun-indent) | ||
| 1068 | (equal | ||
| 1069 | (char-after | ||
| 1070 | (+ (point) (current-indentation))) ?#))))) | ||
| 1066 | (python-util-forward-comment) | 1071 | (python-util-forward-comment) |
| 1067 | (goto-char (line-beginning-position)))) | 1072 | (goto-char (line-beginning-position)))) |
| 1068 | 1073 | ||