[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/raku-mode d8c1ae4d87 089/253: Move context-checking into a
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/raku-mode d8c1ae4d87 089/253: Move context-checking into a function |
Date: |
Sat, 29 Jan 2022 08:28:45 -0500 (EST) |
branch: elpa/raku-mode
commit d8c1ae4d87c5ade6a69c8e2084eb4c641f0c606f
Author: Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
Commit: Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
Move context-checking into a function
---
perl6-font-lock.el | 40 +++++++++++++++++++++++-----------------
1 file changed, 23 insertions(+), 17 deletions(-)
diff --git a/perl6-font-lock.el b/perl6-font-lock.el
index 1b79c44244..443afc2097 100644
--- a/perl6-font-lock.el
+++ b/perl6-font-lock.el
@@ -273,6 +273,18 @@
table)
"Syntax table for bracketing constructs.")
+(defun perl6-syntax-context (&optional state)
+ "Return the syntactic context at the parse state of STATE.
+
+If STATE is not provided, the return value of `syntax-ppss' will be used."
+ (let* ((state (or state (syntax-ppss)))
+ (in-string (nth 3 state))
+ (in-comment (nth 4 state)))
+ (cond
+ (in-string 'string)
+ (in-comment 'comment)
+ (t nil))))
+
(defun perl6-forward-brackets (open close length)
"Move point past the end of a bracketed structure.
@@ -344,12 +356,9 @@ OPEN-ANGLES is the opening delimiter (e.g. \"«\" or
\"<<\")."
'syntax-table (string-to-syntax "|"))))))))
(defun perl6-syntax-propertize-backslash ()
- (let* ((state (syntax-ppss))
- (in-string (nth 3 state))
- (in-comment (nth 4 state)))
- (unless (or in-string in-comment)
- (put-text-property (match-beginning 0) (match-end 0)
- 'syntax-table (string-to-syntax ".")))))
+ (when (eq (perl6-syntax-context) nil)
+ (put-text-property (match-beginning 0) (match-end 0)
+ 'syntax-table (string-to-syntax "."))))
(defun perl6-add-font-lock-hint (property &optional group)
(let ((beg (match-beginning (or group 1)))
@@ -387,11 +396,10 @@ Takes arguments START and END which delimit the region to
propertize."
"Specify font lock faces based on syntax table entries.
Takes STATE, the parse state."
- (let ((in-string (nth 3 state))
- (in-comment (nth 4 state)))
+ (let ((context (perl6-syntax-context state)))
(cond
- (in-string 'perl6-string)
- (in-comment 'perl6-comment))))
+ ((eq context 'string) 'perl6-string)
+ ((eq context 'comment) 'perl6-comment))))
(defun perl6-search-when (regex condition limit)
"Search forward for REGEX if the match satisfies CONDITION.
@@ -429,13 +437,11 @@ LIMIT can be used to bound the search."
(opt (group (symbol type-property))))))
(lambda ()
(goto-char (match-beginning 0))
- (let* ((state (syntax-ppss))
- (in-string (nth 3 state))
- (in-comment (nth 4 state)))
- (not (or in-string
- in-comment
- (looking-back (rx (or (char ".^")
- (and line-start (0+ space)))))))))
+ (let ((context (perl6-syntax-context)))
+ (and
+ (eq context nil)
+ (not (looking-back (rx (or (char ".^")
+ (and line-start (0+ space)))))))))
limit))
(defun perl6-match-property (property context limit)
- [nongnu] elpa/raku-mode 9ca9a0caa7 082/253: Highlight identifiers containing underscore, (continued)
- [nongnu] elpa/raku-mode 9ca9a0caa7 082/253: Highlight identifiers containing underscore, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode c93daf2353 096/253: Avoid highlighting X::Foo and X:: as cross-metaoperators, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 94ba374818 117/253: Realign code, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode e4a86350be 111/253: Fix tests in light of recent changes, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 9ca2944f8f 100/253: Highlight :!foo correctly, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 1d2f63b715 083/253: Highlight [RSXZ] on their own, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 7e60f137ce 095/253: Fix highlighting of some reduce ops, like [<], ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode c91c403320 123/253: Fix highlighting of infix:<<lt>> and friends, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 155abadb6a 124/253: Improve highlighting of numbers, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 1277ec749e 097/253: Fix highlighting of words in identifers, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode d8c1ae4d87 089/253: Move context-checking into a function,
ELPA Syncer <=
- [nongnu] elpa/raku-mode c5f3d072e5 120/253: Don't highlight string delimiters inside comments, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 19f4243934 125/253: Remove unnecessary check for syntactic context, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 6c97f87fd8 135/253: Correctly highlight ::*Foo::Bar, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 309720c98a 148/253: correct indentation, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode c0b40f2ad5 140/253: Correctly highlight custom sub/grammar/etc names that clash with keywords, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 89d6145859 149/253: use proper name for a multi sub or method, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode a594f53e09 141/253: Highlight with/orwith/without, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode a0cd586520 170/253: Following this advice http://stackoverflow.com/questions/26108655/error-updating-emacs-packages-failed-to-download-gnu-archive, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 4a018be623 172/253: Adds BagHash to check again, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 992d8af9de 164/253: add test for private methods, ELPA Syncer, 2022/01/29