From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: charles@aurox.ch (Charles A. Roelli) Newsgroups: gmane.emacs.bugs Subject: bug#30343: make transpose-regions interactive Date: Sun, 04 Feb 2018 10:45:45 +0100 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1517736990 23654 195.159.176.226 (4 Feb 2018 09:36:30 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 4 Feb 2018 09:36:30 +0000 (UTC) To: 30343@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Feb 04 10:36:26 2018 Return-path: Envelope-to: geb-bug-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 1eiGiW-0004jg-8C for geb-bug-gnu-emacs@m.gmane.org; Sun, 04 Feb 2018 10:36:08 +0100 Original-Received: from localhost ([::1]:54713 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiGkV-0007Ss-Ld for geb-bug-gnu-emacs@m.gmane.org; Sun, 04 Feb 2018 04:38:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60734) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiGkP-0007SH-NO for bug-gnu-emacs@gnu.org; Sun, 04 Feb 2018 04:38:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiGkM-0001zY-Eb for bug-gnu-emacs@gnu.org; Sun, 04 Feb 2018 04:38:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:48298) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eiGkM-0001zT-Ay for bug-gnu-emacs@gnu.org; Sun, 04 Feb 2018 04:38:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eiGkL-0005N6-V8 for bug-gnu-emacs@gnu.org; Sun, 04 Feb 2018 04:38:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: charles@aurox.ch (Charles A. Roelli) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 04 Feb 2018 09:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30343 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 30343-submit@debbugs.gnu.org id=B30343.151773705520617 (code B ref 30343); Sun, 04 Feb 2018 09:38:01 +0000 Original-Received: (at 30343) by debbugs.gnu.org; 4 Feb 2018 09:37:35 +0000 Original-Received: from localhost ([127.0.0.1]:56195 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eiGjv-0005MS-GF for submit@debbugs.gnu.org; Sun, 04 Feb 2018 04:37:35 -0500 Original-Received: from sinyavsky.aurox.ch ([37.35.109.145]:40000) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eiGjt-0005MD-6B for 30343@debbugs.gnu.org; Sun, 04 Feb 2018 04:37:34 -0500 Original-Received: from sinyavsky.aurox.ch (sinyavsky.aurox.ch [127.0.0.1]) by sinyavsky.aurox.ch (Postfix) with ESMTP id CA31322678 for <30343@debbugs.gnu.org>; Sun, 4 Feb 2018 09:37:31 +0000 (UTC) Authentication-Results: sinyavsky.aurox.ch (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=aurox.ch DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aurox.ch; h= references:subject:subject:in-reply-to:to:from:from:message-id :date:date; s=dkim; t=1517737050; x=1518601051; bh=2h8192pUY5RV3 WuEz73shpIbQhACnWVB/MbuzFCSq7c=; b=XWxu09PcxinnQIu8wq34dFQlbvKLR 3VENNukhJr1yYq2Y8gRrzPCaws0PmiVwVq1p7zbRr+AUlcBcchtMib0hqEY5h7fp DfE9+QGHjaLng5TMUbX7Rj99Ofs+PfENHp+PRRC9tsskWHKVEgPCoJQSchocZxPm 3ism+3fUMBTYtQ= X-Virus-Scanned: Debian amavisd-new at test.virtualizor.com Original-Received: from sinyavsky.aurox.ch ([127.0.0.1]) by sinyavsky.aurox.ch (sinyavsky.aurox.ch [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id YGjhGqSm3I2i for <30343@debbugs.gnu.org>; Sun, 4 Feb 2018 09:37:30 +0000 (UTC) Original-Received: from gray (125.85.192.178.dynamic.wline.res.cust.swisscom.ch [178.192.85.125]) by sinyavsky.aurox.ch (Postfix) with ESMTPSA id B1C0B2264C for <30343@debbugs.gnu.org>; Sun, 4 Feb 2018 09:37:30 +0000 (UTC) In-reply-to: (charles@aurox.ch) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:142878 Archived-At: What follows is a patch to make transpose-regions interactive. I also noticed that transpose-sentences/paragraphs are not documented, so I'll add those in another commit. >From 8468059f55ea459dc56c3dae6c6667950c6767d2 Mon Sep 17 00:00:00 2001 From: "Charles A. Roelli" Date: Sun, 4 Feb 2018 10:41:00 +0100 Subject: [PATCH] Make transpose-regions interactive (Bug#30343) * doc/emacs/fixit.texi (Transpose): Mention and explain the new command. * editfns.c (Ftranspose_regions): Add an interactive calling specification, and add documentation for it. --- doc/emacs/fixit.texi | 12 +++++++++++- src/editfns.c | 11 +++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/doc/emacs/fixit.texi b/doc/emacs/fixit.texi index ced1ef9..a35ef6b 100644 --- a/doc/emacs/fixit.texi +++ b/doc/emacs/fixit.texi @@ -146,6 +146,8 @@ Transpose Transpose two balanced expressions (@code{transpose-sexps}). @item C-x C-t Transpose two lines (@code{transpose-lines}). +@item M-x transpose-regions +Transpose two regions. @end table @kindex C-t @@ -183,7 +185,7 @@ Transpose (@code{transpose-lines}) exchanges lines. They work like @kbd{M-t} except as regards what units of text they transpose. - A numeric argument to a transpose command serves as a repeat count: it + A numeric argument to most transpose commands serves as a repeat count: it tells the transpose command to move the character (word, expression, line) before or containing point across several other characters (words, expressions, lines). For example, @kbd{C-u 3 C-t} moves the character before @@ -198,6 +200,14 @@ Transpose transpose the character (word, expression, line) ending after point with the one ending after the mark. +@findex transpose-regions + @kbd{M-x transpose-regions} transposes the text between point and +mark with the text between the first two elements of the mark ring. +Unlike the other transpose commands, it does not behave differently +when given a prefix argument. This command is best used for +transposing multiple units of text (words, sentences, paragraphs) in +one go. + @node Fixing Case @section Case Conversion diff --git a/src/editfns.c b/src/editfns.c index 96bb271..66dd2a4 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -5112,7 +5112,10 @@ transpose_markers (ptrdiff_t start1, ptrdiff_t end1, } } -DEFUN ("transpose-regions", Ftranspose_regions, Stranspose_regions, 4, 5, 0, +DEFUN ("transpose-regions", Ftranspose_regions, Stranspose_regions, 4, 5, + "(if (< (length mark-ring) 2)\ + (error \"Mark ring must contain at least two elements\")\ + (list (point) (mark) (car mark-ring) (cadr mark-ring)))", doc: /* Transpose region STARTR1 to ENDR1 with STARTR2 to ENDR2. The regions should not be overlapping, because the size of the buffer is never changed in a transposition. @@ -5120,7 +5123,11 @@ never changed in a transposition. Optional fifth arg LEAVE-MARKERS, if non-nil, means don't update any markers that happen to be located in the regions. -Transposing beyond buffer boundaries is an error. */) +Transposing beyond buffer boundaries is an error. + +Interactively, STARTR1 and ENDR1 are point and mark. STARTR2 and +ENDR2 are the first and second markers in the mark ring. +LEAVE-MARKERS is nil. */) (Lisp_Object startr1, Lisp_Object endr1, Lisp_Object startr2, Lisp_Object endr2, Lisp_Object leave_markers) { register ptrdiff_t start1, end1, start2, end2; -- 2.9.4