all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Loris Bennett" <loris.bennett@fu-berlin.de>
To: help-gnu-emacs@gnu.org
Subject: Re: Transposing words over middle words
Date: Thu, 16 Nov 2017 08:04:39 +0100	[thread overview]
Message-ID: <871skywvp4.fsf@hornfels.zedat.fu-berlin.de> (raw)
In-Reply-To: mailman.3764.1510787840.27995.help-gnu-emacs@gnu.org

Hi Bob,

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.
>
>   Jack and Jill went up the hill.
>
> With the point on the space after Jack the easiest way I know to
> transpose those words is to M-d to kill-word forward deleting the
> "and" leaving.
>
>   Jack and Jill went up the hill.
>       ^ point is here: M-d
>   Jack Jill went up the hill.
>
> Then M-t to transpose those words:
>
>   Jack Jill went up the hill.
>       ^ point is here: M-t
>   Jill Jack went up the hill.
>
> Then restore the "and" which is somewhat inelegant
>
>   Jill Jack went up the hill.
>       ^ point is here: C-b C-y
>   Jill and Jack went up the hill.
>
> Obviously I can use other brute force make the change.
>
>   Jack and Jill went up the hill.
>            ^ point is here: M-d
>   Jack and  went up the hill.
>            ^ point is here: M-b M-b
>   Jack and  went up the hill.
>   ^ point is here: C-y M-d M-f
>   Jill and  went up the hill.
>           ^ point is here: C-f C-y
>   Jill and Jack went up the hill.
>
> That or something similar is usually what I do.  This is one of those
> nuisance items I have always wished had a better way to accomplish but
> just always worked through it by brute force.  But transpose-words has
> always been taunting me that it almost does what I want with M-t but
> doesn't work in this situation.
>
> Is there a way to use M-t to transpose words skipping over middle
> words like it does for punctuation?  Perhaps there isn't a better way.

Assuming I'm at the end of the three words where the transposition
should take place, I usually do

   Jack and Jill went up the hill.
                ^ point is here: M-b
   Jack and Jill went up the hill.
            ^ point is here: M-t
   Jack Jill and went up the hill.
                ^ point is here: M-b M-b
   Jack Jill and went up the hill.
        ^ point is here: M-t M-t
   Jill and Jack went up the hill.

It seems moderately elegant to me, because it involves a fairly simple
ordering of only two different functions.  Having said that, I don't do
it that regularly and so still often screw it up.

Cheers,

Loris

-- 
This signature is currently under construction.


       reply	other threads:[~2017-11-16  7:04 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.3764.1510787840.27995.help-gnu-emacs@gnu.org>
2017-11-16  7:04 ` Loris Bennett [this message]
2017-11-16  8:41   ` Transposing words over middle words Joost Kremers
2017-11-16  8:47     ` Joost Kremers
2017-11-16 16:06   ` Eli Zaretskii
2017-11-16 22:26     ` Bob Proulx
2017-11-17  5:00       ` Yuri Khan
2017-11-17  5:08         ` Emanuel Berg
2017-11-17  8:55       ` Gian Uberto Lauri
2017-11-17  8:58         ` Gian Uberto Lauri
2017-11-17  9:10           ` Eli Zaretskii
2017-11-17  9:35             ` Gian Uberto Lauri
2017-11-17 16:03           ` Stefan Monnier
2017-11-17 16:19             ` Robert Pluim
2017-11-17 20:41               ` Marcin Borkowski
2017-11-17 16:42             ` Eli Zaretskii
2017-11-17 22:53               ` Stefan Monnier
2017-11-17 23:02                 ` Emanuel Berg
     [not found]             ` <mailman.3897.1510936953.27995.help-gnu-emacs@gnu.org>
2017-11-17 16:57               ` Rusi
2017-11-17 17:26                 ` Drew Adams
2017-11-17 18:05                 ` Eli Zaretskii
2017-11-17 22:55             ` Stefan Monnier
2017-11-17 23:09               ` Emanuel Berg
2017-11-21 17:21               ` Tomas Nordin
2017-11-22 18:18                 ` Arnaldo Mandel
2017-11-22 19:15                   ` Emanuel Berg
2017-11-22 21:33                 ` Stefan Monnier
2017-11-17 20:38         ` Marcin Borkowski
2017-11-18 17:11       ` Robert Thorpe
2017-11-16 21:55 ` Michael Piotrowski
2017-11-16 23:05 ` Joseph C. Fineman
2017-11-17  0:39   ` Emanuel Berg
2017-11-17  7:19   ` Eli Zaretskii
2017-11-18 20:29     ` clhs on other languages f.nikolakopoulos
2017-11-21  0:43       ` Robert Thorpe
     [not found]   ` <mailman.3847.1510879170.27995.help-gnu-emacs@gnu.org>
2017-11-17 23:34     ` Transposing words over middle words Joseph C. Fineman
2017-11-18  0:05       ` Emanuel Berg
     [not found]       ` <mailman.3932.1510963563.27995.help-gnu-emacs@gnu.org>
2017-11-18 22:55         ` Joseph C. Fineman
2017-11-18 23:57           ` Emanuel Berg
     [not found]   ` <mailman.3856.1510903218.27995.help-gnu-emacs@gnu.org>
2017-11-17 23:35     ` Joseph C. Fineman
2017-11-15 23:17 Bob Proulx
2017-11-15 23:35 ` Eric Abrahamsen
2017-11-16  6:03   ` Emanuel Berg
2017-11-16  0:04 ` Emanuel Berg
2017-11-18 17:07   ` ken
2017-11-18 19:34     ` Emanuel Berg
2017-11-19  2:06       ` ken
2017-11-19  2:15         ` Emanuel Berg
2017-11-19  2:34           ` John Mastro
2017-11-19  3:39             ` Emanuel Berg
2017-11-19  4:37               ` Drew Adams
2017-11-19  4:58                 ` Drew Adams
2017-11-19 14:56                 ` Emanuel Berg
2017-11-16 19:34 ` Charles A. Roelli
2017-11-16 19:41   ` Emanuel Berg
2017-11-16 20:09   ` Marcin Borkowski
2017-11-16 21:15     ` Emanuel Berg
2017-11-16 22:55       ` Bob Proulx
2017-11-16 23:02         ` Emanuel Berg
2017-11-16 21:18     ` Emanuel Berg
2017-11-16 22:43       ` Drew Adams
2017-11-16 22:59         ` Emanuel Berg
2017-11-17 16:21           ` Drew Adams
2017-11-17 20:52             ` Emanuel Berg
2017-11-16 22:28   ` Bob Proulx
     [not found] ` <mailman.3765.1510789425.27995.help-gnu-emacs@gnu.org>
2017-11-16 22:02   ` Michael Piotrowski
2017-11-16 23:00     ` Bob Proulx
2017-11-16 23:29     ` Eric Abrahamsen
2017-11-16 23:30       ` Eric Abrahamsen

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=871skywvp4.fsf@hornfels.zedat.fu-berlin.de \
    --to=loris.bennett@fu-berlin.de \
    --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.