all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* perl-ts-mode available?
@ 2023-10-05  2:50 hw
  2023-10-06  2:40 ` Danny Freeman
  2023-10-07 18:10 ` Jens Schmidt via Users list for the GNU Emacs text editor
  0 siblings, 2 replies; 8+ messages in thread
From: hw @ 2023-10-05  2:50 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

is a treesitter mode for perl available (somewhere)?  Or is one about
to be created?

I'd venture to write one, but looking at [1] tells me that I don't
have a clue how to even begin such an endeavor.


[1]: /usr/local/share/emacs/30.0.50/lisp/progmodes/c-ts-mode.el.gz




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: perl-ts-mode available?
  2023-10-05  2:50 perl-ts-mode available? hw
@ 2023-10-06  2:40 ` Danny Freeman
  2023-10-06  4:52   ` Corwin Brust
  2023-10-06 20:44   ` hw
  2023-10-07 18:10 ` Jens Schmidt via Users list for the GNU Emacs text editor
  1 sibling, 2 replies; 8+ messages in thread
From: Danny Freeman @ 2023-10-06  2:40 UTC (permalink / raw)
  To: hw; +Cc: help-gnu-emacs


hw <hw@adminart.net> writes:

> Hi,
>
> is a treesitter mode for perl available (somewhere)?  Or is one about
> to be created?

I don't think so.

> I'd venture to write one, but looking at [1] tells me that I don't
> have a clue how to even begin such an endeavor.
>
>
> [1]: /usr/local/share/emacs/30.0.50/lisp/progmodes/c-ts-mode.el.gz

If you are interested in learning how, you could take a look at this
article, which walks you through creating a simple html-ts-mode:
https://www.masteringemacs.org/article/lets-write-a-treesitter-major-mode

Many of the things written there will carry over to writing a
perl-ts-mode.

The only other thing you need to get started with is a grammar:
https://github.com/tree-sitter-perl/tree-sitter-perl

There is also some info in the Emacs manual under the title
"(elisp)Parsing Program Source"
-- 
Danny Freeman



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: perl-ts-mode available?
  2023-10-06  2:40 ` Danny Freeman
@ 2023-10-06  4:52   ` Corwin Brust
  2023-10-06 20:47     ` hw
  2023-10-06 20:44   ` hw
  1 sibling, 1 reply; 8+ messages in thread
From: Corwin Brust @ 2023-10-06  4:52 UTC (permalink / raw)
  To: danny; +Cc: hw, help-gnu-emacs

On Thu, Oct 5, 2023 at 9:40 PM Danny Freeman <danny@dfreeman.email> wrote:
>
> The only other thing you need to get started with is a grammar:
> https://github.com/tree-sitter-perl/tree-sitter-perl
>
> There is also some info in the Emacs manual under the title
> "(elisp)Parsing Program Source"

This is the perl tree-sitter grammar for which I build Windows
binaries (DLLs).  I believe there are others however, although I
haven't looked into treesitter enough to be able to understand the
whys and wherefores technically, I can say that the (just barely) most
significant contributor to this grammar project (Paul) is also a
member of the three-person Perl Steering Council which oversees Perl
development.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: perl-ts-mode available?
  2023-10-06  2:40 ` Danny Freeman
  2023-10-06  4:52   ` Corwin Brust
@ 2023-10-06 20:44   ` hw
  2023-10-07  5:51     ` Edgar Quiroz via Users list for the GNU Emacs text editor
  2023-10-11  1:59     ` Danny Freeman
  1 sibling, 2 replies; 8+ messages in thread
From: hw @ 2023-10-06 20:44 UTC (permalink / raw)
  To: help-gnu-emacs

On Thu, 2023-10-05 at 22:40 -0400, Danny Freeman wrote:
> hw <hw@adminart.net> writes:
> 
> > Hi,
> > 
> > is a treesitter mode for perl available (somewhere)?  Or is one about
> > to be created?
> 
> I don't think so.
> 
> > I'd venture to write one, but looking at [1] tells me that I don't
> > have a clue how to even begin such an endeavor.
> > 
> > 
> > [1]: /usr/local/share/emacs/30.0.50/lisp/progmodes/c-ts-mode.el.gz
> 
> If you are interested in learning how, you could take a look at this
> article, which walks you through creating a simple html-ts-mode:
> https://www.masteringemacs.org/article/lets-write-a-treesitter-major-mode

It's advertising some package the author's working on too much, and
perl is probably way more complex than html.

> Many of the things written there will carry over to writing a
> perl-ts-mode.

Maybe, maybe not.

> The only other thing you need to get started with is a grammar:
> https://github.com/tree-sitter-perl/tree-sitter-perl
> 
> There is also some info in the Emacs manual under the title
> "(elisp)Parsing Program Source"

I thought treesitter would do the parsing.  And how do I know if I
have a working treesitter module for perl when I don't even have a
mode to use it with?




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: perl-ts-mode available?
  2023-10-06  4:52   ` Corwin Brust
