From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Arnaldo Mandel Newsgroups: gmane.emacs.help Subject: Re: Transposing words over middle words Date: Wed, 22 Nov 2017 16:18:25 -0200 Message-ID: References: <871skywvp4.fsf@hornfels.zedat.fu-berlin.de> <83o9o2i4xz.fsf@gnu.org> <20171116152231522684703@bob.proulx.com> <23054.41962.848150.764633@mail.eng.it> <23054.42180.139282.82688@mail.eng.it> <873757zgwp.fsf@fliptop> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1511375499 11795 195.159.176.226 (22 Nov 2017 18:31:39 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 22 Nov 2017 18:31:39 +0000 (UTC) To: "help-gnu-emacs@gnu.org" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 22 19:31:36 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 1eHZo6-0002hK-Ii for geh-help-gnu-emacs@m.gmane.org; Wed, 22 Nov 2017 19:31:34 +0100 Original-Received: from localhost ([::1]:40841 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eHZoD-00065W-Nk for geh-help-gnu-emacs@m.gmane.org; Wed, 22 Nov 2017 13:31:41 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49658) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eHZc4-0003H6-Gu for help-gnu-emacs@gnu.org; Wed, 22 Nov 2017 13:19:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eHZc3-0001Sy-EJ for help-gnu-emacs@gnu.org; Wed, 22 Nov 2017 13:19:08 -0500 Original-Received: from mail-qt0-x22e.google.com ([2607:f8b0:400d:c0d::22e]:46461) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eHZc3-0001Ss-9e for help-gnu-emacs@gnu.org; Wed, 22 Nov 2017 13:19:07 -0500 Original-Received: by mail-qt0-x22e.google.com with SMTP id r39so24898452qtr.13 for ; Wed, 22 Nov 2017 10:19:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=CP6vqRoAQQl89Si2x+SZuopESeBzrNTKsJWuOIj8/Ps=; b=uTf7vMvUSAAUVWzy7KyFi41qm2MZx3cbFI9uNnDy7C+qk/4n8QggtS7K6zm6bw5mK9 JB0opVmUaS+eaRSQVRkZiXqgGW4F3ogR4n4kJ+mMWjOeT+1JgxtAKyYmMY+uAnC9DWL3 jEDXjppQpGw8DcpHzeqsKANS3KFePDc/nAwiw3gYqRjsrk2VofEzR2hi86uBrK85ETCF 8kzLksGqkgVWPUdnuxy/ANbItGcgQUSxBurcSPUCOqp+ibA/mTGD10wr5uF0kE/Vum45 0IpBTr78S4YbdK7Q5keT8V5PnhUax/rj9x1Mm5q7aA4X/iYRh6WlZ39fKBoY6arCudo2 SUFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=CP6vqRoAQQl89Si2x+SZuopESeBzrNTKsJWuOIj8/Ps=; b=j/MJuyU249UQvtQNfl2LwjkpfZlx/pH2NHOxqvxUaCaDFn+kJN6Y4O80WMkaajX1iC begKf4VwBVXsRKKrAPnDvBir9p7orqkiV8ZdHiAIs1HTVR/OS+DvQXbd7anRuAyFw8GW riQm4B/xuJbUQc6jxM/hDiN/hBiJjJOH5Ay1SBHNzt3tvO7DoAyBgXpAJga9fIW0dhWj /apkOxXZwu+T0coNVq/i9yc1DTjsJfWPOiSEGeNvf8LItfzwiTtRiES03lZY89yu2zTW GiLvd0E9L5G6gZ8uR2cUq5JVdR+KD8G721PmKLzWP6sjm2jM89Kj9tdZtqrnoV3OUrYM WvHw== X-Gm-Message-State: AJaThX7SPnRjP+wGGQ7RGkUq4vGfYmVXvapfVdwOP/FSzsJ+8GJuVS/I 8FHMBtOydnHSRdLJV+0ORS+Ph19aYiaZ18endI09ADPK X-Google-Smtp-Source: AGs4zMYZ/j1w/Czb7YJPAXBpDhZMyx2+pZZgf3uc/AxyySXJKyV0yXFUmPWd8oFXFw52HBJkTcSz0bzTX97n0cAEVOQ= X-Received: by 10.237.34.51 with SMTP id n48mr30762830qtc.300.1511374746149; Wed, 22 Nov 2017 10:19:06 -0800 (PST) Original-Received: by 10.12.184.156 with HTTP; Wed, 22 Nov 2017 10:18:25 -0800 (PST) In-Reply-To: <873757zgwp.fsf@fliptop> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::22e X-Mailman-Approved-At: Wed, 22 Nov 2017 13:30:45 -0500 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 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:115054 Archived-At: Here is my take on this function. It is slightly different from what came before in that the cursor should be in the middle word, and it stays there. (defun transpose-over-word () "Transposes the two words adjacent to the one containing point." (interactive) (let ((p (point))) (forward-word 1) (setq p (- (point) p)) (backward-word 1) (transpose-words 2) (backward-word 2) (transpose-words 1) (backward-char p))) On Tue, Nov 21, 2017 at 3:21 PM, Tomas Nordin wrote: > > > Than again, maybe M-t should work like `C-0 M-t` whenever the region > > is active so you don't even need the C-u at all. > > Here is an advice to make that happen, respecting possible prefixes. > > (defun tn-transpose-dwim-advice (transpose-subr &rest args) > (if (and (use-region-p) (= (cadr args) 1)) > ;; MOVER dwim SPECIAL > (apply transpose-subr (car args) 0 (cddr args)) > (apply transpose-subr args))) > > (advice-add 'transpose-subr :around #'tn-transpose-dwim-advice) > > ;;; remove the hack with this: > ;; (advice-remove 'transpose-subr #'tn-transpose-dwim-advice) > >