diff options
| author | Charles A. Roelli | 2018-03-11 11:59:01 +0100 |
|---|---|---|
| committer | Charles A. Roelli | 2018-03-11 11:59:01 +0100 |
| commit | b88e7c8bcd523f1f503f87a1734679405322b5ec (patch) | |
| tree | 7d02b0d403774f2ba8c6ed758be1955dd979bf1b | |
| parent | 806a0c77490e2f997b3498829c8d63a00e504b6b (diff) | |
| download | emacs-b88e7c8bcd523f1f503f87a1734679405322b5ec.tar.gz emacs-b88e7c8bcd523f1f503f87a1734679405322b5ec.zip | |
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.
| -rw-r--r-- | doc/emacs/fixit.texi | 11 | ||||
| -rw-r--r-- | src/editfns.c | 20 |
2 files changed, 29 insertions, 2 deletions
diff --git a/doc/emacs/fixit.texi b/doc/emacs/fixit.texi index 7cacac42400..eb783d175c3 100644 --- a/doc/emacs/fixit.texi +++ b/doc/emacs/fixit.texi | |||
| @@ -149,6 +149,8 @@ Transpose two words (@code{transpose-words}). | |||
| 149 | Transpose two balanced expressions (@code{transpose-sexps}). | 149 | Transpose two balanced expressions (@code{transpose-sexps}). |
| 150 | @item C-x C-t | 150 | @item C-x C-t |
| 151 | Transpose two lines (@code{transpose-lines}). | 151 | Transpose two lines (@code{transpose-lines}). |
| 152 | @item M-x transpose-regions | ||
| 153 | Transpose two regions. | ||
| 152 | @end table | 154 | @end table |
| 153 | 155 | ||
| 154 | @kindex C-t | 156 | @kindex C-t |
| @@ -204,6 +206,15 @@ otherwise a command with a repeat count of zero would do nothing): to | |||
| 204 | transpose the character (or word or expression or line) ending after | 206 | transpose the character (or word or expression or line) ending after |
| 205 | point with the one ending after the mark. | 207 | point with the one ending after the mark. |
| 206 | 208 | ||
| 209 | @findex transpose-regions | ||
| 210 | @kbd{M-x transpose-regions} transposes the text between point and | ||
| 211 | mark with the text between the last two marks pushed to the mark ring | ||
| 212 | (@pxref{Setting Mark}). With a numeric prefix argument, it transposes | ||
| 213 | the text between point and mark with the text between two successive | ||
| 214 | marks that many entries back in the mark ring. This command is best | ||
| 215 | used for transposing multiple characters (or words or sentences or | ||
| 216 | paragraphs) in one go. | ||
| 217 | |||
| 207 | @node Fixing Case | 218 | @node Fixing Case |
| 208 | @section Case Conversion | 219 | @section Case Conversion |
| 209 | 220 | ||
diff --git a/src/editfns.c b/src/editfns.c index debe10572dc..6ecc83fc302 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -5100,7 +5100,16 @@ transpose_markers (ptrdiff_t start1, ptrdiff_t end1, | |||
| 5100 | } | 5100 | } |
| 5101 | } | 5101 | } |
| 5102 | 5102 | ||
| 5103 | DEFUN ("transpose-regions", Ftranspose_regions, Stranspose_regions, 4, 5, 0, | 5103 | DEFUN ("transpose-regions", Ftranspose_regions, Stranspose_regions, 4, 5, |
| 5104 | "(if (< (length mark-ring) 2)\ | ||
| 5105 | (error \"Other region must be marked before transposing two regions\")\ | ||
| 5106 | (let* ((num (if current-prefix-arg\ | ||
| 5107 | (prefix-numeric-value current-prefix-arg)\ | ||
| 5108 | 0))\ | ||
| 5109 | (ring-length (length mark-ring))\ | ||
| 5110 | (eltnum (mod num ring-length))\ | ||
| 5111 | (eltnum2 (mod (1+ num) ring-length)))\ | ||
| 5112 | (list (point) (mark) (elt mark-ring eltnum) (elt mark-ring eltnum2))))", | ||
| 5104 | doc: /* Transpose region STARTR1 to ENDR1 with STARTR2 to ENDR2. | 5113 | doc: /* Transpose region STARTR1 to ENDR1 with STARTR2 to ENDR2. |
| 5105 | The regions should not be overlapping, because the size of the buffer is | 5114 | The regions should not be overlapping, because the size of the buffer is |
| 5106 | never changed in a transposition. | 5115 | never changed in a transposition. |
| @@ -5108,7 +5117,14 @@ never changed in a transposition. | |||
| 5108 | Optional fifth arg LEAVE-MARKERS, if non-nil, means don't update | 5117 | Optional fifth arg LEAVE-MARKERS, if non-nil, means don't update |
| 5109 | any markers that happen to be located in the regions. | 5118 | any markers that happen to be located in the regions. |
| 5110 | 5119 | ||
| 5111 | Transposing beyond buffer boundaries is an error. */) | 5120 | Transposing beyond buffer boundaries is an error. |
| 5121 | |||
| 5122 | Interactively, STARTR1 and ENDR1 are point and mark; STARTR2 and ENDR2 | ||
| 5123 | are the last two marks pushed to the mark ring; LEAVE-MARKERS is nil. | ||
| 5124 | If a prefix argument N is given, STARTR2 and ENDR2 are the two | ||
| 5125 | successive marks N entries back in the mark ring. A negative prefix | ||
| 5126 | argument instead counts forward from the oldest mark in the mark | ||
| 5127 | ring. */) | ||
| 5112 | (Lisp_Object startr1, Lisp_Object endr1, Lisp_Object startr2, Lisp_Object endr2, Lisp_Object leave_markers) | 5128 | (Lisp_Object startr1, Lisp_Object endr1, Lisp_Object startr2, Lisp_Object endr2, Lisp_Object leave_markers) |
| 5113 | { | 5129 | { |
| 5114 | register ptrdiff_t start1, end1, start2, end2; | 5130 | register ptrdiff_t start1, end1, start2, end2; |