[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/raku-mode ce3ef00b82 026/253: Syntax propertize <quoted wo
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/raku-mode ce3ef00b82 026/253: Syntax propertize <quoted words> |
Date: |
Sat, 29 Jan 2022 08:28:36 -0500 (EST) |
branch: elpa/raku-mode
commit ce3ef00b826f7613ef07450b8c15bd0a3a5fe722
Author: Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
Commit: Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
Syntax propertize <quoted words>
This is more or less a direct port of the regexes used in vim-perl.
Works decently, but can be made more efficient by doing only doing one
pair of looking-back/looking-at calls.
---
perl6-font-lock.el | 25 ++++++++++++++++++++++++-
test/perl6-mode-test.el | 8 ++++++++
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/perl6-font-lock.el b/perl6-font-lock.el
index 251ad203e9..a2452c0f5b 100644
--- a/perl6-font-lock.el
+++ b/perl6-font-lock.el
@@ -227,6 +227,27 @@ 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-angle ()
+ "Add syntax properties to angle-bracketed quotes (<foo bar>)."
+ (unless (or (looking-at "[-=]")
+ (looking-back "[+~=!]<" 2))
+ (when (or (or (not (looking-at "[\s\n]"))
+ (not (looking-back "[\s\n]<" 1)))
+ (looking-at "<\s+>")
+ (looking-back "=\s+<")
+ (looking-back "\(\s*<")
+ (or (looking-at "\s*$") (looking-back "^\s*<"))
+ (looking-back (perl6-rx (symbol (or "enum" "for" "any" "all"
"none"))
+ (0+ space) (opt "\)") (0+ space) "<")))
+ (let ((quote-beg (- (point) 1)))
+ (put-text-property quote-beg (1+ quote-beg)
+ 'syntax-table (string-to-syntax "|"))
+ (search-forward ">")
+ (let ((quote-end (- (point) 1)))
+ (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.
@@ -251,7 +272,9 @@ Takes arguments START and END which delimit the region to
propertize."
((rx (group "<") "<" (0+ (not-char ">")) (opt (and ">" (group ">"))))
(0 (ignore (put-text-property (match-beginning 0) (match-end 0)
'syntax-multiline t)))
(1 "|")
- (2 "|")))
+ (2 "|"))
+ ((rx "<")
+ (0 (ignore (perl6-syntax-propertize-angle)))))
start end)))
(defun perl6-font-lock-syntactic-face (state)
diff --git a/test/perl6-mode-test.el b/test/perl6-mode-test.el
index 484eebf7cc..a665d3a8e1 100644
--- a/test/perl6-mode-test.el
+++ b/test/perl6-mode-test.el
@@ -58,6 +58,14 @@ POS."
(should (eq (perl6-test-syntax-at 10) 'symbol))
(should (eq (perl6-test-syntax-at 11)
'symbol))))
+(ert-deftest perl6-syntax-propertize/angles ()
+ :tags '(syntax-table syntax-properties)
+ (perl6-test-with-temp-buffer "my @foo = <bar>; for @foo <-> $bar {}"
+ (should (eq (perl6-test-syntax-at 11)
'generic-string))
+ (should (eq (perl6-test-syntax-at 15)
'generic-string))
+ (should (eq (perl6-test-syntax-at 27)
'punctuation))
+ (should (eq (perl6-test-syntax-at 29)
'punctuation))))
+
(ert-deftest perl6-syntax-propertize/dq-words ()
:tags '(syntax-table syntax-properties)
(perl6-test-with-temp-buffer "foo «bar» bla <<baz>> quux"
- [nongnu] elpa/raku-mode 357a72be71 229/253: Fix syntax highlighting for code blocks in POD., (continued)
- [nongnu] elpa/raku-mode 357a72be71 229/253: Fix syntax highlighting for code blocks in POD., ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 43fd562825 227/253: Merge pull request #36 from matiaslina/dont-highlight-operators-in-variables, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 5f885f4961 177/253: There's no need to install this, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode f6dcbaf9a4 190/253: Add raku exec path to customization group, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 3d43b91d82 209/253: Add syntax highlighting to REPL., ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode e0639c89a3 230/253: Merge pull request #35 from tmtvl/24-highlight-pod-the-same-as-comments, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 4ed7c06294 200/253: also detect '.rakutest' extension, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode b6a5535e27 219/253: Merge pull request #29 from tmtvl/auto-insert-skeletons, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 8a6e17f174 234/253: Merge pull request #41 from anquegi/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 6fa383e25f 003/253: More robust magic matching of Perl 6 code, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode ce3ef00b82 026/253: Syntax propertize <quoted words>,
ELPA Syncer <=
- [nongnu] elpa/raku-mode 3cf62b8383 002/253: Only check if .t/.pl/.pm files contain Perl 6 code, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 1b0698744b 015/253: Move Perl 6 detection into perl6-detect.el, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 2f3b6f5eec 039/253: Remvoe superfluous space, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 1a7cb03101 050/253: Slight change in wording, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 4b8f5150d6 063/253: Break line in two, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 44c6e42d56 044/253: Highlight basic punctuation/match variables, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode eb32e01386 045/253: Correctly highilight version literal ranges, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode d2dfe7031c 073/253: Don't apply punctuation syntax to all set operators, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode e7e04422d0 052/253: Don't bug me with email notifications, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 4ec31b6904 070/253: Highlight number literals with an explicit base, ELPA Syncer, 2022/01/29