Commit 170ffa77 authored by Barry Warsaw's avatar Barry Warsaw

(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.
parent f831d819
...@@ -1792,7 +1792,7 @@ local bindings to py-newline-and-indent.")) ...@@ -1792,7 +1792,7 @@ local bindings to py-newline-and-indent."))
(defun py-parse-state () (defun py-parse-state ()
(save-excursion (save-excursion
(let ((here (point)) (let ((here (point))
pps done) pps done ci)
(while (not done) (while (not done)
;; back up to the first preceding line (if any; else start of ;; back up to the first preceding line (if any; else start of
;; buffer) that begins with a popular Python keyword, or a ;; buffer) that begins with a popular Python keyword, or a
...@@ -1801,11 +1801,15 @@ local bindings to py-newline-and-indent.")) ...@@ -1801,11 +1801,15 @@ local bindings to py-newline-and-indent."))
;; at a non-zero nesting level. It may be slow for people who ;; at a non-zero nesting level. It may be slow for people who
;; write huge code blocks or huge lists ... tough beans. ;; write huge code blocks or huge lists ... tough beans.
(re-search-backward py-parse-state-re nil 'move) (re-search-backward py-parse-state-re nil 'move)
(setq ci (current-indentation))
(beginning-of-line) (beginning-of-line)
(save-excursion (save-excursion
(setq pps (parse-partial-sexp (point) here))) (setq pps (parse-partial-sexp (point) here)))
;; make sure we don't land inside a triple-quoted string ;; 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))) pps)))
;; if point is at a non-zero nesting level, returns the number of the ;; if point is at a non-zero nesting level, returns the number of the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment