[Gllug] Performing a function on a region in emacs

Peter Corlett abuse at cabal.org.uk
Wed Sep 3 17:21:12 UTC 2008


On Wed, Sep 03, 2008 at 05:00:28PM +0100, Matthew King wrote:
[...]
> After a minute of searching around I just did the change manually using a
> separate file and perl, but I'm sure there's a way to do it natively or by
> piping through something externally.

That's how I'd do it. Note the existence of perl -i to do an in-place edit.
"perl -pi.bak -e 's/ ... /' file1 file2" is a fairly standard idiom.

> So - how do you process a region in emacs with an external command
> and/or some lisp (I don't really know lisp at all).

M-x shell-command-on-region, also bound to M-|. Prefix it with C-u or M-1 to
tell it to replace the region with the command's output, otherwise it'll
just go into another buffer.

-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list