I've written a simple mode for handling JSON. It uses the derived machinery to re-use most of json-mode's code. However one addition is you can insert elisp into the JSON text which is evaluated at JSON submission time. For example an excerpt of the json looks like this:
{
"parameters": {
"IRC_USER": "stsquad",
"PUB_KEY": `(format "\"%s\"" (s-trim (shell-command-to-string "cat ~/.ssh/id_rsa.pub")))`
}
}
Currently the syntax highlighting of this text is broken as the JSON syntax hightlighter get's thrown by the elisp. I'd like to set-up a nested syntax table so the elisp is properly recognised as elisp when inside the escape characters (I've chosen ` in this case). I understand you can join char-tables (which syntax-tables are built from) with something like:
(defvar lava-mode-syntax-table
(let ((json-table (copy-syntax-table json-mode-syntax-table))
(elisp-table (copy-syntax-table lisp-mode-syntax-table)))
(set-char-table-parent elisp-table json-table)
(modify-syntax-entry ?` "(`" json-table)
(modify-syntax-entry ?` ")`" json-table)
json-table)
"LAVA Mode syntax table.
This is a combination of json-mode-syntax-table with an escape into
lisp-mode-syntax table for the embedded elisp.")
But I don't understand how I can modify the syntax table to start using the child (elisp) syntax table while between the escape characters?