[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Question about syntax coloring using an external program
From: |
Basile Starynkevitch |
Subject: |
Re: Question about syntax coloring using an external program |
Date: |
Sun, 15 Oct 2023 17:34:06 +0200 |
User-agent: |
Mozilla Thunderbird |
Hello all,
On 10/15/23 16:01, Fredrik Öhrström wrote:
I would like to invoke an external program to do syntax coloring and
formatting of the source inside an emacs buffer. I have created an elisp
solution using font-lock mode an regexes, but I would like a 100% correct
coloring solution. It suppose it could be implemented in pure elisp, but
for the moment I need to use an external program to do this. The external
program can annotate the source with tags that probably can be used by
emacs to color the source.
However I am at a loss how to actually implement such a round trip in emacs.
I would greatly appreciate any pointers to similar existing solutions or
hints on how to do it!
I am assuming you use GNU emacs (a recent one) on a GNU/Linux computer.
In theory you could use approaches inspired by the following GNU emacs
extensions:
The ocaml merlin and tuareg modes:
https://ocaml.github.io/merlin/editor/emacs/
Since the ocaml compiler (i.e. ocamlc or ocamlopt) can compute typing
information (e.g. if you compile Ocaml source foo.ml with ocamlc
-bin-annot foo.ml, a binary file foo.cmt is created, containing type
information; which is exploitable with another utility by emacs).
Another approach involves the language server protocol LSP: See
https://en.wikipedia.org/wiki/Language_Server_Protocol
<https://en.wikipedia.org/wiki/Language_Server_Protocol>
(I believe /LSP/ is somehow supported in some extensions of recent GNU
emacs)
Yet another approach would involve GNU emacs extensibility (this might
require patching GNU emacs source code); see its file src/dynlib.c
(since dlopen seems to be callable from GNU emacs). See
https://www.gnu.org/software/emacs/manual/html_node/elisp/Dynamic-Modules.html
and
https://www.gnu.org/software/emacs/manual/html_node/elisp/Writing-Dynamic-Modules.html
Whatever approach you take, please explain it on some public mailing
list, and if possible publish your code (with a GNU emacs compatible
license, perhaps GPLv3+).
In the RefPerSys open source inference engine project (see
https://github.com/RefPerSys/RefPerSys/ ....), we would need (in a few
months) to do something similar.
Thanks
--
Basile Starynkevitch -http://starynkevitch.net/Basile/
email:<basile@starynkevitch.net> (near Paris, France)
only mines opinions - les opinions sont seulement miennes