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

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

Re: Reversing lines chunks at a time


From: Xah
Subject: Re: Reversing lines chunks at a time
Date: Tue, 16 Sep 2008 13:24:40 -0700 (PDT)
User-agent: G2/1.0

On Sep 16, 2:07 am, Rupert Swarbrick <rswarbr...@gmail.com> wrote:
> Hi,
>
> I have the following sort of transformation that I have to do fairly
> often. For example, when writing LaTeX code, I might have a line in
> maths mode which looks like
>
>   G_*[n] = G_* \times \Delta^n
>
> (this defines the left hand side to be the Cartesian product of a G with
> a star and a capital delta with a superscript n, for those reading who
> aren't au fait with LaTeX). Anyway, suppose I wanted the product the
> other way round:
>
>   G_*[n] = \Delta^n \times G_*
>
> I'm using Auctex, which is pretty brilliant, but it's syntax table
> breaks at quite a few characters other than whitespace for word
> boundaries. I don't particularly want to change that: it seems
> reasonable, but it means that the transpose-* commands don't really help
> in this case: you end up mangling together bits of the various
> sections.
>
> Moreover, I sometimes don't bother, say, putting a space before the
> \times, which is still perfectly fine LaTeX, but it means that there
> would be no way for Auctex to sensibly see what to do.
>
> At the moment, I do a crazy jumping forward and back, killing and
> yanking, but I suspect there's a better way! Before I started hacking
> elisp, I was wondering whether there was already a neat way to solve
> this sort of problem that I didn't know about?

harven suggested a solution that uses syntax table.

i'd just write a simple elisp that process the current line or region.
This is such as good exercise if you haven't tried elisp for text
processing yet.

The functions listed in this page is probably all you need:
http://xahlee.org/emacs/elisp_common_functions.html

  Xah
∑ http://xahlee.org/

reply via email to

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