[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/raku-mode 1fb8435db1 028/253: Highlight variables
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/raku-mode 1fb8435db1 028/253: Highlight variables |
Date: |
Sat, 29 Jan 2022 08:28:36 -0500 (EST) |
branch: elpa/raku-mode
commit 1fb8435db1cdeb54bc7fc867b4d8e614cfb49847
Author: Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
Commit: Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
Highlight variables
---
perl6-font-lock.el | 36 ++++++++++++++++++++++++++++++++----
test/perl6-mode-test.el | 9 +++++++++
2 files changed, 41 insertions(+), 4 deletions(-)
diff --git a/perl6-font-lock.el b/perl6-font-lock.el
index 7bdd193fa7..1d50daf7d2 100644
--- a/perl6-font-lock.el
+++ b/perl6-font-lock.el
@@ -81,6 +81,26 @@
"Face for pragmas in Perl 6."
:group 'perl6)
+(defface perl6-sigil
+ '((t :inherit font-lock-variable-name-face))
+ "Face for variable sigils in Perl 6."
+ :group 'perl6)
+
+(defface perl6-twigil
+ '((t :inherit font-lock-type-face))
+ "Face for variable twigils in Perl 6."
+ :group 'perl6)
+
+(defface perl6-var-package
+ '((t :inherit font-lock-variable-name-face))
+ "Face for variable names in Perl 6."
+ :group 'perl6)
+
+(defface perl6-var-name
+ '((t :inherit font-lock-variable-name-face))
+ "Face for variable names in Perl 6."
+ :group 'perl6)
+
(eval-when-compile
(require 'rx)
@@ -142,9 +162,8 @@
"KitchenSink" "Role" "Int" "Rat" "Buf" "UInt"
"Abstraction" "Numeric" "Real" "Nil"
"Mu")))
- (identifier . ,(rx (and (any "A-Za-z")
- (1+ (or (any "A-Za-z0-9")
- (and (any "-'") (any "A-Za-z")))))))))
+ (identifier . ,(rx (any "A-Za-z") (0+ (any "A-Za-z0-9"))
+ (0+ (any "-'") (any "A-Za-z") (0+ (any
"A-Za-z0-9")))))))
(defmacro perl6-rx (&rest sexps)
"Specialized `rx' variant for perl6-mode."
(let ((rx-constituents (append perl6-rx-constituents rx-constituents)))
@@ -264,7 +283,7 @@ Takes arguments START and END which delimit the region to
propertize."
(funcall
(syntax-propertize-rules
;; [-'] between identifiers are symbol chars
- ((rx (any "A-Za-z") (group (any "-'")) (any "A-Za-z"))
+ ((rx (any "A-Za-z0-9") (group (any "-'")) (any "A-Za-z"))
(1 "_"))
;; same for "::" around identifiers
((rx (or (and "::" symbol-start)
@@ -292,6 +311,15 @@ Takes STATE, the parse state."
(defvar perl6-font-lock-keywords
`(
+ (,(perl6-rx (group (1+ (char "@$%&")))
+ (group (opt (char ".^*?=!~")))
+ (group (opt (or (and "::" (0+ (and identifier "::")))
+ (1+ identifier "::"))))
+ (group identifier symbol-end))
+ (1 'perl6-sigil)
+ (2 'perl6-twigil)
+ (3 'perl6-var-package)
+ (4 'perl6-var-name))
(,(perl6-rx (group (any ".^")) (group identifier symbol-end))
(1 'perl6-operator)
(2 'perl6-identifier))
diff --git a/test/perl6-mode-test.el b/test/perl6-mode-test.el
index 3cb52014cd..e04abd02fa 100644
--- a/test/perl6-mode-test.el
+++ b/test/perl6-mode-test.el
@@ -105,6 +105,15 @@ bar #`<foo> baz"
(perl6-test-with-temp-buffer "BEGIN {"
(should (eq (perl6-test-face-at 1) 'perl6-phaser))))
+(ert-deftest perl5-font-lock-keywords/variable ()
+ :tags '(fontification syntax-table)
+ (perl6-test-with-temp-buffer "$::foo @!bar"
+ (should (eq (perl6-test-face-at 3) 'perl6-var-package))
+ (should (eq (perl6-test-face-at 4) 'perl6-var-name))
+ (should (eq (perl6-test-face-at 8) 'perl6-sigil))
+ (should (eq (perl6-test-face-at 9) 'perl6-twigil))
+ (should (eq (perl6-test-face-at 10) 'perl6-var-name))))
+
(provide 'perl6-mode-test)
;; Local Variables:
- [nongnu] elpa/raku-mode 4b8f5150d6 063/253: Break line in two, (continued)
- [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
- [nongnu] elpa/raku-mode a01e71cde7 081/253: Avoid highlighting numbers and type constraints in strings/comments, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode b7f95283e2 115/253: Remove redundant reduce operator highlighting, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode d33d36e085 165/253: add test for nqp, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 1872efb95a 107/253: Highlight hyper operators, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 1fb8435db1 028/253: Highlight variables,
ELPA Syncer <=
- [nongnu] elpa/raku-mode a82a14ceb2 019/253: Better doc string for perl6-magic-matcher, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 023eb3227b 007/253: Nullify case-fold-search for the entire function body, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 488f3386fe 020/253: Small README fix, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 09663a722d 048/253: Follow http://keepachangelog.com/, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 8fd6683e06 041/253: defvar -> defconst, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode c0978dcf65 054/253: Suggest (package-refresh-contents) since this package is new, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 11891356c0 061/253: Highliht bare sigils, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 04988356e8 065/253: Don't highlight type constraints inside strings/comments, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode af61f78377 011/253: Never look at more than 4k when detecting Perl 6, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode b111c81c75 031/253: Move set operator regex into perl6-rx, ELPA Syncer, 2022/01/29