106 |
</p> |
</p> |
107 |
<p> Many commands that insert text, such as <kbd>C-y</kbd> (<code>yank</code>) and |
<p> Many commands that insert text, such as <kbd>C-y</kbd> (<code>yank</code>) and |
108 |
<kbd>M-x insert-buffer</kbd>, position the mark at one end of the inserted |
<kbd>M-x insert-buffer</kbd>, position the mark at one end of the inserted |
109 |
text--the opposite end from where point is positioned, so that the region |
text—the opposite end from where point is positioned, so that the region |
110 |
contains the text just inserted. |
contains the text just inserted. |
111 |
</p> |
</p> |
112 |
<p> Aside from delimiting the region, the mark is useful for marking |
<p> Aside from delimiting the region, the mark is useful for marking |
693 |
|
|
694 |
<p> The most basic delete commands are <kbd>C-d</kbd> (<code>delete-char</code>) and |
<p> The most basic delete commands are <kbd>C-d</kbd> (<code>delete-char</code>) and |
695 |
<kbd>DEL</kbd> (<code>delete-backward-char</code>). <kbd>C-d</kbd> deletes the |
<kbd>DEL</kbd> (<code>delete-backward-char</code>). <kbd>C-d</kbd> deletes the |
696 |
character after point, the one the cursor is "on top of". Point |
character after point, the one the cursor is “on top of”. Point |
697 |
doesn't move. <kbd>DEL</kbd> deletes the character before the cursor, and |
doesn't move. <kbd>DEL</kbd> deletes the character before the cursor, and |
698 |
moves point back. You can delete newlines like any other characters in |
moves point back. You can delete newlines like any other characters in |
699 |
the buffer; deleting a newline joins two lines. Actually, <kbd>C-d</kbd> and |
the buffer; deleting a newline joins two lines. Actually, <kbd>C-d</kbd> and |
864 |
<h2 class="section"> 9.5 Yanking </h2> |
<h2 class="section"> 9.5 Yanking </h2> |
865 |
|
|
866 |
<p> <em>Yanking</em> means getting back text which was killed. Some systems |
<p> <em>Yanking</em> means getting back text which was killed. Some systems |
867 |
call this "pasting". The usual way to move or copy text is to kill it |
call this “pasting”. The usual way to move or copy text is to kill it |
868 |
and then yank it one or more times. |
and then yank it one or more times. |
869 |
</p> |
</p> |
870 |
<dl compact="compact"> |
<dl compact="compact"> |
936 |
<p> <kbd>C-u C-y</kbd> yanks the text, leaves the cursor in front of the text, |
<p> <kbd>C-u C-y</kbd> yanks the text, leaves the cursor in front of the text, |
937 |
and sets the mark after it, if the argument is with just a <kbd>C-u</kbd>. |
and sets the mark after it, if the argument is with just a <kbd>C-u</kbd>. |
938 |
Any other argument, including <kbd>C-u</kbd> and digits, has different |
Any other argument, including <kbd>C-u</kbd> and digits, has different |
939 |
results, described below, under "Yanking Earlier Kills". |
results, described below, under “Yanking Earlier Kills”. |
940 |
</p> |
</p> |
941 |
<a name="IDX336"></a> |
<a name="IDX336"></a> |
942 |
<a name="IDX337"></a> |
<a name="IDX337"></a> |
943 |
<p> To copy a block of text, you can also use <kbd>M-w</kbd> |
<p> To copy a block of text, you can also use <kbd>M-w</kbd> |
944 |
(<code>copy-region-as-kill</code>), which copies the region into the kill ring |
(<code>copy-region-as-kill</code>), which copies the region into the kill ring |
945 |
without removing it from the buffer. <kbd>M-w</kbd> is similar to <kbd>C-w</kbd> |
without removing it from the buffer. <kbd>M-w</kbd> is similar to <kbd>C-w</kbd> |
946 |
followed by <kbd>C-y</kbd> but does not mark the buffer as "modified" and |
followed by <kbd>C-y</kbd> but does not mark the buffer as “modified” and |
947 |
does not actually cut anything. |
does not actually cut anything. |
948 |
</p> |
</p> |
949 |
<hr size="6"> |
<hr size="6"> |
993 |
followed it, and the second <kbd>C-k</kbd> kills the newline after the second |
followed it, and the second <kbd>C-k</kbd> kills the newline after the second |
994 |
line. The result is that the buffer contains <samp>`This is and here is the |
line. The result is that the buffer contains <samp>`This is and here is the |
995 |
third.'</samp> and a single kill entry contains <samp>`the first<kbd>RET</kbd>line of |
third.'</samp> and a single kill entry contains <samp>`the first<kbd>RET</kbd>line of |
996 |
sample text<kbd>RET</kbd>'</samp>--all the killed text, in its original order. |
sample text<kbd>RET</kbd>'</samp>—all the killed text, in its original order. |
997 |
</p> |
</p> |
998 |
<a name="IDX338"></a> |
<a name="IDX338"></a> |
999 |
<a name="IDX339"></a> |
<a name="IDX339"></a> |
1035 |
the last kill, then <kbd>M-y</kbd> to replace it with the previous |
the last kill, then <kbd>M-y</kbd> to replace it with the previous |
1036 |
kill. |
kill. |
1037 |
</p> |
</p> |
1038 |
<p> You can think in terms of a "last yank" pointer which points at an item |
<p> You can think in terms of a “last yank” pointer which points at an item |
1039 |
in the kill ring. Each time you kill, the "last yank" pointer moves to |
in the kill ring. Each time you kill, the “last yank” pointer moves to |
1040 |
the new item at the front of the ring. <kbd>C-y</kbd> yanks the item |
the new item at the front of the ring. <kbd>C-y</kbd> yanks the item |
1041 |
which the "last yank" pointer points to. <kbd>M-y</kbd> moves the "last |
which the “last yank” pointer points to. <kbd>M-y</kbd> moves the “last |
1042 |
yank" pointer to a different item, and the text in the buffer changes to |
yank” pointer to a different item, and the text in the buffer changes to |
1043 |
match. Enough <kbd>M-y</kbd> commands can move the pointer to any item in the |
match. Enough <kbd>M-y</kbd> commands can move the pointer to any item in the |
1044 |
ring, so you can get any item into the buffer. Eventually the pointer |
ring, so you can get any item into the buffer. Eventually the pointer |
1045 |
reaches the end of the ring; the next <kbd>M-y</kbd> moves it to the first item |
reaches the end of the ring; the next <kbd>M-y</kbd> moves it to the first item |
1046 |
again. |
again. |
1047 |
</p> |
</p> |
1048 |
<p> Yanking moves the "last yank" pointer around the ring, but does not |
<p> Yanking moves the “last yank” pointer around the ring, but does not |
1049 |
change the order of the entries in the ring, which always runs from the |
change the order of the entries in the ring, which always runs from the |
1050 |
most recent kill at the front to the oldest one still remembered. |
most recent kill at the front to the oldest one still remembered. |
1051 |
</p> |
</p> |
1052 |
<p> Use <kbd>M-y</kbd> with a numeric argument to advance the "last |
<p> Use <kbd>M-y</kbd> with a numeric argument to advance the “last |
1053 |
yank" pointer by the specified number of items. A negative argument |
yank” pointer by the specified number of items. A negative argument |
1054 |
moves the pointer toward the front of the ring; from the front of the |
moves the pointer toward the front of the ring; from the front of the |
1055 |
ring, it moves to the last entry and starts moving forward from there. |
ring, it moves to the last entry and starts moving forward from there. |
1056 |
</p> |
</p> |
1058 |
stop doing <kbd>M-y</kbd> commands and the text will stay there. Since the |
stop doing <kbd>M-y</kbd> commands and the text will stay there. Since the |
1059 |
text is just a copy of the kill ring item, editing it in the buffer does |
text is just a copy of the kill ring item, editing it in the buffer does |
1060 |
not change what's in the ring. As long you don't kill additional text, |
not change what's in the ring. As long you don't kill additional text, |
1061 |
the "last yank" pointer remains at the same place in the kill ring: |
the “last yank” pointer remains at the same place in the kill ring: |
1062 |
repeating <kbd>C-y</kbd> will yank another copy of the same old kill. |
repeating <kbd>C-y</kbd> will yank another copy of the same old kill. |
1063 |
</p> |
</p> |
1064 |
<p> If you know how many <kbd>M-y</kbd> commands it would take to find the |
<p> If you know how many <kbd>M-y</kbd> commands it would take to find the |
1067 |
restores the text the specified number of entries back in the kill |
restores the text the specified number of entries back in the kill |
1068 |
ring. Thus, <kbd>C-u 2 C-y</kbd> gets the next to the last block of killed |
ring. Thus, <kbd>C-u 2 C-y</kbd> gets the next to the last block of killed |
1069 |
text. It is equivalent to <kbd>C-y M-y</kbd>. <kbd>C-y</kbd> with a numeric |
text. It is equivalent to <kbd>C-y M-y</kbd>. <kbd>C-y</kbd> with a numeric |
1070 |
argument starts counting from the "last yank" pointer, and sets the |
argument starts counting from the “last yank” pointer, and sets the |
1071 |
"last yank" pointer to the entry that it yanks. |
“last yank” pointer to the entry that it yanks. |
1072 |
</p> |
</p> |
1073 |
<a name="IDX340"></a> |
<a name="IDX340"></a> |
1074 |
<p> The variable <code>kill-ring-max</code> controls the length of the kill |
<p> The variable <code>kill-ring-max</code> controls the length of the kill |
1354 |
<li> |
<li> |
1355 |
Commands that operate on the region only work if the region is active. |
Commands that operate on the region only work if the region is active. |
1356 |
</li><li> |
</li><li> |
1357 |
Only a very small set of commands causes the region to become active-- |
Only a very small set of commands causes the region to become active— |
1358 |
those commands whose semantics are to mark an area, such as <code>mark-defun</code>. |
those commands whose semantics are to mark an area, such as <code>mark-defun</code>. |
1359 |
</li><li> |
</li><li> |
1360 |
The region is deactivated after each command that is executed, except that |
The region is deactivated after each command that is executed, except that |
1401 |
<p>When <code>zmacs-regions</code> is <code>t</code>, programs can be non-intrusive |
<p>When <code>zmacs-regions</code> is <code>t</code>, programs can be non-intrusive |
1402 |
on the state of the region by setting the variable <code>zmacs-region-stays</code> |
on the state of the region by setting the variable <code>zmacs-region-stays</code> |
1403 |
to a non-<code>nil</code> value. If you are writing a new Emacs command that |
to a non-<code>nil</code> value. If you are writing a new Emacs command that |
1404 |
is conceptually a "motion" command and should not interfere with the |
is conceptually a “motion” command and should not interfere with the |
1405 |
current highlightedness of the region, then you may set this variable. |
current highlightedness of the region, then you may set this variable. |
1406 |
It is reset to <code>nil</code> after each user command is executed. |
It is reset to <code>nil</code> after each user command is executed. |
1407 |
</p> |
</p> |
1544 |
</p></dd> |
</p></dd> |
1545 |
<dt> <kbd>M-x kill-rectangle</kbd></dt> |
<dt> <kbd>M-x kill-rectangle</kbd></dt> |
1546 |
<dd><p>Similar, but also save the contents of the region-rectangle as the |
<dd><p>Similar, but also save the contents of the region-rectangle as the |
1547 |
"last killed rectangle". |
“last killed rectangle”. |
1548 |
</p></dd> |
</p></dd> |
1549 |
<dt> <kbd>M-x yank-rectangle</kbd></dt> |
<dt> <kbd>M-x yank-rectangle</kbd></dt> |
1550 |
<dd><p>Yank the last killed rectangle with its upper left corner at point. |
<dd><p>Yank the last killed rectangle with its upper left corner at point. |
1564 |
<a name="IDX345"></a> |
<a name="IDX345"></a> |
1565 |
<a name="IDX346"></a> |
<a name="IDX346"></a> |
1566 |
<p> There are two ways to get rid of the text in a rectangle: you can discard |
<p> There are two ways to get rid of the text in a rectangle: you can discard |
1567 |
the text (delete it) or save it as the "last killed" rectangle. The |
the text (delete it) or save it as the “last killed” rectangle. The |
1568 |
commands for these two ways are <kbd>M-x delete-rectangle</kbd> and <kbd>M-x |
commands for these two ways are <kbd>M-x delete-rectangle</kbd> and <kbd>M-x |
1569 |
kill-rectangle</kbd>. In either case, the portion of each line that falls inside |
kill-rectangle</kbd>. In either case, the portion of each line that falls inside |
1570 |
the rectangle's boundaries is deleted, causing following text (if any) on |
the rectangle's boundaries is deleted, causing following text (if any) on |
1571 |
the line to move left. |
the line to move left. |
1572 |
</p> |
</p> |
1573 |
<p> Note that "killing" a rectangle is not killing in the usual sense; the |
<p> Note that “killing” a rectangle is not killing in the usual sense; the |
1574 |
rectangle is not stored in the kill ring, but in a special place that |
rectangle is not stored in the kill ring, but in a special place that |
1575 |
only records the most recently killed rectangle (that is, does not |
only records the most recently killed rectangle (that is, does not |
1576 |
append to a killed rectangle). Different yank commands |
append to a killed rectangle). Different yank commands |