[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/raku-mode 2810276a92 023/253: Initial support for double-q
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/raku-mode 2810276a92 023/253: Initial support for double-quote-words |
Date: |
Sat, 29 Jan 2022 08:28:35 -0500 (EST) |
branch: elpa/raku-mode
commit 2810276a929d40db888640ab373aba282bc840a0
Author: Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
Commit: Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
Initial support for double-quote-words
No interpolation yet, though.
---
perl6-font-lock.el | 28 +++++++++++++++++++++++-----
test/perl6-mode-test.el | 11 +++++++++++
2 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/perl6-font-lock.el b/perl6-font-lock.el
index d679fe7329..10c5a8d44b 100644
--- a/perl6-font-lock.el
+++ b/perl6-font-lock.el
@@ -177,12 +177,14 @@
table)
"The top level syntax table for Perl 6.")
-(defvar perl6-comment-syntax-table
+(defvar perl6-bracket-syntax-table
(let ((table (make-syntax-table perl6-mode-syntax-table)))
(modify-syntax-entry ?< "(>" table)
(modify-syntax-entry ?> ")<" table)
+ (modify-syntax-entry ?« "(»" table)
+ (modify-syntax-entry ?» ")«" table)
table)
- "Syntax table for comments.")
+ "Syntax table for bracketing constructs.")
(defun perl6-forward-brackets (open close length)
"Move point past the end of a bracketed structure.
@@ -209,7 +211,7 @@ LENGTH is the length of the brackets (e.g. 2 for a
<<foo>>)."
(defun perl6-syntax-propertize-embedded-comment ()
"Add syntax properties to embedded comments \(#`<<foo>>\)."
- (with-syntax-table perl6-comment-syntax-table
+ (with-syntax-table perl6-bracket-syntax-table
(when (and (following-char)
(eq ?\( (char-syntax (following-char))))
(let* ((comment-beg (- (point) 2))
@@ -225,6 +227,21 @@ LENGTH is the length of the brackets (e.g. 2 for a
<<foo>>)."
(put-text-property (- comment-end 1) comment-end
'syntax-table (string-to-syntax "!"))))))))
+(defun perl6-syntax-propertize-dq-words ()
+ "Add syntax properties to double-quoted word lists \(«foo $bar baz»\)."
+ (with-syntax-table perl6-bracket-syntax-table
+ (let* ((quote-beg (match-beginning 0))
+ (quote-chars (match-string 0))
+ (quote-length (length quote-chars))
+ (open-quote (string-to-char (car (split-string quote-chars "" t))))
+ (close-quote (matching-paren open-quote)))
+ (put-text-property quote-beg (1+ quote-beg) 'syntax-table
(string-to-syntax "|"))
+ (perl6-forward-brackets open-quote close-quote quote-length)
+ (let ((quote-end (point)))
+ (put-text-property quote-beg quote-end 'syntax-multiline t)
+ (put-text-property (- quote-end 1) quote-end
+ 'syntax-table (string-to-syntax "|"))))))
+
(defun perl6-syntax-propertize (start end)
"Add context-specific syntax properties to code.
@@ -240,9 +257,10 @@ Takes arguments START and END which delimit the region to
propertize."
((rx (or (and "::" symbol-start)
(and symbol-end "::")))
(0 "_"))
- ; multiline comments
((rx "#`")
- (0 (ignore (perl6-syntax-propertize-embedded-comment)))))
+ (0 (ignore (perl6-syntax-propertize-embedded-comment))))
+ ((rx (or "«" "<<"))
+ (0 (ignore (perl6-syntax-propertize-dq-words)))))
start end)))
(defun perl6-font-lock-syntactic-face (state)
diff --git a/test/perl6-mode-test.el b/test/perl6-mode-test.el
index 2c9a268bc2..484eebf7cc 100644
--- a/test/perl6-mode-test.el
+++ b/test/perl6-mode-test.el
@@ -58,6 +58,17 @@ POS."
(should (eq (perl6-test-syntax-at 10) 'symbol))
(should (eq (perl6-test-syntax-at 11)
'symbol))))
+(ert-deftest perl6-syntax-propertize/dq-words ()
+ :tags '(syntax-table syntax-properties)
+ (perl6-test-with-temp-buffer "foo «bar» bla <<baz>> quux"
+ (should (eq (perl6-test-syntax-at 1) 'word))
+ (should (eq (perl6-test-syntax-at 5)
'generic-string))
+ (should (eq (perl6-test-syntax-at 9)
'generic-string))
+ (should (eq (perl6-test-syntax-at 15)
'generic-string))
+ (should (eq (perl6-test-syntax-at 16)
'punctuation))
+ (should (eq (perl6-test-syntax-at 20)
'punctuation))
+ (should (eq (perl6-test-syntax-at 21)
'generic-string))))
+
(ert-deftest perl6-mode-syntax-table/fontify-dq-string ()
:tags '(fontification syntax-table)
(should (eq (perl6-test-face-at 8 "$foo = \"bar\"") 'perl6-string)))
- [nongnu] branch elpa/raku-mode created (now 977b14a7c1), ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 014a7b44fd 010/253: Abort Perl 6 detection if we reach end of file, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode d3ba5aab7e 036/253: Try to fix formatting of MELPA badge, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 2810276a92 023/253: Initial support for double-quote-words,
ELPA Syncer <=
- [nongnu] elpa/raku-mode 5e7b03579f 009/253: Document filetype detection, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 09460a1f18 006/253: Include more Perl 6 declarations for magic-mode detections, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode edbe902cf4 021/253: Update Emacs version requirement in README, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 8043c16dd1 016/253: Grammar fixes, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode ec9d721334 024/253: Simpler approach for double-quote-words, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 6e8b0fd8c4 032/253: Highlight "rule q {}" correctly, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode fbe23fa55d 014/253: Require whitespace after (my|our), ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 4556ff4e9b 038/253: Support non-ASCII identifiers, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode a349f9a7ff 076/253: Also highlight labels after loop control statements, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 1eaa1452bc 067/253: More robust highlighting of set operators, ELPA Syncer, 2022/01/29