diff options
author | Barry Warsaw <barry@python.org> | 1996-04-06 00:00:19 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 1996-04-06 00:00:19 (GMT) |
commit | 43ecf8ee5854d457fbd3412bd80e85ea32bac39d (patch) | |
tree | d54c93eb0a1a5279197dae80011517d4f321bed5 /Misc | |
parent | ab69eb967304400af6d18e330803309704c27c00 (diff) | |
download | cpython-43ecf8ee5854d457fbd3412bd80e85ea32bac39d.zip cpython-43ecf8ee5854d457fbd3412bd80e85ea32bac39d.tar.gz cpython-43ecf8ee5854d457fbd3412bd80e85ea32bac39d.tar.bz2 |
(py-parse-state): make sure we don't land inside a triple-quoted
string
Diffstat (limited to 'Misc')
-rw-r--r-- | Misc/python-mode.el | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/Misc/python-mode.el b/Misc/python-mode.el index 7f59c31..b40a587 100644 --- a/Misc/python-mode.el +++ b/Misc/python-mode.el @@ -1752,16 +1752,22 @@ local bindings to py-newline-and-indent.")) ;; returns the parse state at point (see parse-partial-sexp docs) (defun py-parse-state () (save-excursion - (let ((here (point)) ) - ;; back up to the first preceding line (if any; else start of - ;; buffer) that begins with a popular Python keyword, or a non- - ;; whitespace and non-comment character. These are good places - ;; to start parsing to see whether where we started is 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) - (beginning-of-line) - (parse-partial-sexp (point) here)))) + (let ((here (point)) + pps done) + (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 + ;; non- whitespace and non-comment character. These are good + ;; places to start parsing to see whether where we started is + ;; 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) + (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)))) + pps))) ;; if point is at a non-zero nesting level, returns the number of the ;; character that opens the smallest enclosing unclosed list; else |