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

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

Re: Perl and SQL within the same buffer


From: Luca Ferrari
Subject: Re: Perl and SQL within the same buffer
Date: Fri, 20 Jan 2023 10:08:19 +0100

On Mon, Oct 3, 2022 at 4:18 PM Luca Ferrari <fluca1978@gmail.com> wrote:
>
> Hi all,
> when I edit PostgreSQL PL/Perl functions, I have a source code that
> has a basic SQL mode in the outer part of a function, and Perl in the
> inner part.
> Is there a way to instrument Perl to recognize and use both modes and
> syntax highlight? Something like what it happens when editing HTML and
> PHP inside it.
> An example of source code I edit:
>
> CREATE OR REPLACE FUNCTION
> pwc185.task2_plperl( text )
> RETURNS text
> AS $CODE$
> my ( $input ) = @_;
> my @output;
> my $counter = 4;
>
> for ( split( //, $input ) ) {
>     push @output, 'x'
>         and $counter--
>         and next if ( /[a-z0-9]/i ) and $counter > 0;
>     push @output, $_;
> }
>
> return join( '', @output );
> $CODE$
> LANGUAGE plperl;
>
>
>
> Everything outside the $CODE$ lines is SQL, everything insde is Perl.


Another idea that came into my mind is to trigger an alternative
editor buffer within the $CODE$ region, so that I can write Perl code
into a separated buffer that will be placed entirely into the main
buffer once I've done. This is somehow similar to what org-mode does.
Any suggestion on how to activate an embedded Perl editing buffer?

Thanks,
Luca



reply via email to

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