[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rust-mode c62185a 397/486: Merge pull request #304 from ku
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rust-mode c62185a 397/486: Merge pull request #304 from kurnevsky/raw-string-propertize |
Date: |
Sat, 7 Aug 2021 09:26:01 -0400 (EDT) |
branch: elpa/rust-mode
commit c62185ae1c6edf0335261f169241eb8ee9713ad5
Merge: 0a94268 e53dc8a
Author: Niko Matsakis <niko@alum.mit.edu>
Commit: GitHub <noreply@github.com>
Merge pull request #304 from kurnevsky/raw-string-propertize
Don't insert string delimiter inside strings.
---
rust-mode-tests.el | 13 +++++++++++++
rust-mode.el | 49 ++++++++++++++++++++++++++-----------------------
2 files changed, 39 insertions(+), 23 deletions(-)
diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index 72a9e4e..b21202a 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -1452,6 +1452,19 @@ fn g() {
"g" font-lock-function-name-face
"\"xs\"" font-lock-string-face)))
+(ert-deftest font-lock-string-ending-with-r-word-boundary ()
+ (with-temp-buffer
+ (rust-mode)
+ (insert "const foo = \"foo bar\"")
+ (font-lock-fontify-buffer)
+ ;; right-word should move the point to the end of the words.
+ (goto-char 14)
+ (right-word)
+ (should (equal 17 (point)))
+ (right-word)
+ (should (equal 21 (point)))
+ ))
+
(ert-deftest font-lock-raw-string-trick-ending-followed-by-string-with-quote ()
(rust-test-font-lock
"r\"With what looks like the start of a raw string at the end r#\";
diff --git a/rust-mode.el b/rust-mode.el
index c7afd34..a5f658a 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -1105,41 +1105,44 @@ 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.
(rust--char-literal-rx (1 "\"") (2 "\""))
;; Raw strings.
("\\(r\\)#*\""
- (1 (prog1 "|"
- (goto-char (match-end 0))
- (rust--syntax-propertize-raw-string end))))
+ (0 (ignore
+ (goto-char (match-end 0))
+ (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 (match-beginning 0) end)))))
("[<>]"
(0 (ignore
(when (save-match-data
- [nongnu] elpa/rust-mode 5d0406f 374/486: adjust docstring formatting, (continued)
- [nongnu] elpa/rust-mode 5d0406f 374/486: adjust docstring formatting, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode b445737 376/486: imenu: handle lifetimes in impl blocks., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 72f795d 378/486: Add rust-run and rust-test interactive function, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode e2e713e 384/486: refer to (point-min) instead of 1, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 497d476 388/486: Reverted back to font-lock-fontify-buffer, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode d432409 391/486: Don't insert string delimiter inside strings., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 63deaf3 382/486: Remove old comment, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 55e6cd9 392/486: Add test for word boundaries for string ending with r., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode e53dc8a 394/486: Don't call syntax-ppss twice for raw strings., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode fe02536 395/486: Add `await` to list of keywords, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode c62185a 397/486: Merge pull request #304 from kurnevsky/raw-string-propertize,
ELPA Syncer <=
- [nongnu] elpa/rust-mode 295e234 404/486: rust-compile, rust-run, rust-test: respect rust-cargo-bin. (#321), ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 5aeae14 407/486: rust-format-diff-buffer: use start-process rather than make-process., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 86b82ad 408/486: rust-format-diff-buffer-sentinel: use diff-mode and pop-to-buffer., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 836a8a9 409/486: Don't set indent-tabs-mode. (#324), ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 897af24 410/486: rust-mode.el: check for possible space between variable name and type (#325), ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 74c2647 411/486: Highlight variable name in a for-loop (#326), ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode bb9bbd2 413/486: readme: recommend setting indent-tabs-mode to nil, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 6dca073 414/486: readme: make other useful packages a list, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 7960c74 417/486: Do not allow subword-match when detecting built-in formatting macros, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 5ad9b59 418/486: subword-match for built-in formatting macros: add a test., ELPA Syncer, 2021/08/07