From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.help Subject: Re: Transposing words over middle words Date: Wed, 15 Nov 2017 15:35:58 -0800 Message-ID: <87h8tvi081.fsf@ericabrahamsen.net> References: <20171115155650067497545@bob.proulx.com> 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 1510789461 8709 195.159.176.226 (15 Nov 2017 23:44:21 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 15 Nov 2017 23:44:21 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (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 00:44:17 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 1eF7Lq-0001bT-CN for geh-help-gnu-emacs@m.gmane.org; Thu, 16 Nov 2017 00:44:14 +0100 Original-Received: from localhost ([::1]:38350 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eF7Lt-0002P1-41 for geh-help-gnu-emacs@m.gmane.org; Wed, 15 Nov 2017 18:44:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eF7LK-0002No-IX for help-gnu-emacs@gnu.org; Wed, 15 Nov 2017 18:43:43 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eF7LF-0005md-UN for help-gnu-emacs@gnu.org; Wed, 15 Nov 2017 18:43:42 -0500 Original-Received: from [195.159.176.226] (port=38069 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eF7LF-0005lR-N8 for help-gnu-emacs@gnu.org; Wed, 15 Nov 2017 18:43:37 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1eF7L3-0007R6-H0 for help-gnu-emacs@gnu.org; Thu, 16 Nov 2017 00:43:25 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 32 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:3ml0nrE9egFNnEIqEEhRI/29Xn8= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 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:114891 Archived-At: 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. 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