branch: elpa/rust-mode
commit e53dc8a31f07248422606e45a1dd67b935be2ac3
Author: Evgeny Kurnevsky <[email protected]>
Commit: Evgeny Kurnevsky <[email protected]>
Don't call syntax-ppss twice for raw strings.
---
rust-mode.el | 42 +++++++++++++++++++++---------------------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/rust-mode.el b/rust-mode.el
index 6cfaf41..d8092ab 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -1105,32 +1105,32 @@ should be considered a paired angle bracket."
(group "'")))
"A regular expression matching a character literal."))
-(defun rust--syntax-propertize-raw-string (end)
+(defun rust--syntax-propertize-raw-string (str-start end)
"A helper for rust-syntax-propertize.
-If point is already in a raw string, this will apply the
-appropriate string syntax to the character up to the end of the
-raw string, or to END, whichever comes first."
- (let ((str-start (nth 8 (syntax-ppss))))
- (when str-start
- (when (save-excursion
- (goto-char str-start)
- (looking-at "r\\(#*\\)\\(\"\\)"))
- ;; In a raw string, so try to find the end.
- (let ((hashes (match-string 1)))
- ;; Match \ characters at the end of the string to suppress
- ;; their normal character-quote syntax.
- (when (re-search-forward (concat "\\(\\\\*\\)\\(\"" hashes "\\)") end
t)
- (put-text-property (match-beginning 1) (match-end 1)
- 'syntax-table (string-to-syntax "_"))
- (put-text-property (1- (match-end 2)) (match-end 2)
- 'syntax-table (string-to-syntax "|"))
- (goto-char (match-end 0))))))))
+This will apply the appropriate string syntax to the character
+from the STR-START up to the end of the raw string, or to END,
+whichever comes first."
+ (when (save-excursion
+ (goto-char str-start)
+ (looking-at "r\\(#*\\)\\(\"\\)"))
+ ;; In a raw string, so try to find the end.
+ (let ((hashes (match-string 1)))
+ ;; Match \ characters at the end of the string to suppress
+ ;; their normal character-quote syntax.
+ (when (re-search-forward (concat "\\(\\\\*\\)\\(\"" hashes "\\)") end t)
+ (put-text-property (match-beginning 1) (match-end 1)
+ 'syntax-table (string-to-syntax "_"))
+ (put-text-property (1- (match-end 2)) (match-end 2)
+ 'syntax-table (string-to-syntax "|"))
+ (goto-char (match-end 0))))))
(defun rust-syntax-propertize (start end)
"A `syntax-propertize-function' to apply properties from START to END."
(goto-char start)
- (rust--syntax-propertize-raw-string end)
+ (let ((str-start (rust-in-str-or-cmnt)))
+ (when str-start
+ (rust--syntax-propertize-raw-string str-start end)))
(funcall
(syntax-propertize-rules
;; Character literals.
@@ -1142,7 +1142,7 @@ raw string, or to END, whichever comes first."
(unless (save-excursion (nth 8 (syntax-ppss (match-beginning 0))))
(put-text-property (match-beginning 1) (match-end 1)
'syntax-table (string-to-syntax "|"))
- (rust--syntax-propertize-raw-string end)))))
+ (rust--syntax-propertize-raw-string (match-beginning 0) end)))))
("[<>]"
(0 (ignore
(when (save-match-data