From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "Loris Bennett" Newsgroups: gmane.emacs.help Subject: Re: Transposing words over middle words Date: Thu, 16 Nov 2017 08:04:39 +0100 Organization: Freie Universitaet Berlin Message-ID: <871skywvp4.fsf@hornfels.zedat.fu-berlin.de> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1510815935 22109 195.159.176.226 (16 Nov 2017 07:05:35 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 16 Nov 2017 07:05:35 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Nov 16 08:05:28 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eFEEp-0005E3-Oz for geh-help-gnu-emacs@m.gmane.org; Thu, 16 Nov 2017 08:05:27 +0100 Original-Received: from localhost ([::1]:39333 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eFEEu-0005fy-2c for geh-help-gnu-emacs@m.gmane.org; Thu, 16 Nov 2017 02:05:32 -0500 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 85 Original-X-Trace: news.uni-berlin.de aiCY2Z5+7cAK4WWIVG5MYgW8XIs8xaJh5sugBxJ8zFMYcs Cancel-Lock: sha1:m3jAyViuW47is0q/znqYaJ6aI/I= Original-Xref: usenet.stanford.edu gnu.emacs.help:220786 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:114896 Archived-At: Hi Bob, Bob Proulx 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.