[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] externals/caml b5bf207 160/197: update caml-font.el to deal wit
From: |
Stefan Monnier |
Subject: |
[nongnu] externals/caml b5bf207 160/197: update caml-font.el to deal with the quoted string syntax |
Date: |
Sat, 21 Nov 2020 01:19:58 -0500 (EST) |
branch: externals/caml
commit b5bf207a675ae93def1ebed4eb47754d3aff1a58
Author: Damien Doligez <damien.doligez@inria.fr>
Commit: Damien Doligez <damien.doligez@inria.fr>
update caml-font.el to deal with the quoted string syntax
---
caml-font.el | 44 ++++++++++++++++++++++++++++++++++++--------
1 file changed, 36 insertions(+), 8 deletions(-)
diff --git a/caml-font.el b/caml-font.el
index 40bee0a..9c28e01 100644
--- a/caml-font.el
+++ b/caml-font.el
@@ -172,23 +172,28 @@
"'\\(\015\012\\|[\012\015]\\)"
)
+; match an opening delimiter for a quoted string
+(defconst caml-font-quoted-string-start-re
+ "{\\([a-z]*\\)|"
+)
+
; match any token or sequence of tokens that cannot contain a
-; quote, double quote, a start of comment, or a newline
+; quote, double quote, a start of comment or quoted string, or a newline
; note: this is only to go faster than one character at a time
(defconst caml-font-other-re
- "[^A-Za-z_0-9\012\015\300-\326\330-\366\370-\377'\"(]+"
+ "[^A-Za-z_0-9\012\015\300-\326\330-\366\370-\377'\"({]+"
)
; match any sequence of non-special characters in a comment
; note: this is only to go faster than one character at a time
(defconst caml-font-other-comment-re
- "[^(*\"'\012\015]+"
+ "[^{(*\"'\012\015]+"
)
; match any sequence of non-special characters in a string
; note: this is only to go faster than one character at a time
(defconst caml-font-other-string-re
- "[^\\\"\012\015]"
+ "[^|\\\"\012\015]"
)
; match a newline
@@ -230,8 +235,9 @@
; depth is the depth of nested comments at this point
; it must be a non-negative integer
; st can be:
-; nil -- we are in the base state
-; t -- we are within a string
+; nil -- we are in the base state
+; t -- we are within a string
+; a string -- we are within a quoted string and st is the closing delimiter
(defun caml-font-annotate (st depth)
(let ((continue t))
@@ -254,6 +260,11 @@
'syntax-table (string-to-syntax "|"))
(goto-char (match-end 0))
(setq st t))
+ ((caml-font-looking-at caml-font-quoted-string-start-re)
+ (put-text-property (point) (1+ (point))
+ 'syntax-table (string-to-syntax "|"))
+ (goto-char (match-end 0))
+ (setq st (concat "|" (match-string 1) "}")))
((caml-font-looking-at "(\\*")
(put-text-property (point) (1+ (point))
'syntax-table (string-to-syntax "!"))
@@ -297,7 +308,7 @@
(remove-text-properties (point) (1+ (point))
'(syntax-table nil caml-font-state nil))
(goto-char (1+ (point))))))
- (t ; string state inside or outside a comment
+ ((equal st t) ; string state inside or outside a comment
(cond
((caml-font-looking-at "\"")
(when (= depth 0)
@@ -315,7 +326,24 @@
(t
(remove-text-properties (point) (1+ (point))
'(syntax-table nil caml-font-state nil))
- (goto-char (1+ (point)))))))))
+ (goto-char (1+ (point))))))
+ ((stringp st) ; quoted-string state inside or outside comment
+ (cond
+ ((caml-font-looking-at st)
+ (when (= depth 0)
+ (put-text-property (1- (match-end 0)) (match-end 0)
+ 'syntax-table (string-to-syntax "|")))
+ (goto-char (match-end 0))
+ (setq st nil))
+ ((caml-font-looking-at caml-font-other-string-re)
+ (goto-char (match-end 0)))
+ (t
+ (remove-text-properties (point) (1+ (point))
+ '(syntax-table nil caml-font-state nil))
+ (goto-char (1+ (point))))))
+ (t ; should not happen
+ (remove-text-properties (point) (1+ (point))
+ '(syntax-table nil caml-font-state nil))))))
)
; This is the hook function for font-lock-extend-after-change-function
- [nongnu] externals/caml 3190d71 145/197: PR#5070, continued: also parse backtrace locations, (continued)
- [nongnu] externals/caml 3190d71 145/197: PR#5070, continued: also parse backtrace locations, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml f6a12d8 149/197: merge patch by Stefan Monnier from PR#5884, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml f6cd0b9 078/197: petit nettoyage, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 474e6ee 102/197: only set type faces where needed, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml b1eaaab 115/197: merge changes 3.10.0 -> 3.10.1, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 43a83dc 118/197: bug string-to-number, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml c525bf8 121/197: clean up spaces and tabs, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 73599dd 129/197: uniform .ignore system, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml eec3351 144/197: do byte-compile file caml-font.el, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml b1139bc 146/197: merge version/4.00 at revision 12866, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml b5bf207 160/197: update caml-font.el to deal with the quoted string syntax,
Stefan Monnier <=
- [nongnu] externals/caml d3bc724 167/197: caml.el: Pass the `system` flag when defining abbrevs, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml c0b7050 163/197: caml-types.el: Cosmetic changes., Stefan Monnier, 2020/11/21
- [nongnu] externals/caml f9a4fd4 177/197: makefiles: turn the 'install' command into a variable, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 2bc0b92 178/197: factorize common makefile definitions in Makefile.common, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 78b3169 182/197: Move config/Makefile to Makefile.config, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 9288416 183/197: Introduce and use ROOTDIR in more makefiles, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 1756296 140/197: PR#5137: caml-types-explore does not work, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 02303ea 147/197: PR#5727: emacs caml-mode indents shebang line in toplevel scripts, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 2c3dbdb 157/197: merge branch 4.02 from 4.02.1 (rev 15540) to a few fixes after 4.02.2 (rev 16205), Stefan Monnier, 2020/11/21
- [nongnu] externals/caml ed94de1 159/197: simplify .gitignore; remove .ignore files and tools/setignore; adjust tools/check-typo, Stefan Monnier, 2020/11/21