Another emacs major mode for perl
aa34c2a15aec — pranshu@fedora default tip 19 days ago
Bump version
Fixed up lots of signature syntax highlighting

heads

tip
browse log

clone

read-only
https://hg.sr.ht/~pranshu/perl-ts-mode
read/write
ssh://hg@hg.sr.ht/~pranshu/perl-ts-mode

#Report bug or contribute

Please send an email to ~pranshu/perl-ts-mode@lists.sr.ht with bug or patch. You can view archives of the mailing list here.

#Info

This is a major mode for perl, designed to be similar to cperl-mode. The major difference is that this mode uses a parser(done by treesitter) to provide it's features, instead of it based all on regexps.

If you just, want to see how the colour looks like, go to https://p.bauherren.ovh/stuff/test.pl.html .

#Prerequisets

Just execute the following code and you should be ready to go.

(add-to-list 'treesit-language-source-alist
	     '(perl . ("https://github.com/tree-sitter-perl/tree-sitter-perl" "release")))
(add-to-list 'treesit-language-source-alist
	     '(pod . ("https://github.com/tree-sitter-perl/tree-sitter-pod" "release")))
(treesit-install-language-grammar 'perl)
(treesit-install-language-grammar 'pod)

#Usage

Should be pretty intutive, you use M-e and M-a to navigate around PODs. This package also provides proper sexp navigation for perl. In the following code:

#Sexp navigation

my $r = join '-', @arr + 2 - 1;

The sexps (circle bracket), and sentence[square bracker] would be:

[((my) ($r)) = ((join) '-', (((@arr) + (2)) - (1)));]

Commands like C-M-b, C-M-f, M-e, M-a will reflect on this. It makes moving around seem more fun and cool.

#Imenu

The imenu settings should work as expected, similar to how cperl-mode does it.

#Outline

The outline-mode (outline-minior-mode) is top notch, better than cperl.

(setq outline-minor-mode-cycle t)

#Contributing

There are 3 ways to make this mode better in order of preference:

  1. Contribute to the perl treesitter grammer and try to speed it up
  2. Contribute to perl-ts-mode.el
  3. Contribute to treesit.el in emasc core

#Warning

As of 2025-01-06, the treesit ranges are unstable. Also being worked on.

Due to some major perfomance issues with the grammer, it is not advisable to use this if you will be working on large files. As of 2025-01-21, these are being worked on rapidly.

#TODO

  • Set list in perl-ts-thing-settings.
  • Try do injection for code markup inside pod.