emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/rust-mode 0d408d5 357/486: Merge pull request #253 from jj


From: ELPA Syncer
Subject: [nongnu] elpa/rust-mode 0d408d5 357/486: Merge pull request #253 from jjwest/master
Date: Sat, 7 Aug 2021 09:25:52 -0400 (EDT)

branch: elpa/rust-mode
commit 0d408d5fe5bae38f6463e78486eab4263d4ae40d
Merge: b911835 705f3e4
Author: Niko Matsakis <niko@alum.mit.edu>
Commit: GitHub <noreply@github.com>

    Merge pull request #253 from jjwest/master
    
    Improved font-locking for print macros
---
 rust-mode-tests.el | 13 +++++++++++++
 rust-mode.el       |  4 ++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index 6c6e9af..fd29d5d 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -2193,6 +2193,19 @@ fn main() {
      "\"\"" font-lock-string-face
      "/* " font-lock-comment-delimiter-face
      "print!(\"\"); */" font-lock-comment-face))
+  ;; with newline directly following delimiter
+  (rust-test-font-lock
+   "print!(\n\"\"\n); { /* print!(\"\"); */ }"
+   '("print!" rust-builtin-formatting-macro-face
+     "\"\"" font-lock-string-face
+     "/* " font-lock-comment-delimiter-face
+     "print!(\"\"); */" font-lock-comment-face))
+  ;; with empty println!()
+  (rust-test-font-lock
+   "println!(); { /* println!(); */ }"
+   '("println!" rust-builtin-formatting-macro-face
+     "/* " font-lock-comment-delimiter-face
+     "println!(); */" font-lock-comment-face))
   ;; other delimiters
   (rust-test-font-lock
    "print!{\"\"}; { /* no-op */ }"
diff --git a/rust-mode.el b/rust-mode.el
index a5987ed..0c31b6c 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -633,7 +633,7 @@ match data if found. Returns nil if not within a Rust 
string."
   "List of builtin Rust macros for string formatting used by 
`rust-mode-font-lock-keywords'. (`write!' is handled separately.)")
 
 (defvar rust-formatting-macro-opening-re
-  "[[:space:]]*[({[][[:space:]]*"
+  "[[:space:]\n]*[({[][[:space:]\n]*"
   "Regular expression to match the opening delimiter of a Rust formatting 
macro.")
 
 (defvar rust-start-of-string-re
@@ -661,7 +661,7 @@ match data if found. Returns nil if not within a Rust 
string."
       1 font-lock-preprocessor-face keep)
 
      ;; Builtin formatting macros
-     (,(concat (rust-re-grab (concat (regexp-opt 
rust-builtin-formatting-macros) "!")) (concat rust-formatting-macro-opening-re 
rust-start-of-string-re))
+     (,(concat (rust-re-grab (concat (regexp-opt 
rust-builtin-formatting-macros) "!")) (concat rust-formatting-macro-opening-re 
"\\(?:" rust-start-of-string-re) "\\)?")
       (1 'rust-builtin-formatting-macro-face)
       (rust-string-interpolation-matcher
        (rust-end-of-string)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]