diff options
| author | Fabián Ezequiel Gallina <fgallina@cuca> | 2012-05-17 00:03:43 -0300 |
|---|---|---|
| committer | Fabián Ezequiel Gallina <fgallina@gnu.org> | 2012-05-17 00:03:43 -0300 |
| commit | 462973b5ef2bdb31392ec8a87ea23d5501059db2 (patch) | |
| tree | 196fd8e49ef928431363fb1f2886a89f525a8ef1 /lisp/progmodes/python.el | |
| parent | b15e880041f5aacb12de0959c79d60e6065188fd (diff) | |
Enhancements on `python-beginning-of-defun-function' for `mark-defun' behavior.
`mark-defun' was failing when point was right at the start of a defun.
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 4654143a160..1279c38b68b 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -1052,16 +1052,19 @@ negative do the same but backwards. When NODECORATORS is non-nil decorators are not included. Return non-nil if point is moved to the `beginning-of-defun'." (when (or (null arg) (= arg 0)) (setq arg 1)) - (if (> arg 0) - (dotimes (i arg (python-nav-beginning-of-defun nodecorators))) - (let ((found)) - (dotimes (i (- arg) found) - (python-end-of-defun-function) - (python-util-forward-comment) - (goto-char (line-end-position)) - (when (not (eobp)) - (setq found - (python-nav-beginning-of-defun nodecorators))))))) + (cond ((and (eq this-command 'mark-defun) + (looking-at python-nav-beginning-of-defun-regexp))) + ((> arg 0) + (dotimes (i arg (python-nav-beginning-of-defun nodecorators)))) + (t + (let ((found)) + (dotimes (i (- arg) found) + (python-end-of-defun-function) + (python-util-forward-comment) + (goto-char (line-end-position)) + (when (not (eobp)) + (setq found + (python-nav-beginning-of-defun nodecorators)))))))) (defun python-end-of-defun-function () "Move point to the end of def or class. |
