aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorStefan Monnier2010-11-08 13:56:10 -0500
committerStefan Monnier2010-11-08 13:56:10 -0500
commit73525e726cd917645950e185cbabafda00bc0635 (patch)
treea1d9a980325462459c536250333fdaf580f2e921 /lisp/progmodes/python.el
parent05539fb32aabb9bf531b70b0ea549314e2446370 (diff)
downloademacs-73525e726cd917645950e185cbabafda00bc0635.tar.gz
emacs-73525e726cd917645950e185cbabafda00bc0635.zip
* lisp/progmodes/python.el (python-font-lock-syntactic-keywords):
Fix handling of backslash escapes. (python-quote-syntax): Adjust accordingly. Fixes: debbugs:7322
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el19
1 files changed, 5 insertions, 14 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index ed2a3236be1..dba8fe5572b 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -170,18 +170,9 @@
170 ;; Make outer chars of matching triple-quote sequences into generic 170 ;; Make outer chars of matching triple-quote sequences into generic
171 ;; string delimiters. Fixme: Is there a better way? 171 ;; string delimiters. Fixme: Is there a better way?
172 ;; First avoid a sequence preceded by an odd number of backslashes. 172 ;; First avoid a sequence preceded by an odd number of backslashes.
173 `((,(rx (not (any ?\\)) 173 `((,(concat "\\(?:\\([RUru]\\)[Rr]?\\|^\\|[^\\]\\(?:\\\\.\\)*\\)" ;Prefix.
174 ?\\ (* (and ?\\ ?\\)) 174 "\\(?:\\('\\)'\\('\\)\\|\\(?2:\"\\)\"\\(?3:\"\\)\\)")
175 (group (syntax string-quote)) 175 (1 (python-quote-syntax 1) nil lax)
176 (backref 1)
177 (group (backref 1)))
178 (2 ,(string-to-syntax "\""))) ; dummy
179 (,(rx (group (optional (any "uUrR"))) ; prefix gets syntax property
180 (optional (any "rR")) ; possible second prefix
181 (group (syntax string-quote)) ; maybe gets property
182 (backref 2) ; per first quote
183 (group (backref 2))) ; maybe gets property
184 (1 (python-quote-syntax 1))
185 (2 (python-quote-syntax 2)) 176 (2 (python-quote-syntax 2))
186 (3 (python-quote-syntax 3))) 177 (3 (python-quote-syntax 3)))
187 ;; This doesn't really help. 178 ;; This doesn't really help.
@@ -219,9 +210,9 @@ Used for syntactic keywords. N is the match number (1, 2 or 3)."
219 (eval-when-compile (string-to-syntax "|")))))) 210 (eval-when-compile (string-to-syntax "|"))))))
220 ;; Consider property for initial char, accounting for prefixes. 211 ;; Consider property for initial char, accounting for prefixes.
221 ((or (and (= n 2) ; leading quote (not prefix) 212 ((or (and (= n 2) ; leading quote (not prefix)
222 (= (match-beginning 1) (match-end 1))) ; prefix is null 213 (not (match-end 1))) ; prefix is null
223 (and (= n 1) ; prefix 214 (and (= n 1) ; prefix
224 (/= (match-beginning 1) (match-end 1)))) ; non-empty 215 (match-end 1))) ; non-empty
225 (let ((font-lock-syntactic-keywords nil)) 216 (let ((font-lock-syntactic-keywords nil))
226 (unless (eq 'string (syntax-ppss-context (syntax-ppss))) 217 (unless (eq 'string (syntax-ppss-context (syntax-ppss)))
227 (eval-when-compile (string-to-syntax "|"))))) 218 (eval-when-compile (string-to-syntax "|")))))