unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Perl "plugin" for Emacs
@ 2011-09-23 21:22 paxxus
  2011-09-23 22:01 ` Nikolai Weibull
  0 siblings, 1 reply; 4+ messages in thread
From: paxxus @ 2011-09-23 21:22 UTC (permalink / raw)
  To: Help-gnu-emacs


Hi,

I'd like to be able to perform some text formatting in Perl as that will be
way faster for me than having to learn Lisp. Here's what I'm after:

1. Select a region in Emacs.
2. Press a key.
3. The selected text is passed to a Perl script.
4. Output from Perl script replaces the selected region.

Is this possible and what exactly would I have to put in my .emacs if, let's
say, the key I want to bind is F5 and the Perl script is located at
~/Emacs/format.pl

Thanks!

-- 
View this message in context: http://old.nabble.com/Perl-%22plugin%22-for-Emacs-tp32503889p32503889.html
Sent from the Emacs - Help mailing list archive at Nabble.com.




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

* Re: Perl "plugin" for Emacs
  2011-09-23 21:22 Perl "plugin" for Emacs paxxus
@ 2011-09-23 22:01 ` Nikolai Weibull
  2011-09-23 22:31   ` Paxxus
  2011-09-23 23:08   ` Paxxus
  0 siblings, 2 replies; 4+ messages in thread
From: Nikolai Weibull @ 2011-09-23 22:01 UTC (permalink / raw)
  To: paxxus; +Cc: Help-gnu-emacs

On Fri, Sep 23, 2011 at 23:22, paxxus <paxxus@hotmail.com> wrote:

> I'd like to be able to perform some text formatting in Perl as that will be
> way faster for me than having to learn Lisp. Here's what I'm after:
>
> 1. Select a region in Emacs.
> 2. Press a key.
> 3. The selected text is passed to a Perl script.
> 4. Output from Perl script replaces the selected region.
>
> Is this possible and what exactly would I have to put in my .emacs if, let's
> say, the key I want to bind is F5 and the Perl script is located at
> ~/Emacs/format.pl

Look up the function shell-command-on-region.



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

* RE: Perl "plugin" for Emacs
  2011-09-23 22:01 ` Nikolai Weibull
@ 2011-09-23 22:31   ` Paxxus
  2011-09-23 23:08   ` Paxxus
  1 sibling, 0 replies; 4+ messages in thread
From: Paxxus @ 2011-09-23 22:31 UTC (permalink / raw)
  To: now; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1101 bytes --]





> Date: Sat, 24 Sep 2011 00:01:57 +0200
> Subject: Re: Perl "plugin" for Emacs
> From: now@bitwi.se
> To: paxxus@hotmail.com
> CC: Help-gnu-emacs@gnu.org
> 
> On Fri, Sep 23, 2011 at 23:22, paxxus <paxxus@hotmail.com> wrote:
> 
> > I'd like to be able to perform some text formatting in Perl as that will be
> > way faster for me than having to learn Lisp. Here's what I'm after:
> >
> > 1. Select a region in Emacs.
> > 2. Press a key.
> > 3. The selected text is passed to a Perl script.
> > 4. Output from Perl script replaces the selected region.
> >
> > Is this possible and what exactly would I have to put in my .emacs if, let's
> > say, the key I want to bind is F5 and the Perl script is located at
> > ~/Emacs/format.pl
> 
> Look up the function shell-command-on-region.

Thanks! I put the following code in my .emacs (using cksum as the command for testing):

(global-set-key (kbd "<f5>") '(shell-command-on-region "cksum"))

But I get the following error when I press F5:

Wrong type argument: commandp, (shell-command-on-region "cksum")

 		 	   		  

[-- Attachment #2: Type: text/html, Size: 1541 bytes --]

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

* RE: Perl "plugin" for Emacs
  2011-09-23 22:01 ` Nikolai Weibull
  2011-09-23 22:31   ` Paxxus
@ 2011-09-23 23:08   ` Paxxus
  1 sibling, 0 replies; 4+ messages in thread
From: Paxxus @ 2011-09-23 23:08 UTC (permalink / raw)
  To: now; +Cc: help-gnu-emacs



> Date: Sat, 24 Sep 2011 00:01:57 +0200
> Subject: Re: Perl "plugin" for Emacs
> From: now@bitwi.se
> To: paxxus@hotmail.com
> CC: Help-gnu-emacs@gnu.org
>
> On Fri, Sep 23, 2011 at 23:22, paxxus <paxxus@hotmail.com> wrote:
>
> > I'd like to be able to perform some text formatting in Perl as that will be
> > way faster for me than having to learn Lisp. Here's what I'm after:
> >
> > 1. Select a region in Emacs.
> > 2. Press a key.
> > 3. The selected text is passed to a Perl script.
> > 4. Output from Perl script replaces the selected region.
> >
> > Is this possible and what exactly would I have to put in my .emacs if, let's
> > say, the key I want to bind is F5 and the Perl script is located at
> > ~/Emacs/format.pl
>
> Look up the function shell-command-on-region.

I figured out how to do it. I put this command into my .emacs:

(global-set-key
  (kbd "<f5>")
  ( lambda () (interactive)
    ( shell-command-on-region
      (region-beginning) (region-end) "perl ~/Emacs/format.pl" nil t
    )
  )
)

Thanks for the help!

 		 	   		  


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

end of thread, other threads:[~2011-09-23 23:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-23 21:22 Perl "plugin" for Emacs paxxus
2011-09-23 22:01 ` Nikolai Weibull
2011-09-23 22:31   ` Paxxus
2011-09-23 23:08   ` Paxxus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).