[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Enhancing cperl-mode

From: Harald Jörg
Subject: Re: Enhancing cperl-mode
Date: Mon, 19 Jun 2023 16:41:22 +0000

Corwin Brust <corwin@bru.st> writes:

> Wonderful seeing this.. we are clearly thinking along very similar
> lines! --more--


> I'd be very happy to defer to your efforts; if you would like to take
> the lead on this I'm happy to help all I can, like please absorb what
> you will from my version.  As you can see, I've not even bothered to
> fix trivial things like line length in my rush to see the new keywords
> "light up" :)

I'll then happily take your patch as an additional check list that I
haven't missed anything!

> [...]
>> Also, I've been dreaming of adding support for Perl's syntax
>> extensions as minor modes which can be activated on top of perl-mode and
>> cperl-mode.
> I have the same theory/vision.
> I have long term vision/hopes, and too, I've also been of adding
> support for syntax.pm keywords via minor-modes, probably via some new
> hooks?  I have the idea of a "amada" of cperl-syntax-FOO minor modes
> mirroring the CPAN modules using syntax.pm.

...or more generally, stuff like Moose where the "keywords" (has,
extends etc) technically are imported subroutines, but they "feel" like

> I hooks call while
> setting up font-locking could be a feasible way, but I'm still trying
> to parse the parsing (sorry if I crashed ur tokenizer there).  More
> specifically, I'm not clear on the interaction/use subrs vs calling
> hooks to add/tweak font-locking and what all, exactly, is happening at
> compile time.  (Is this effectively impossible? Will we wreck
> performance?)
> I do know I haven't found an incantation to make updating the
> font-lock setup "live"; I have to re-launch Emacs as I go to test
> these changes.

For font-locking, there are two mechanisms which can be used by minor
mode hooks: First, there's font-lock-add-keyword /
font-lock-remove-keyword which works for all, well, "keywords" (which
most of the syntax extensions provide).  Second, the MATCHER in
font-lock can be a function (as already used in the ominous
cperl-fontify-update) which can work on variables which in turn can be
modified by minor modes, or even hooked into.  So yes, it can be done
"live", but it needs preparation.  I made a proof-of-concept, but the
implementation is crap.  It still hangs around at
https://github.com/HaraldJoerg/cperl-mode/, but I more or less stopped
working on it when I started to contribute to the savannah repository.

Open a file which uses Moose, or Zydeco, or Function::Parameters, or any
of the keyword sets it understands... and it automatically highlights
the extensions.  Instead of minor modes it uses commands
cperl-activate-keyword-set, cperl-deactivate-keyword-set, and
cperl-reset-keyword-sets.  This is a bad idea, but back then I didn't
understand minor modes.

I'm a bit stuck with indentation, where the code in cperl-mode is
messy.  Keywords that are followed by a { code block } sometimes need a
semicolon, and sometimes they don't, and cperl-mode needs to understand
this in order to decide whether the next line is a continuation line or
a new statement.

> Excited to hear the extent you'd like to work on this!

I am interested to work on this, only have been distracted a lot by
non-elisp projects.  The upcoming Perl 5.38 made me re-activate my elisp
activities.  I'm also interested to get cperl-mode published via ELPA,
so that it can be used once Perl 5.38 is out.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]