[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] feature/gnus-select 5276bca 052/218: Make transpose-region
From: |
Andrew G Cohen |
Subject: |
[Emacs-diffs] feature/gnus-select 5276bca 052/218: Make transpose-regions interactive (Bug#30343) |
Date: |
Fri, 14 Dec 2018 03:34:54 -0500 (EST) |
branch: feature/gnus-select
commit 5276bca8f2170122a95848fa3b59324c553de5f4
Author: Charles A. Roelli <address@hidden>
Commit: Andrew G Cohen <address@hidden>
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 | 11 +++++++++++
src/editfns.c | 20 ++++++++++++++++++--
2 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/doc/emacs/fixit.texi b/doc/emacs/fixit.texi
index 7cacac4..eb783d1 100644
--- a/doc/emacs/fixit.texi
+++ b/doc/emacs/fixit.texi
@@ -149,6 +149,8 @@ Transpose two words (@code{transpose-words}).
Transpose two balanced expressions (@code{transpose-sexps}).
@item C-x C-t
Transpose two lines (@code{transpose-lines}).
address@hidden M-x transpose-regions
+Transpose two regions.
@end table
@kindex C-t
@@ -204,6 +206,15 @@ otherwise a command with a repeat count of zero would do
nothing): to
transpose the character (or word or expression or line) ending after
point with the one ending after the mark.
address@hidden transpose-regions
+ @kbd{M-x transpose-regions} transposes the text between point and
+mark with the text between the last two marks pushed to the mark ring
+(@pxref{Setting Mark}). With a numeric prefix argument, it transposes
+the text between point and mark with the text between two successive
+marks that many entries back in the mark ring. This command is best
+used for transposing multiple characters (or words or sentences or
+paragraphs) in one go.
+
@node Fixing Case
@section Case Conversion
diff --git a/src/editfns.c b/src/editfns.c
index debe105..6ecc83f 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -5100,7 +5100,16 @@ 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 \"Other region must be marked before transposing two
regions\")\
+ (let* ((num (if current-prefix-arg\
+ (prefix-numeric-value current-prefix-arg)\
+ 0))\
+ (ring-length (length mark-ring))\
+ (eltnum (mod num ring-length))\
+ (eltnum2 (mod (1+ num) ring-length)))\
+ (list (point) (mark) (elt mark-ring eltnum) (elt mark-ring
eltnum2))))",
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.
@@ -5108,7 +5117,14 @@ 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 last two marks pushed to the mark ring; LEAVE-MARKERS is nil.
+If a prefix argument N is given, STARTR2 and ENDR2 are the two
+successive marks N entries back in the mark ring. A negative prefix
+argument instead counts forward from the oldest mark in the mark
+ring. */)
(Lisp_Object startr1, Lisp_Object endr1, Lisp_Object startr2, Lisp_Object
endr2, Lisp_Object leave_markers)
{
register ptrdiff_t start1, end1, start2, end2;
- [Emacs-diffs] feature/gnus-select c69a17d 025/218: * lisp/isearch.el (search-exit-option): Add option 'append'., (continued)
- [Emacs-diffs] feature/gnus-select c69a17d 025/218: * lisp/isearch.el (search-exit-option): Add option 'append'., Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 781d997 008/218: Replace some obsolete aliases in code, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 317b4d2 010/218: Fix display of TABs in hscrolled windows with line numbers, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select de2b09f 024/218: Add to "Completion Commands" Info node, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 4efd277 030/218: ; * lisp/org/org-table.el: Replace obsolete alias in comment., Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 52b1442 003/218: Revert last commit, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 1d6e562 021/218: More minor changes in the manual, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 954d7ce 035/218: * test/Makefile.in (check-declare): New PHONY rule., Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 036f0fe 032/218: Fix string-to-number C-level mishandling, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 0160cc5 029/218: Avoid losing info when formatting integers, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 5276bca 052/218: Make transpose-regions interactive (Bug#30343),
Andrew G Cohen <=
- [Emacs-diffs] feature/gnus-select 5400223 062/218: * lisp/vc/vc-dir.el (vc-dir-unmark): Fix documentation., Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 71da4a5 063/218: ; * lisp/minibuffer.el (completion-cycle-threshold): Fix last change., Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select fbe22b5 014/218: Replace some obsolete aliases in code, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 46738e3 040/218: Improve SVG documentation, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select d25b161 042/218: Fix wrong behavior of 'outline-headers-as-kill' command (Bug#30209), Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 064037f 050/218: * lisp/simple.el (mark-whole-buffer): Clarify its behavior., Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 906b8fb 048/218: Port to NetBSD tzalloc, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select fd1f96f 060/218: Replace use of the obsolete write-contents-hooks, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 7f35e7d 055/218: Improve documentation of Xref, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 2fe4ae7 057/218: Fix last change in Xref documentation, Andrew G Cohen, 2018/12/14