all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: rgb <rbielaws@i1.net>
To: help-gnu-emacs@gnu.org
Subject: Re: Reversing lines chunks at a time
Date: Wed, 17 Sep 2008 10:14:35 -0700 (PDT)	[thread overview]
Message-ID: <4534ba64-6bd9-4256-92ac-5359bd3296b8@m73g2000hsh.googlegroups.com> (raw)
In-Reply-To: gant1g$od6$1@news.albasani.net

On Sep 16, 4: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?
>
> Many thanks,
>
> Rupert
>
>  application_pgp-signature_part
> < 1KViewDownload

See
http://www.emacswiki.org/cgi-bin/wiki/AnchoredTranspose

It should probably be called swap-regions since that's what it does.

There are several ways to do what you want using it.
Personally I have it mapped to C-x t

In your example you could select the text
G_* \times \Delta^n
C-x t
select    \times
C-x t
Poof it's done

If you prefer you could select
\Delta^n
C-x t
G_*
C-x t
Then it's done too.
The order you select things in isn't important.
It works with secondary selection too.

If I remember correctly by default it ignores white space around your
selection.  IOW you may need to C-u C-x M-t to have it swap correctly
(stop ignoring whitespace).
But if you find yourself needing the C-u behavior you can make this
change.

  (interactive `(,(region-beginning) ,(region-end)
                 ,current-prefix-arg
to
  (interactive `(,(region-beginning) ,(region-end)
                 ,(not current-prefix-arg)

Hmm, maybe the routine needs a cust flag....


  parent reply	other threads:[~2008-09-17 17:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-16  9:07 Reversing lines chunks at a time Rupert Swarbrick
2008-09-16 10:23 ` harven
2008-09-17 18:54   ` Rupert Swarbrick
2008-09-16 20:24 ` Xah
2008-09-17 18:58   ` Rupert Swarbrick
2008-09-17 21:18     ` Xah
2008-09-17 17:14 ` rgb [this message]
2008-09-17 18:49   ` Rupert Swarbrick

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4534ba64-6bd9-4256-92ac-5359bd3296b8@m73g2000hsh.googlegroups.com \
    --to=rbielaws@i1.net \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.