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

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

Re: Transposing words over middle words


From: Eric Abrahamsen
Subject: Re: Transposing words over middle words
Date: Wed, 15 Nov 2017 15:35:58 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Bob Proulx <bob@proulx.com> writes:

> TL;DR: How can I transpose words jumping over middle words?
>
> Of course we all know about C-t transpose-chars.  And there is the
> corresponding M-t transpose-words too.  Here is the documentation.
>
>        ‘M-t’ transposes the word before point with the word after point
>     (‘transpose-words’).  It moves point forward over a word, dragging the
>     word preceding or containing point forward as well.  The punctuation
>     characters between the words do not move.  For example, ‘FOO, BAR’
>     transposes into ‘BAR, FOO’ rather than ‘BAR FOO,’.
>
> When modifying a list of comma separated s strings this works great.
> But often I find myself wanting to transpose words in an "and"
> structure.

I use Emacs more for prose composition than I do for coding, and I've
often wanted this. Over the years I've written a bunch of small
functions for making it easier to write prose (slurping spaces before
punctuation after deleting a word, etc), but eventually have discarded
most of them in favor of just hitting a few extra keys. I could never
get the DWIM behavior DWIM-ish enough, and it was more of a headache
watching for and correcting the mis-fires than it was just banging more
keys.

Anyway, the function you want is pretty easy to write. As I recall, I
dropped it because I couldn't decide what to do about multiple
invocations. `transpose-words' is actually "drag word forward". What
should this function do if you call it multiple times in a row?

Eric




reply via email to

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