[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/raku-mode cf09f024a3 099/253: Support some unicode quote d
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/raku-mode cf09f024a3 099/253: Support some unicode quote delimiters |
Date: |
Sat, 29 Jan 2022 08:28:46 -0500 (EST) |
branch: elpa/raku-mode
commit cf09f024a3532e287042d8db2b38660b1db8a761
Author: Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
Commit: Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
Support some unicode quote delimiters
Resolves #2.
---
perl6-font-lock.el | 58 ++++++++++++++++++++++++++++++++++++------------------
1 file changed, 39 insertions(+), 19 deletions(-)
diff --git a/perl6-font-lock.el b/perl6-font-lock.el
index dde29df842..81a64ced6b 100644
--- a/perl6-font-lock.el
+++ b/perl6-font-lock.el
@@ -273,6 +273,17 @@
table)
"Syntax table for bracketing constructs.")
+(defconst perl6-string-delimiter-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)
+ (modify-syntax-entry ?“ "(”" table)
+ (modify-syntax-entry ?” ")“" table)
+ table)
+ "Syntax table for string delimiters.")
+
(defun perl6-syntax-context (&optional state)
"Return the syntactic context at the parse state of STATE.
@@ -311,23 +322,27 @@ LENGTH is the length of the brackets (e.g. 2 for a
<<foo>>)."
(when (eq depth 0)
(setq found-closing t))))))))
-(defun perl6-syntax-propertize-embedded-comment ()
- "Add syntax properties to embedded comments \(#`<<foo>>\)."
- (with-syntax-table perl6-bracket-syntax-table
- (when (and (following-char)
- (eq ?\( (char-syntax (following-char))))
- (let* ((comment-beg (- (point) 2))
- (open-delim (following-char))
- (close-delim (matching-paren open-delim)))
- (put-text-property comment-beg (1+ comment-beg)
- 'syntax-table (string-to-syntax "!"))
- (re-search-forward (rx-to-string `(1+ ,open-delim)))
- (let ((delim-length (length (match-string 0))))
- (perl6-forward-brackets open-delim close-delim delim-length)
- (let ((comment-end (point)))
- (put-text-property comment-beg comment-end 'syntax-multiline t)
- (put-text-property (- comment-end 1) comment-end
- 'syntax-table (string-to-syntax "!"))))))))
+(defun perl6-syntax-propertize-delimiters (syntax &optional offset)
+ "Add syntax properties to a delimited region.
+
+SYNTAX is the type of syntax to apply to the delimiters \(such as \"!\"\).
+
+OFFSET can be used to shift the starting position (relative to point) of the
+opening delimiter."
+ (when (and (following-char)
+ (eq ?\( (char-syntax (following-char))))
+ (let* ((delim-beg (+ (point) (or offset 0)))
+ (open-delim (following-char))
+ (close-delim (matching-paren open-delim)))
+ (put-text-property delim-beg (1+ delim-beg)
+ 'syntax-table (string-to-syntax syntax))
+ (re-search-forward (rx-to-string `(1+ ,open-delim)))
+ (let ((delim-length (length (match-string 0))))
+ (perl6-forward-brackets open-delim close-delim delim-length)
+ (let ((delim-end (point)))
+ (put-text-property delim-beg delim-end 'syntax-multiline t)
+ (put-text-property (- delim-end 1) delim-end
+ 'syntax-table (string-to-syntax syntax)))))))
(defun perl6-syntax-propertize-angles (open-angles)
"Add syntax properties to angle-bracketed quotes (e.g. <foo> and «bar»).
@@ -387,7 +402,8 @@ Takes arguments START and END which delimit the region to
propertize."
(1 "_")
(2 "_"))
((rx "#" (any "`|="))
- (0 (ignore (perl6-syntax-propertize-embedded-comment))))
+ (0 (ignore (with-syntax-table perl6-bracket-syntax-table
+ (perl6-syntax-propertize-delimiters "!" -2)))))
((rx "#" (0+ not-newline))
(0 (ignore)))
((perl6-rx (or set-operator rsxz-operator reduce-operator))
@@ -395,7 +411,11 @@ Takes arguments START and END which delimit the region to
propertize."
((rx (1+ (char "<«")))
(0 (ignore (perl6-syntax-propertize-angles (match-string 0)))))
((rx "\\")
- (0 (ignore (perl6-syntax-propertize-backslash)))))
+ (0 (ignore (perl6-syntax-propertize-backslash))))
+ ((rx (any "‘「“"))
+ (0 (ignore (progn (backward-char)
+ (with-syntax-table perl6-string-delimiter-syntax-table
+ (perl6-syntax-propertize-delimiters "|")))))))
start end)))
(defun perl6-font-lock-syntactic-face (state)
- [nongnu] elpa/raku-mode 0968a528bb 216/253: Fix wrong slashes., (continued)
- [nongnu] elpa/raku-mode 0968a528bb 216/253: Fix wrong slashes., ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 21af6e8398 224/253: Add comment-style highlighting to POD., ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 9fa9e3968e 091/253: pcase is more straightforward than let+cond here, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode aa5078f9cc 112/253: Mention test suite in README.md, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 299099e246 102/253: Simplify variable fontification, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 8ecc3daa40 113/253: Expand comment, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 6d4ef1743a 118/253: More robust comment highlighting, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 07b36e8506 114/253: Amend comment about magic-mode-alist a bit, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 730155c851 103/253: Apply prefix syntax property to sigils and twigils, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 2b5f69ade1 094/253: Fix highlighting of some non-alphanumberic RSXZ metaops, like C«R<», ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode cf09f024a3 099/253: Support some unicode quote delimiters,
ELPA Syncer <=
- [nongnu] elpa/raku-mode 87fdf3d563 085/253: Highlight numbered match variables ($1, $2, ...), ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 2a9e959a24 092/253: Improve highlighting of bracketed strings/comments, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode aa57012ec3 138/253: Minor change to magic pattern, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 4aa7fde34b 134/253: Separate syntax flags, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 3d4a45d644 128/253: No identifiers in comments after recent changes, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 883a60e8ef 127/253: Clean up label pattern, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode c8e8ebe289 150/253: fix the range of choices more completely, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 8319cebe75 147/253: remove imenu item, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode fbac3c871d 196/253: Merge branch 'repl' of github.com:matiaslina/perl6-mode into repl, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 92c9915396 160/253: More fixes for highlighting of angled strings, ELPA Syncer, 2022/01/29