[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: syntax-ppss bug?
From: |
Stefan Monnier |
Subject: |
Re: syntax-ppss bug? |
Date: |
Mon, 24 Apr 2006 03:30:34 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
> I tracked down the problem below to an infloop in
> python-beginning-of-statement which occurs because syntax-ppss returns -1
> as the depth. I think that is the wrong value. Would you
> please investigate?
Actually, parse-partial-sexp returns the same -1. And if you close more
parens, you can get to -2, -3, ... it seems it's done on purpose.
> I suspect this Python program was garbled by introduction of
> incorrect line breaks, and that it is actually invalid. Do you know?
I believe so as well. I think the problem is that only the first of the two
lines below is commented, so the second line's closing parens confuse the
paren-counter.
# tablename -> [ ["query templates for subqueries",
['columnkey1','columnkey2'...] ] , ... ]
> I was editing some pyton and hit the tab button. Then emacs
> started processing and 'froze up'. C-g brought it out.
> It happended when I hit tab at the start of the line
> that has [ ["App", "SELECT a.appi ...
Does the patch below fix it for you?
Stefan
--- orig/lisp/progmodes/python.el
+++ mod/lisp/progmodes/python.el
@@ -292,9 +292,9 @@
comments and strings, or that the bracket/paren nesting depth is nonzero."
(or (and (eq ?\\ (char-before (line-end-position 0)))
(not (syntax-ppss-context (syntax-ppss))))
- (/= 0 (syntax-ppss-depth
- (save-excursion ; syntax-ppss with arg changes point
- (syntax-ppss (line-beginning-position)))))))
+ (< 0 (syntax-ppss-depth
+ (save-excursion ; syntax-ppss with arg changes point
+ (syntax-ppss (line-beginning-position)))))))
(defun python-comment-line-p ()
"Return non-nil iff current line has only a comment."
@@ -719,7 +719,10 @@
(python-beginning-of-string)
;; Skip forward out of nested brackets.
(condition-case () ; beware invalid syntax
- (progn (backward-up-list (syntax-ppss-depth (syntax-ppss))) t)
+ (let ((depth (syntax-ppss-depth (syntax-ppss))))
+ ;; Beware negative depths.
+ (if (> depth 0) (backward-up-list depth))
+ t)
(error (throw 'foo nil))))))
(back-to-indentation))