From: Fabián Ezequiel Gallina Date: Thu, 17 May 2012 03:03:43 +0000 (-0300) Subject: Enhancements on `python-beginning-of-defun-function' for `mark-defun' behavior. X-Git-Tag: emacs-24.2.90~1199^2~485 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=462973b5ef2bdb31392ec8a87ea23d5501059db2;p=emacs.git 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. --- 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.