branch: elpa/raku-mode
commit 2a9e959a24ba638aff11fcf3f3ebbddb0a0399ec
Author: Hinrik Örn Sigurðsson <[email protected]>
Commit: Hinrik Örn Sigurðsson <[email protected]>
Improve highlighting of bracketed strings/comments
Now we won't try to add syntax properties to <foo> strings inside
comments.
We now pay attention to backslashes when looking for the closing
delimiter or nested opening/closing delimiters.
---
perl6-font-lock.el | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/perl6-font-lock.el b/perl6-font-lock.el
index b6e4816d8d..90bc64544a 100644
--- a/perl6-font-lock.el
+++ b/perl6-font-lock.el
@@ -292,21 +292,24 @@ Skips over any nested balanced brackets.
OPEN and CLOSE are the bracketing characters (e.g. ?< and ?>).
LENGTH is the length of the brackets (e.g. 2 for a <<foo>>)."
- (let ((pattern (rx-to-string `(or (group (= ,length ,open))
- (group (= ,length ,close)))))
+ (let ((pattern (rx-to-string `(and (group (0+ "\\"))
+ (or (group (= ,length ,open))
+ (group (= ,length ,close))))))
(found-closing nil)
(depth 1))
(while (and (not found-closing)
(< (point) (point-max)))
(re-search-forward pattern (point-max) 'noerror)
- (cond ((match-string 1)
- (if (looking-at (rx-to-string open))
- (re-search-forward (rx-to-string `(1+ ,open)))
- (setq depth (1+ depth))))
- ((match-string 2)
- (setq depth (1- depth))
- (when (eq depth 0)
- (setq found-closing t)))))))
+ (when (or (not (match-string 1))
+ (= 0 (% (length (match-string 1)) 2)))
+ (cond ((match-string 2)
+ (if (looking-at (rx-to-string open))
+ (re-search-forward (rx-to-string `(1+ ,open)))
+ (setq depth (1+ depth))))
+ ((match-string 3)
+ (setq depth (1- depth))
+ (when (eq depth 0)
+ (setq found-closing t))))))))
(defun perl6-syntax-propertize-embedded-comment ()
"Add syntax properties to embedded comments \(#`<<foo>>\)."
@@ -384,6 +387,8 @@ Takes arguments START and END which delimit the region to
propertize."
(0 "_"))
((rx "#" (any "`|="))
(0 (ignore (perl6-syntax-propertize-embedded-comment))))
+ ((rx "#" (0+ not-newline))
+ (0 (ignore)))
((perl6-rx (or set-operator rsxz-operator))
(0 (ignore (perl6-add-font-lock-hint 'perl6-metaoperator 0))))
((rx (1+ (char "<«")))