]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/progmodes/python.el (python-nav-beginning-of-statement): Speed
authorFabián Ezequiel Gallina <fgallina@gnu.org>
Tue, 24 Dec 2013 19:48:40 +0000 (16:48 -0300)
committerFabián Ezequiel Gallina <fgallina@gnu.org>
Tue, 24 Dec 2013 19:48:40 +0000 (16:48 -0300)
up.

Fixes: debbugs:15295
lisp/ChangeLog
lisp/progmodes/python.el

index c3185a37a71a1b9d8183819093ce0700ba2609d4..1c66a806c5f4e96531204b6c71bf93143453581d 100644 (file)
@@ -1,3 +1,8 @@
+2013-12-24  Fabián Ezequiel Gallina  <fgallina@gnu.org>
+
+       * progmodes/python.el (python-nav-beginning-of-statement): Speed
+       up (Bug#15295).
+
 2013-12-24  Lars Ingebrigtsen  <larsi@gnus.org>
 
        * net/eww.el (eww-bookmark-browse): Use `quit-window' to restore
index aeee179c7e7a2cd19a334b44432d13b11a203c52..07a8bba6b18bd8d6209265e48ed5c1ad23496ee1 100644 (file)
@@ -1279,15 +1279,21 @@ nested definitions."
 (defun python-nav-beginning-of-statement ()
   "Move to start of current statement."
   (interactive "^")
-  (while (and (or (back-to-indentation) t)
-              (not (bobp))
-              (when (or
-                     (save-excursion
-                       (forward-line -1)
-                       (python-info-line-ends-backslash-p))
-                     (python-syntax-context 'string)
-                     (python-syntax-context 'paren))
-                (forward-line -1))))
+  (back-to-indentation)
+  (let* ((ppss (syntax-ppss))
+         (context-point
+          (or
+           (python-syntax-context 'paren ppss)
+           (python-syntax-context 'string ppss))))
+    (cond ((bobp))
+          (context-point
+           (goto-char context-point)
+           (python-nav-beginning-of-statement))
+          ((save-excursion
+             (forward-line -1)
+             (python-info-line-ends-backslash-p))
+           (forward-line -1)
+           (python-nav-beginning-of-statement))))
   (point-marker))
 
 (defun python-nav-end-of-statement (&optional noend)