]> code.delx.au - gnu-emacs/commitdiff
(python-continuation-line-p, python-beginning-of-statement):
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 26 Apr 2006 05:26:39 +0000 (05:26 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Wed, 26 Apr 2006 05:26:39 +0000 (05:26 +0000)
syntax-ppss may return a negative depth.

lisp/ChangeLog
lisp/progmodes/python.el

index bf5bb40f5cf38b26908a4836244172fb059e290f..4b5d9bf58d50b75bc3ffa320d8449a9a72085656 100644 (file)
@@ -1,5 +1,9 @@
 2006-04-26  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+       * progmodes/python.el (python-continuation-line-p)
+       (python-beginning-of-statement): syntax-ppss may return
+       a negative depth.
+
        * time-stamp.el (time-stamp-start, time-stamp-end)
        (time-stamp-inserts-lines): Tighten up a bit the safety predicate.
 
index 5e645535a2381c75a2d22d6561fb1083b8be06be..9636f7eaeae830a154a82f2db8d457b05525fed7 100644 (file)
@@ -292,9 +292,9 @@ The criteria are that the previous line ends in a backslash outside
 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 @@ expressions."
        (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))
 
@@ -1755,7 +1758,6 @@ lines count as headers.
   (if (featurep 'hippie-exp)
       (set (make-local-variable 'hippie-expand-try-functions-list)
           (cons 'python-try-complete hippie-expand-try-functions-list)))
-  (unless font-lock-mode (font-lock-mode 1))
   (when python-guess-indent (python-guess-indent))
   (set (make-local-variable 'python-command) python-python-command)
   (unless (boundp 'python-mode-running)        ; kill the recursion from jython-mode