bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#46889: cperl-mode: Fix indentation issues [PATCH]


From: Harald Jörg
Subject: bug#46889: cperl-mode: Fix indentation issues [PATCH]
Date: Thu, 04 Mar 2021 19:19:42 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Lars Ingebrigtsen <larsi@gnus.org> writes:

> [...]
>> Many thanks to Mattias Engdegård for his patient explanations how rx
>> expressions can be used without breaking compatibility to Emacs 26.1.
>> Until now, this allowed two ugly regexp literals to be eliminated.
>
> Funnily enough, that's the one thing I was going to ask you about with
> this patch.
>
> I'm not an experienced rx user -- at all -- but is this the best way to
> do this?
>
>> +(eval-and-compile
>> +  (defconst cperl--ws-rx
>> +    '(sequence (or space "\n"))
>
> It was the eval-and-compile that made me look at this bit...

I am not an experienced rx user at all, I only recently discovered it :)
I'm always happy when somebody else is looking over my changes.

The patch was a result of a my understanding of an off-the-lists dialog
between Mattias and me, where it is totally possible that I
misunderstood or misimplemented things.

What led me to eval-and-compile was that I want to "compose" Perl syntax
elements from those defined earlier - and I also want to write unit
tests for the rx form in cperl-mode-tests.el.

> [...]
>
>> +(defconst cperl-maybe-white-and-comment-rex
>> +  (rx-to-string `(group (eval cperl--ws*-rx)))
>
> I'm thinking of the rx `eval' things everywhere.  Wouldn't defining
> these rx expressions with `rx-define' be more straighforward, and then
> you'd have:

Yes, it would be.  The downside is that I'd have to abandon the plan to
move CPerl mode to ELPA and make it available for Emacs 26.1 and up.
Perl coders might want to try the new CPerl mode without having to build
Emacs 28 - and I want their feedback.

I'm ready to upgrade that stuff to `rx-define' when the typical Linux
distributions ship with an Emacs version supporting it!

>> +(defconst cperl-maybe-white-and-comment-rex
>> +  (rx-to-string `(group cperl--ws*-rx))
>
> (Similarly for basically all the rx `eval' bits.
>
> Now, rx expands the `eval' at compile time, I think, so it doesn't
> really make that much difference in practice, but it seems slightly
> clearer, perhaps?

Sure, I understand that.

By the way, the journey isn't over yet.  What I plan to do next is to
add support for popular Perl extensions which bring new syntax (also, a
new Perl version might sooner or later bring the same keywords, probably
with "better" syntax).  So I guess there will be a basic
compile-time-syntax, plus modifications at runtime when I know which
exact syntax applies to a buffer.
-- 
Cheers,
haj





reply via email to

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