all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Perl and SQL within the same buffer
@ 2022-10-03 14:18 Luca Ferrari
  2022-10-03 22:38 ` Emanuel Berg
  2023-01-20  9:08 ` Luca Ferrari
  0 siblings, 2 replies; 3+ messages in thread
From: Luca Ferrari @ 2022-10-03 14:18 UTC (permalink / raw)
  To: help-gnu-emacs

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.

Any suggestion?

Thanks,
Luca



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

* Re: Perl and SQL within the same buffer
  2022-10-03 14:18 Perl and SQL within the same buffer Luca Ferrari
@ 2022-10-03 22:38 ` Emanuel Berg
  2023-01-20  9:08 ` Luca Ferrari
  1 sibling, 0 replies; 3+ messages in thread
From: Emanuel Berg @ 2022-10-03 22:38 UTC (permalink / raw)
  To: help-gnu-emacs

Luca Ferrari wrote:

> 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.

I know there is some multimode ... mode in Emacs.

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Perl and SQL within the same buffer
  2022-10-03 14:18 Perl and SQL within the same buffer Luca Ferrari
  2022-10-03 22:38 ` Emanuel Berg
@ 2023-01-20  9:08 ` Luca Ferrari
  1 sibling, 0 replies; 3+ messages in thread
From: Luca Ferrari @ 2023-01-20  9:08 UTC (permalink / raw)
  To: help-gnu-emacs

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



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

end of thread, other threads:[~2023-01-20  9:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-03 14:18 Perl and SQL within the same buffer Luca Ferrari
2022-10-03 22:38 ` Emanuel Berg
2023-01-20  9:08 ` Luca Ferrari

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.