@ 2023-10-06 20:47     ` hw
  0 siblings, 0 replies; 8+ messages in thread
From: hw @ 2023-10-06 20:47 UTC (permalink / raw)
  To: help-gnu-emacs

AOn Thu, 2023-10-05 at 23:52 -0500, Corwin Brust wrote:
> On Thu, Oct 5, 2023 at 9:40 PM Danny Freeman <danny@dfreeman.email> wrote:
> > 
> > The only other thing you need to get started with is a grammar:
> > https://github.com/tree-sitter-perl/tree-sitter-perl
> > 
> > There is also some info in the Emacs manual under the title
> > "(elisp)Parsing Program Source"
> 
> This is the perl tree-sitter grammar for which I build Windows
> binaries (DLLs).  I believe there are others however, although I
> haven't looked into treesitter enough to be able to understand the
> whys and wherefores technically, I can say that the (just barely) most
> significant contributor to this grammar project (Paul) is also a
> member of the three-person Perl Steering Council which oversees Perl
> development.
> 

Are you saying it's not working?  And what's the point of having this
when there's no mode to use it with?




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: perl-ts-mode available?
  2023-10-06 20:44   ` hw
@ 2023-10-07  5:51     ` Edgar Quiroz via Users list for the GNU Emacs text editor
  2023-10-11  1:59     ` Danny Freeman
  1 sibling, 0 replies; 8+ messages in thread
From: Edgar Quiroz via Users list for the GNU Emacs text editor @ 2023-10-07  5:51 UTC (permalink / raw)
  To: help-gnu-emacs

hw <hw@adminart.net> writes:
> On Thu, 2023-10-05 at 22:40 -0400, Danny Freeman wrote:
>> The only other thing you need to get started with is a grammar:
>> https://github.com/tree-sitter-perl/tree-sitter-perl
>> 
>> There is also some info in the Emacs manual under the title
>> "(elisp)Parsing Program Source"
>
> I thought treesitter would do the parsing.  And how do I know if I
> have a working treesitter module for perl when I don't even have a
> mode to use it with?

If the compiled grammar is available, you can go into any buffer
(regardless if you have a mode or not) and run M-x
treesit-explore-mode. It will prompt you for the name of language and
will open a new buffer with the abstract syntax tree for the buffer
(the result of the parsing).

Last time I tried to dabble into Treesitter, I found go-ts-mode
very helpful. It is a non-trivial yet not too complex example of a tree
sitter mode.




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: perl-ts-mode available?
  2023-10-05  2:50 perl-ts-mode available? hw
  2023-10-06  2:40 ` Danny Freeman
@ 2023-10-07 18:10 ` Jens Schmidt via Users list for the GNU Emacs text editor
  1 sibling, 0 replies; 8+ messages in thread
From: Jens Schmidt via Users list for the GNU Emacs text editor @ 2023-10-07 18:10 UTC (permalink / raw)
  To: help-gnu-emacs

On 2023-10-05  04:50, hw wrote:
> Hi,
> 
> is a treesitter mode for perl available (somewhere)?  Or is one about
> to be created?
>
> I'd venture to write one, but looking at [1] tells me that I don't
> have a clue how to even begin such an endeavor.
> 
> 
> [1]: /usr/local/share/emacs/30.0.50/lisp/progmodes/c-ts-mode.el.gz

Harald Jörg, the (almost?) maintainer of cperl-mode has started one
on

  https://github.com/HaraldJoerg/emacs-perl-ts-mode

but it's very basic so far (as he notes himself!) and does syntax
highlighting only, as far as I can see.  Harald also comments on
the treesitter approach for Perl at the end of this post, btw:

  https://yhetil.org/emacs-bugs/878r8wa67e.fsf@oook.m.uunet.de/

Plus, as others on this thread have already mentioned, there is no
fully operable treesitter grammar for Perl yet.  The one on

  https://github.com/tree-sitter-perl/tree-sitter-perl

seems to be the best bet so far.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: perl-ts-mode available?
  2023-10-06 20:44   ` hw
  2023-10-07  5:51     ` Edgar Quiroz via Users list for the GNU Emacs text editor
@ 2023-10-11  1:59     ` Danny Freeman
  1 sibling, 0 replies; 8+ messages in thread
From: Danny Freeman @ 2023-10-11  1:59 UTC (permalink / raw)
  To: hw; +Cc: help-gnu-emacs


hw <hw@adminart.net> writes:

>> If you are interested in learning how, you could take a look at this
>> article, which walks you through creating a simple html-ts-mode:
>> https://www.masteringemacs.org/article/lets-write-a-treesitter-major-mode
>
> It's advertising some package the author's working on too much, and
> perl is probably way more complex than html.

It's a good article to get your feet wet with tree-sitter. Take it or
leave it, but there isn't much content out there to learn from other
than reading tree-sitter modes that already exist, or reading the Emacs
manual. The concepts for syntax highlighting and indentation with
tree-sitter will carry over from html to perl easy enough once you get
comfortable with writing tree-sitter queries.
 
>> There is also some info in the Emacs manual under the title
>> "(elisp)Parsing Program Source"
>
> I thought treesitter would do the parsing.  And how do I know if I
> have a working treesitter module for perl when I don't even have a
> mode to use it with?

That section in the manual explains how to use tree-sitter. It does do
the parsing. The name of that part of the manual is very clear imo.

-- 
Danny Freeman



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-10-11  1:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-05  2:50 perl-ts-mode available? hw
2023-10-06  2:40 ` Danny Freeman
2023-10-06  4:52   ` Corwin Brust
2023-10-06 20:47     ` hw
2023-10-06 20:44   ` hw
2023-10-07  5:51     ` Edgar Quiroz via Users list for the GNU Emacs text editor
2023-10-11  1:59     ` Danny Freeman
2023-10-07 18:10 ` Jens Schmidt via Users list for the GNU Emacs text editor

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.