summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>1996-07-31 20:57:22 (GMT)
committerBarry Warsaw <barry@python.org>1996-07-31 20:57:22 (GMT)
commit170ffa775dca17fab8fce083904fbf156dd69351 (patch)
tree4c012e4b2add4bcaf63276dda6ad067abe5272ec
parentf831d81999e826e9bf444138c2e193ff1c9e801e (diff)
downloadcpython-170ffa775dca17fab8fce083904fbf156dd69351.zip
cpython-170ffa775dca17fab8fce083904fbf156dd69351.tar.gz
cpython-170ffa775dca17fab8fce083904fbf156dd69351.tar.bz2
(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.
-rw-r--r--Misc/python-mode.el8
1 files changed, 6 insertions, 2 deletions
diff --git a/Misc/python-mode.el b/Misc/python-mode.el
index ebcc791..c95f75b 100644
--- a/Misc/python-mode.el
+++ b/Misc/python-mode.el
@@ -1792,7 +1792,7 @@ local bindings to py-newline-and-indent."))
(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 @@ local bindings to py-newline-and-indent."))
;; 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