[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r110291: Enhancements for triple-quot
From: |
Fabián Ezequiel Gallina |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r110291: Enhancements for triple-quote string syntax. |
Date: |
Sun, 30 Sep 2012 17:14:02 -0300 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 110291
committer: Fabián Ezequiel Gallina <address@hidden>
branch nick: trunk
timestamp: Sun 2012-09-30 17:14:02 -0300
message:
Enhancements for triple-quote string syntax.
* progmodes/python.el (python-syntax-propertize-function): Match
both quote cases in one regexp.
(python-syntax-stringify): Handle matches properly.
modified:
lisp/progmodes/python.el
=== modified file 'lisp/progmodes/python.el'
--- a/lisp/progmodes/python.el 2012-09-24 23:15:40 +0000
+++ b/lisp/progmodes/python.el 2012-09-30 20:14:02 +0000
@@ -499,17 +499,17 @@
(defconst python-syntax-propertize-function
(syntax-propertize-rules
((rx
- ;; Match even number of backslashes.
- (or (not (any ?\\ ?\' ?\")) point) (* ?\\ ?\\)
- ;; Match single or triple quotes of any kind.
- (group (or "\"" "\"\"\"" "'" "'''")))
- (1 (ignore (python-syntax-stringify))))
- ((rx
- ;; Match odd number of backslashes.
- (or (not (any ?\\)) point) ?\\ (* ?\\ ?\\)
- ;; Followed by even number of equal quotes.
- (group (or "\"\"" "\"\"\"\"" "''" "''''")))
- (1 (ignore (python-syntax-stringify))))))
+ (or (and
+ ;; Match even number of backslashes.
+ (or (not (any ?\\ ?\' ?\")) point) (* ?\\ ?\\)
+ ;; Match single or triple quotes of any kind.
+ (group (or "\"" "\"\"\"" "'" "'''")))
+ (and
+ ;; Match odd number of backslashes.
+ (or (not (any ?\\)) point) ?\\ (* ?\\ ?\\)
+ ;; Followed by even number of equal quotes.
+ (group (or "\"\"" "\"\"\"\"" "''" "''''")))))
+ (0 (ignore (python-syntax-stringify))))))
(defsubst python-syntax-count-quotes (quote-char &optional point limit)
"Count number of quotes around point (max is 3).
@@ -526,7 +526,8 @@
(defun python-syntax-stringify ()
"Put `syntax-table' property correctly on single/triple quotes."
(let* ((num-quotes
- (let ((n (length (match-string-no-properties 1))))
+ (let ((n (length (or (match-string-no-properties 1)
+ (match-string-no-properties 2)))))
;; This corrects the quote count when matching odd number
;; of backslashes followed by even number of quotes.
(or (and (= 1 (logand n 1)) n) (1- n))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r110291: Enhancements for triple-quote string syntax.,
Fabián Ezequiel Gallina <=