]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/progmodes/python.el (python-font-lock-syntactic-keywords):
authorStefan Monnier <monnier@iro.umontreal.ca>
Mon, 8 Nov 2010 18:56:10 +0000 (13:56 -0500)
committerStefan Monnier <monnier@iro.umontreal.ca>
Mon, 8 Nov 2010 18:56:10 +0000 (13:56 -0500)
Fix handling of backslash escapes.
(python-quote-syntax): Adjust accordingly.

Fixes: debbugs:7322
lisp/ChangeLog
lisp/progmodes/python.el

index 45066263c5e896bbb6a99a81c3a822b5128d1f48..0a38a9a6c9f0fb3e61e71e0d07a667d9e5400f35 100644 (file)
@@ -1,3 +1,9 @@
+2010-11-08  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * progmodes/python.el (python-font-lock-syntactic-keywords): (bug#7322)
+       Fix handling of backslash escapes.
+       (python-quote-syntax): Adjust accordingly.
+
 2010-11-08  Richard Levitte  <richard@levitte.org>  (tiny patch)
 
        * vc-mtn.el (vc-mtn-working-revision, vc-mtn-after-dir-status)
index ed2a3236be10280143963f513d4f2f60ebeb2916..dba8fe5572b56450240b2b6d96e96543642ae5fc 100644 (file)
   ;; Make outer chars of matching triple-quote sequences into generic
   ;; string delimiters.  Fixme: Is there a better way?
   ;; First avoid a sequence preceded by an odd number of backslashes.
-  `((,(rx (not (any ?\\))
-         ?\\ (* (and ?\\ ?\\))
-         (group (syntax string-quote))
-         (backref 1)
-         (group (backref 1)))
-     (2 ,(string-to-syntax "\"")))     ; dummy
-    (,(rx (group (optional (any "uUrR"))) ; prefix gets syntax property
-         (optional (any "rR"))           ; possible second prefix
-         (group (syntax string-quote))   ; maybe gets property
-         (backref 2)                     ; per first quote
-         (group (backref 2)))            ; maybe gets property
-     (1 (python-quote-syntax 1))
+  `((,(concat "\\(?:\\([RUru]\\)[Rr]?\\|^\\|[^\\]\\(?:\\\\.\\)*\\)" ;Prefix.
+              "\\(?:\\('\\)'\\('\\)\\|\\(?2:\"\\)\"\\(?3:\"\\)\\)")
+     (1 (python-quote-syntax 1) nil lax)
      (2 (python-quote-syntax 2))
      (3 (python-quote-syntax 3)))
     ;; This doesn't really help.
@@ -219,9 +210,9 @@ Used for syntactic keywords.  N is the match number (1, 2 or 3)."
              (eval-when-compile (string-to-syntax "|"))))))
      ;; Consider property for initial char, accounting for prefixes.
      ((or (and (= n 2)                 ; leading quote (not prefix)
-              (= (match-beginning 1) (match-end 1))) ; prefix is null
+              (not (match-end 1)))     ; prefix is null
          (and (= n 1)                  ; prefix
-              (/= (match-beginning 1) (match-end 1)))) ; non-empty
+              (match-end 1)))          ; non-empty
       (let ((font-lock-syntactic-keywords nil))
        (unless (eq 'string (syntax-ppss-context (syntax-ppss)))
          (eval-when-compile (string-to-syntax "|")))))