]> git.eshelyaron.com Git - emacs.git/commitdiff
Enhancements on `python-beginning-of-defun-function' for `mark-defun' behavior.
authorFabián Ezequiel Gallina <fgallina@cuca>
Thu, 17 May 2012 03:03:43 +0000 (00:03 -0300)
committerFabián Ezequiel Gallina <fgallina@gnu.org>
Thu, 17 May 2012 03:03:43 +0000 (00:03 -0300)
`mark-defun' was failing when point was right at the start of a defun.

lisp/progmodes/python.el

index 4654143a160e730259d0d97f5442868c1d68154e..1279c38b68bc75e8425c1a9d78bef450b9c8f804 100644 (file)
@@ -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.