Hi

I would suggest taking a little time to learn about tree-sitter


   - Watch this:
   
https://www.thestrangeloop.com/2018/tree-sitter---a-new-parsing-system-for-programming-tools.html
   - Explore https://tree-sitter.github.io/tree-sitter/  In particular use
   the Playground are to see the parse tree for some code (MATLAB isn't there
   but several other languages are available in the playground).
   - Google for info on tree-sitter

I'm also very new to tree-sitter, so I'm still learning it. With Emacs 30,
which the matlab-ts-mode is based on, I've written a new major mode,
matlab-ts-mode. Think of it as a much better matlab-mode. When you open a
*.m file, run

 M-x matlab-ts-mode

What happened with Emacs is that there was one path being taken for
tree-sitter integration which is in https://emacs-tree-sitter.github.io/
and that is only valid upto Emacs 29. It should not be used with Emacs 30.
In Emacs 30, tree-sitter was built-in, which is a major step forward for
improved language integration into Emacs. I've been writing a guide to
creation of a tree-sitter major mode in the contributing subdirectory of
the Emacs-MATLAB-mode subdirectory on the matlab-ts-mode branch. The guide
is missing a lot, but still should be helpful. Once I have the
matlab-ts-mode done, I plan on cleaning up the guide and sending it to the
Emacs developers to see if it can be put in the manual because details on
how to do this are light and my guide is trying to address that.

There is an excellent https://github.com/emacs-tree-sitter/tree-sitter-langs
site that is for Emacs 29 and earlier, so don't install that directly with
Emacs 30. For Emacs 30, you either need to build the matlab tree-sitter
grammer shared library,  ~/.emacs.d/tree-sitter/libtree-sitter-matlab.so or
extract it from the latest release in
https://github.com/emacs-tree-sitter/tree-sitter-langs. To extract the
latest,

   1. click the "latest" link on
   https://github.com/emacs-tree-sitter/tree-sitter-langs
   2. Download the *.gz file
   3. Open the *.gz file in Emacs
   4. Look for matlab.so (or matlab.dll or matlab.dylib)
   5. Save that out to ~/.emacs/tree-sitter/libtree-sitter-matlab.so (or
   .dll or .dylib depending on what type of system you are on).

Creating the HOWTO-elpa.org would be great. Can you put it in the
contributing subdirectory?

Also, it would be good to do changes on the matlab-ts-mode branch so it can
be merged into default easily.

Thanks
John

On Thu, Jul 17, 2025 at 11:34 AM Uwe Brauer <o...@mat.ucm.es> wrote:

> >>> "JC" == John C <john.ciolfi...@gmail.com> writes:
>
> Hi John,
>
>
> > Over the past few weeks, I've made progress on a matlab tree-sitter major
> > mode, matlab-ts-mode.el, in the matlab-ts-mode branch. Tree-sitter,
> > https://tree-sitter.github.io/tree-sitter/ is a major step forward from
> the
> > classic technique for building a major-mode in Emacs. With tree-sitter we
> > have accurate parse trees that form the basis of the major mode. The mode
> > is very close and independent from matlab-mode. The main item remaining
> is
> > integration with matlab-shell. Assuming things go well, I should be able
> to
> > merge matlab-ts-mode to the default branch. Therefore, if anyone wants to
> > check it out, please do so. To look at the matlab-ts-mode branch, clone
> the
> > repo, checkout that branch, and get
>
>
> I have seen your efforts, and I appreciate them very much. Now, the
> academic year has finally finished, and my workload is much reduced I
> have time for matlab-emacs.
>
>
> >    ~/.emacs.d/tree-sitter/libtree-sitter-matlab.so
>
> I have to confess my almost total ignorance about that subject. What
> essential new-or-different features does tree-sitter offer. I am asking
> this because otherwise testing will be a bit difficult.
>
>
>
> > Install ~/.emacs.d/tree-sitter/libtree-sitter-matlab.so by grabbing
> > matlab.so from   https://github.com/emacs-tree-sitter/tree-sitter-langs
> > latest release and renaming it to
> > ~/.emacs.d/tree-sitter/libtree-sitter-matlab.so. (.so on Linux, .dll on
> > Windows, .dylib on Mac)
>
> I am very confused. I install tree-sitter via the package system, so I
> have it installed
>
> /.emacs.d/elpa/tree-sitter-langs-20250716.1455
>
> Which is a different directory.
>
> Next I cannot find the /libtree-sitter-matlab.so file in
> https://github.com/emacs-tree-sitter/tree-sitter-langs
>
> So there is something elementary I fail to gasp.
>
>
>
> BTW, we should release, at least matlab 6.4 in ELPA, the MELPA version
> is now quite a bit ahead (compared to the  ELPA version)
>
>
> I will then also add a HOWTO-elpa.org file that describe, how to release
> a new ELPA release. MELPA is updated automatically on a daily base using
> the new pushes.
>
> Uwe
>
>
> > latest release and renaming it to
> > ~/.emacs.d/tree-sitter/libtree-sitter-matlab.so. (.so on Linux, .dll on
> > Windows, .dylib on Mac)
>
> > The matlab tree-sitter shared library we're using is from
> > https://github.com/acristoffers/tree-sitter-matlab and many thanks to
> > acristoffers for maintaining that and fixing issues.
>
> > _______________________________________________
> > Matlab-emacs-discuss mailing list
> > Matlab-emacs-discuss@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/matlab-emacs-discuss
>
>
> --
> I strongly condemn Hamas heinous despicable pogroms/atrocities on Israel
> I strongly condemn Putin's war of aggression against Ukraine.
> I support to deliver weapons to Ukraine's military.
> I support the EU and NATO membership of Ukraine.
>
>
_______________________________________________
Matlab-emacs-discuss mailing list
Matlab-emacs-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matlab-emacs-discuss

Reply via email to