diff Misc/python-mode.el @ 3901:ce2d9239ba81 legacy-trunk

(py-parse-state): stop searching backwards when we found a keyword at column zero. Perhaps a kludge, but similar in nature to Emacs' beginning-of-defun shortcut.
author Barry Warsaw <barry@python.org>
date Wed, 31 Jul 1996 20:57:22 +0000
parents cba4ce15a0d5
children a3f67bb96adc
line wrap: on
line diff
--- a/Misc/python-mode.el	Wed Jul 31 20:42:59 1996 +0000
+++ b/Misc/python-mode.el	Wed Jul 31 20:57:22 1996 +0000
@@ -1792,7 +1792,7 @@
 (defun py-parse-state ()
   (save-excursion
     (let ((here (point))
-	  pps done)
+	  pps done ci)
       (while (not done)
 	;; back up to the first preceding line (if any; else start of
 	;; buffer) that begins with a popular Python keyword, or a
@@ -1801,11 +1801,15 @@
 	;; at a non-zero nesting level.  It may be slow for people who
 	;; write huge code blocks or huge lists ... tough beans.
 	(re-search-backward py-parse-state-re nil 'move)
+	(setq ci (current-indentation))
 	(beginning-of-line)
 	(save-excursion
 	  (setq pps (parse-partial-sexp (point) here)))
 	;; make sure we don't land inside a triple-quoted string
-	(setq done (or (not (nth 3 pps)) (bobp))))
+	(setq done (or (zerop ci)
+		       (not (nth 3 pps))
+		       (bobp)))
+	)
       pps)))
 
 ;; if point is at a non-zero nesting level, returns the number of the