diff options
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/emacs/ChangeLog | 15 | ||||
| -rw-r--r-- | doc/emacs/dired.texi | 2 | ||||
| -rw-r--r-- | doc/emacs/emacs.texi | 4 | ||||
| -rw-r--r-- | doc/emacs/frames.texi | 6 | ||||
| -rw-r--r-- | doc/emacs/killing.texi | 397 | ||||
| -rw-r--r-- | doc/emacs/mark.texi | 60 | ||||
| -rw-r--r-- | doc/emacs/mule.texi | 4 | ||||
| -rw-r--r-- | doc/lispref/ChangeLog | 7 | ||||
| -rw-r--r-- | doc/lispref/package.texi | 3 | ||||
| -rw-r--r-- | doc/lispref/text.texi | 18 | ||||
| -rw-r--r-- | doc/misc/ChangeLog | 13 | ||||
| -rw-r--r-- | doc/misc/ert.texi | 126 |
12 files changed, 369 insertions, 286 deletions
diff --git a/doc/emacs/ChangeLog b/doc/emacs/ChangeLog index 3089d2b3d5d..3fa8eece141 100644 --- a/doc/emacs/ChangeLog +++ b/doc/emacs/ChangeLog | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | 2011-10-13 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * killing.texi (Deletion): Add xref to Using Region. Document | ||
| 4 | delete-forward-char. | ||
| 5 | (Yanking): Move yank-excluded-properties to Lisp manual. Move C-y | ||
| 6 | description here. Recommend C-u C-SPC for jumping to mark. | ||
| 7 | (Kill Ring): Move kill ring variable documentation here. | ||
| 8 | (Primary Selection): Copyedits. | ||
| 9 | (Rectangles): Document new command rectangle-number-lines. | ||
| 10 | (CUA Bindings): Note that this disables the mark-even-if-inactive | ||
| 11 | behavior for C-x and C-c. | ||
| 12 | |||
| 13 | * mark.texi (Mark): Mention "active region" terminology. | ||
| 14 | (Using Region): Document delete-active-region. | ||
| 15 | |||
| 1 | 2011-10-12 Chong Yidong <cyd@stupidchicken.com> | 16 | 2011-10-12 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 17 | ||
| 3 | * mark.texi (Mark): Clarify description of disabled Transient Mark | 18 | * mark.texi (Mark): Clarify description of disabled Transient Mark |
diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi index eb2bcc109e8..b6ed47fdb3f 100644 --- a/doc/emacs/dired.texi +++ b/doc/emacs/dired.texi | |||
| @@ -1403,7 +1403,7 @@ directory than in this one. It also marks files with no counterpart, | |||
| 1403 | in both directories, as always. | 1403 | in both directories, as always. |
| 1404 | 1404 | ||
| 1405 | @cindex drag and drop, Dired | 1405 | @cindex drag and drop, Dired |
| 1406 | On the X window system, Emacs supports the ``drag and drop'' | 1406 | On the X Window System, Emacs supports the ``drag and drop'' |
| 1407 | protocol. You can drag a file object from another program, and drop | 1407 | protocol. You can drag a file object from another program, and drop |
| 1408 | it onto a Dired buffer; this either moves, copies, or creates a link | 1408 | it onto a Dired buffer; this either moves, copies, or creates a link |
| 1409 | to the file in that directory. Precisely which action is taken is | 1409 | to the file in that directory. Precisely which action is taken is |
diff --git a/doc/emacs/emacs.texi b/doc/emacs/emacs.texi index d34ecb01ad6..8a15c783fc0 100644 --- a/doc/emacs/emacs.texi +++ b/doc/emacs/emacs.texi | |||
| @@ -319,9 +319,9 @@ Killing and Moving Text | |||
| 319 | 319 | ||
| 320 | Yanking | 320 | Yanking |
| 321 | 321 | ||
| 322 | * Kill Ring:: Where killed text is stored. Basic yanking. | 322 | * Kill Ring:: Where killed text is stored. |
| 323 | * Appending Kills:: Several kills in a row all yank together. | ||
| 324 | * Earlier Kills:: Yanking something killed some time ago. | 323 | * Earlier Kills:: Yanking something killed some time ago. |
| 324 | * Appending Kills:: Several kills in a row all yank together. | ||
| 325 | 325 | ||
| 326 | Killing and Yanking on Graphical Displays | 326 | Killing and Yanking on Graphical Displays |
| 327 | 327 | ||
diff --git a/doc/emacs/frames.texi b/doc/emacs/frames.texi index fc78f90db15..14fdb3121a4 100644 --- a/doc/emacs/frames.texi +++ b/doc/emacs/frames.texi | |||
| @@ -93,7 +93,7 @@ clicked. | |||
| 93 | Normally, Emacs does not distinguish between ordinary mouse clicks | 93 | Normally, Emacs does not distinguish between ordinary mouse clicks |
| 94 | and clicks that select a frame. When you click on a frame to select | 94 | and clicks that select a frame. When you click on a frame to select |
| 95 | it, that also changes the selected window and cursor position | 95 | it, that also changes the selected window and cursor position |
| 96 | according to the mouse click position. On the X window system, you | 96 | according to the mouse click position. On the X Window System, you |
| 97 | can change this behavior by setting the variable | 97 | can change this behavior by setting the variable |
| 98 | @code{x-mouse-click-focus-ignore-position} to @code{t}. Then the | 98 | @code{x-mouse-click-focus-ignore-position} to @code{t}. Then the |
| 99 | first click selects the frame, but does not affect the selected window | 99 | first click selects the frame, but does not affect the selected window |
| @@ -961,7 +961,7 @@ the left of each Emacs window, running the height of the | |||
| 961 | window.@footnote{Placing it at the left is usually more useful with | 961 | window.@footnote{Placing it at the left is usually more useful with |
| 962 | overlapping frames with text starting at the left margin.} | 962 | overlapping frames with text starting at the left margin.} |
| 963 | 963 | ||
| 964 | When Emacs is compiled with GTK+ support on the X window system, or | 964 | When Emacs is compiled with GTK+ support on the X Window System, or |
| 965 | in operating systems such as Microsoft Windows or Mac OS, you can use | 965 | in operating systems such as Microsoft Windows or Mac OS, you can use |
| 966 | the scroll bar as you do in other graphical applications. If you | 966 | the scroll bar as you do in other graphical applications. If you |
| 967 | click @kbd{Mouse-1} on the scroll bar's up and down buttons, that | 967 | click @kbd{Mouse-1} on the scroll bar's up and down buttons, that |
| @@ -971,7 +971,7 @@ the entire height of the window, like @kbd{M-v} and @kbd{C-v} | |||
| 971 | respectively (@pxref{Moving Point}). Dragging the inner box with | 971 | respectively (@pxref{Moving Point}). Dragging the inner box with |
| 972 | @kbd{Mouse-1} scrolls the window continuously. | 972 | @kbd{Mouse-1} scrolls the window continuously. |
| 973 | 973 | ||
| 974 | If Emacs is compiled without GTK+ support on the X window system, | 974 | If Emacs is compiled without GTK+ support on the X Window System, |
| 975 | the scroll bar behaves differently. The scroll bar's inner box is | 975 | the scroll bar behaves differently. The scroll bar's inner box is |
| 976 | drawn to represent the portion of the buffer currently displayed, with | 976 | drawn to represent the portion of the buffer currently displayed, with |
| 977 | the entire height of the scroll bar representing the entire length of | 977 | the entire height of the scroll bar representing the entire length of |
diff --git a/doc/emacs/killing.texi b/doc/emacs/killing.texi index 06839ce5187..493316daa52 100644 --- a/doc/emacs/killing.texi +++ b/doc/emacs/killing.texi | |||
| @@ -77,12 +77,18 @@ the most part, the Emacs commands that delete text are those that | |||
| 77 | erase just one character or only whitespace. | 77 | erase just one character or only whitespace. |
| 78 | 78 | ||
| 79 | @table @kbd | 79 | @table @kbd |
| 80 | @item C-d | ||
| 81 | @itemx @key{Delete} | ||
| 82 | Delete next character (@code{delete-char}). | ||
| 83 | @item @key{DEL} | 80 | @item @key{DEL} |
| 84 | @itemx @key{Backspace} | 81 | @itemx @key{Backspace} |
| 85 | Delete previous character (@code{delete-backward-char}). | 82 | Delete the previous character, or the text in the region if it is |
| 83 | active (@code{delete-backward-char}). | ||
| 84 | |||
| 85 | @item @key{Delete} | ||
| 86 | Delete the next character, or the text in the region if it is active | ||
| 87 | (@code{delete-forward-char}). | ||
| 88 | |||
| 89 | @item C-d | ||
| 90 | Delete the next character (@code{delete-char}). | ||
| 91 | |||
| 86 | @item M-\ | 92 | @item M-\ |
| 87 | Delete spaces and tabs around point (@code{delete-horizontal-space}). | 93 | Delete spaces and tabs around point (@code{delete-horizontal-space}). |
| 88 | @item M-@key{SPC} | 94 | @item M-@key{SPC} |
| @@ -95,9 +101,13 @@ Join two lines by deleting the intervening newline, along with any | |||
| 95 | indentation following it (@code{delete-indentation}). | 101 | indentation following it (@code{delete-indentation}). |
| 96 | @end table | 102 | @end table |
| 97 | 103 | ||
| 98 | We have already described the basic deletion commands @kbd{C-d} | 104 | We have already described the basic deletion commands @key{DEL} |
| 99 | (@code{delete-char}) and @key{DEL} (@code{delete-backward-char}). | 105 | (@code{delete-backward-char}), @key{delete} |
| 100 | @xref{Erasing}. | 106 | (@code{delete-forward-char}), and @kbd{C-d} (@code{delete-char}). |
| 107 | @xref{Erasing}. With a numeric argument, they delete the specified | ||
| 108 | number of characters. If the numeric argument is omitted or one, they | ||
| 109 | delete all the text in the region if it is active (@pxref{Using | ||
| 110 | Region}). | ||
| 101 | 111 | ||
| 102 | @kindex M-\ | 112 | @kindex M-\ |
| 103 | @findex delete-horizontal-space | 113 | @findex delete-horizontal-space |
| @@ -177,35 +187,35 @@ key sequence @kbd{C-S-backspace}. | |||
| 177 | 187 | ||
| 178 | @table @kbd | 188 | @table @kbd |
| 179 | @item C-w | 189 | @item C-w |
| 180 | Kill region (@code{kill-region}). @xref{Mark}. | 190 | Kill the region (@code{kill-region}). |
| 181 | @item M-w | 191 | @item M-w |
| 182 | Save region as last killed text without actually killing it | 192 | Copy the region into the kill ring (@code{kill-ring-save}). |
| 183 | (@code{kill-ring-save}). Some programs call this ``copying.'' | ||
| 184 | @item M-d | 193 | @item M-d |
| 185 | Kill word (@code{kill-word}). @xref{Words}. | 194 | Kill the next word (@code{kill-word}). @xref{Words}. |
| 186 | @item M-@key{DEL} | 195 | @item M-@key{DEL} |
| 187 | Kill word backwards (@code{backward-kill-word}). | 196 | Kill one word backwards (@code{backward-kill-word}). |
| 188 | @item C-x @key{DEL} | 197 | @item C-x @key{DEL} |
| 189 | Kill back to beginning of sentence (@code{backward-kill-sentence}). | 198 | Kill back to beginning of sentence (@code{backward-kill-sentence}). |
| 190 | @xref{Sentences}. | 199 | @xref{Sentences}. |
| 191 | @item M-k | 200 | @item M-k |
| 192 | Kill to end of sentence (@code{kill-sentence}). | 201 | Kill to the end of the sentence (@code{kill-sentence}). |
| 193 | @item C-M-k | 202 | @item C-M-k |
| 194 | Kill the following balanced expression (@code{kill-sexp}). @xref{Expressions}. | 203 | Kill the following balanced expression (@code{kill-sexp}). @xref{Expressions}. |
| 195 | @item M-z @var{char} | 204 | @item M-z @var{char} |
| 196 | Kill through the next occurrence of @var{char} (@code{zap-to-char}). | 205 | Kill through the next occurrence of @var{char} (@code{zap-to-char}). |
| 197 | @end table | 206 | @end table |
| 198 | 207 | ||
| 199 | Apart from @kbd{C-k}, the most commonly-used kill command is | 208 | @kindex C-w |
| 200 | @kbd{C-w} (@code{kill-region}), which kills the text in the region | 209 | @findex kill-region |
| 201 | (i.e., between point and mark). @xref{Mark}. If the mark is inactive | ||
| 202 | when you type @kbd{C-w}, it first reactivates the mark where it was | ||
| 203 | last set. The mark is deactivated at the end of the command. | ||
| 204 | |||
| 205 | @kindex M-w | 210 | @kindex M-w |
| 206 | @findex kill-ring-save | 211 | @findex kill-ring-save |
| 207 | @kbd{M-w} (@code{kill-ring-save}) copies the region into the kill | 212 | One of the commonly-used kill commands is @kbd{C-w} |
| 208 | ring without removing it from the buffer. | 213 | (@code{kill-region}), which kills the text in the region |
| 214 | (@pxref{Mark}). Similarly, @kbd{M-w} (@code{kill-ring-save}) copies | ||
| 215 | the text in the region into the kill ring without removing it from the | ||
| 216 | buffer. If the mark is inactive when you type @kbd{C-w} or @kbd{M-w}, | ||
| 217 | the command acts on the text between point and where you last set the | ||
| 218 | mark (@pxref{Using Region}). | ||
| 209 | 219 | ||
| 210 | Emacs also provides commands to kill specific syntactic units: | 220 | Emacs also provides commands to kill specific syntactic units: |
| 211 | words, with @kbd{M-@key{DEL}} and @kbd{M-d} (@pxref{Words}); balanced | 221 | words, with @kbd{M-@key{DEL}} and @kbd{M-d} (@pxref{Words}); balanced |
| @@ -248,34 +258,45 @@ kill-ring entry, without duplication. | |||
| 248 | @cindex pasting | 258 | @cindex pasting |
| 249 | 259 | ||
| 250 | @dfn{Yanking} means reinserting text previously killed. The usual | 260 | @dfn{Yanking} means reinserting text previously killed. The usual |
| 251 | way to move or copy text is to kill it and then yank it elsewhere one | 261 | way to move or copy text is to kill it and then yank it elsewhere. |
| 252 | or more times. | ||
| 253 | 262 | ||
| 254 | @table @kbd | 263 | @table @kbd |
| 255 | @item C-y | 264 | @item C-y |
| 256 | Yank last killed text (@code{yank}). | 265 | Yank the last kill into the buffer, at point (@code{yank}). |
| 257 | @item M-y | 266 | @item M-y |
| 258 | Replace text just yanked with an earlier batch of killed text | 267 | Replace the text just yanked with an earlier batch of killed text |
| 259 | (@code{yank-pop}). | 268 | (@code{yank-pop}). @xref{Earlier Kills}. |
| 260 | @item C-M-w | 269 | @item C-M-w |
| 261 | Append next kill to last batch of killed text (@code{append-next-kill}). | 270 | Cause the following command, if it is a kill command, to append to the |
| 271 | previous kill (@code{append-next-kill}). @xref{Appending Kills}. | ||
| 262 | @end table | 272 | @end table |
| 263 | 273 | ||
| 264 | @cindex yanking and text properties | 274 | @kindex C-y |
| 265 | @vindex yank-excluded-properties | 275 | @findex yank |
| 266 | The yank commands discard certain properties from the yanked text. | 276 | The basic yanking command is @kbd{C-y} (@code{yank}). It inserts |
| 267 | These are properties that might lead to annoying results, such as | 277 | the most recent kill, leaving the cursor at the end of the inserted |
| 268 | causing the text to respond to the mouse or specifying key bindings. | 278 | text. It also sets the mark at the beginning of the inserted text, |
| 269 | The list of properties to discard is stored in the variable | 279 | without activating the mark; this lets you jump easily to that |
| 270 | @code{yank-excluded-properties}. These properties are also discarded | 280 | position, if you wish, with @kbd{C-u C-@key{SPC}} (@pxref{Mark Ring}). |
| 271 | when yanking register contents and rectangles. @xref{Text | 281 | |
| 272 | Properties,,, elisp, the Emacs Lisp Reference Manual}, for more | 282 | With a plain prefix argument (@kbd{C-u C-y}), the command instead |
| 273 | information about text properties. | 283 | leaves the cursor in front of the inserted text, and sets the mark at |
| 284 | the end. Using any other prefix argument specifies an earlier kill; | ||
| 285 | e.g. @kbd{C-u 4 C-y} reinserts the fourth most recent kill. | ||
| 286 | @xref{Earlier Kills}. | ||
| 287 | |||
| 288 | On graphical displays, @kbd{C-y} first checks if another application | ||
| 289 | has placed any text in the system clipboard more recently than the | ||
| 290 | last Emacs kill. If so, it inserts the text in the clipboard instead. | ||
| 291 | Thus, Emacs effectively treats ``cut'' or ``copy'' clipboard | ||
| 292 | operations performed in other applications like Emacs kills, except | ||
| 293 | that they are not recorded in the kill ring. @xref{Cut and Paste}, | ||
| 294 | for details. | ||
| 274 | 295 | ||
| 275 | @menu | 296 | @menu |
| 276 | * Kill Ring:: Where killed text is stored. Basic yanking. | 297 | * Kill Ring:: Where killed text is stored. |
| 277 | * Appending Kills:: Several kills in a row all yank together. | ||
| 278 | * Earlier Kills:: Yanking something killed some time ago. | 298 | * Earlier Kills:: Yanking something killed some time ago. |
| 299 | * Appending Kills:: Several kills in a row all yank together. | ||
| 279 | @end menu | 300 | @end menu |
| 280 | 301 | ||
| 281 | @node Kill Ring | 302 | @node Kill Ring |
| @@ -284,31 +305,69 @@ information about text properties. | |||
| 284 | The @dfn{kill ring} is a list of blocks of text that were previously | 305 | The @dfn{kill ring} is a list of blocks of text that were previously |
| 285 | killed. There is only one kill ring, shared by all buffers, so you | 306 | killed. There is only one kill ring, shared by all buffers, so you |
| 286 | can kill text in one buffer and yank it in another buffer. This is | 307 | can kill text in one buffer and yank it in another buffer. This is |
| 287 | the usual way to move text from one file to another. (There are | 308 | the usual way to move text from one buffer to another. (There are |
| 288 | several other methods: for instance, you could store the text in a | 309 | several other methods: for instance, you could store the text in a |
| 289 | register; see @ref{Registers}. @xref{Accumulating Text}, for some | 310 | register; see @ref{Registers}. @xref{Accumulating Text}, for some |
| 290 | other ways to move text around.) | 311 | other ways to move text around.) |
| 291 | 312 | ||
| 292 | @kindex C-y | 313 | @vindex kill-ring-max |
| 293 | @findex yank | 314 | The maximum number of entries in the kill ring is controlled by the |
| 294 | @kbd{C-y} (@code{yank}) reinserts the text of the most recent kill, | 315 | variable @code{kill-ring-max}. The default is 60. If you make a new |
| 295 | leaving the cursor at the end of the text. It also adds the position | 316 | kill when this limit has been reached, Emacs makes room by deleting |
| 296 | of the beginning of the text to the mark ring, without activating the | 317 | the oldest entry in the kill ring. |
| 297 | mark; this allows you to jump easily to that position with @kbd{C-x | ||
| 298 | C-x} (@pxref{Setting Mark}). | ||
| 299 | 318 | ||
| 300 | On graphical displays, @kbd{C-y} first checks if another application | 319 | @vindex kill-ring |
| 301 | has placed any text in the system clipboard more recently than the | 320 | The actual contents of the kill ring are stored in a variable named |
| 302 | last Emacs kill. If so, it inserts from the clipboard instead of the | 321 | @code{kill-ring}; you can view the entire contents of the kill ring |
| 303 | kill ring. Conceptually, you can think of the clipboard as an | 322 | with @kbd{C-h v kill-ring}. |
| 304 | ``extra'' entry in the kill ring, which is present if you recently cut | 323 | |
| 305 | or copied some text in another application. @xref{Cut and Paste}. | 324 | @node Earlier Kills |
| 325 | @subsection Yanking Earlier Kills | ||
| 326 | @cindex yanking previous kills | ||
| 327 | |||
| 328 | As explained in @ref{Yanking}, you can use a numeric argument to | ||
| 329 | @kbd{C-y} to yank text that is no longer the most recent kill. This | ||
| 330 | is useful if you remember which kill ring entry you want. If you | ||
| 331 | don't, you can use the @kbd{M-y} (@code{yank-pop}) command to cycle | ||
| 332 | through the possibilities. | ||
| 333 | |||
| 334 | @kindex M-y | ||
| 335 | @findex yank-pop | ||
| 336 | If the previous command was a yank command, @kbd{M-y} takes the text | ||
| 337 | that was yanked and replaces it with the text from an earlier kill. | ||
| 338 | So, to recover the text of the next-to-the-last kill, first use | ||
| 339 | @kbd{C-y} to yank the last kill, and then use @kbd{M-y} to replace it | ||
| 340 | with the previous kill. @kbd{M-y} is allowed only after a @kbd{C-y} | ||
| 341 | or another @kbd{M-y}. | ||
| 342 | |||
| 343 | You can understand @kbd{M-y} in terms of a ``last yank'' pointer which | ||
| 344 | points at an entry in the kill ring. Each time you kill, the ``last | ||
| 345 | yank'' pointer moves to the newly made entry at the front of the ring. | ||
| 346 | @kbd{C-y} yanks the entry which the ``last yank'' pointer points to. | ||
| 347 | @kbd{M-y} moves the ``last yank'' pointer to a different entry, and the | ||
| 348 | text in the buffer changes to match. Enough @kbd{M-y} commands can move | ||
| 349 | the pointer to any entry in the ring, so you can get any entry into the | ||
| 350 | buffer. Eventually the pointer reaches the end of the ring; the next | ||
| 351 | @kbd{M-y} loops back around to the first entry again. | ||
| 352 | |||
| 353 | @kbd{M-y} moves the ``last yank'' pointer around the ring, but it does | ||
| 354 | not change the order of the entries in the ring, which always runs from | ||
| 355 | the most recent kill at the front to the oldest one still remembered. | ||
| 356 | |||
| 357 | @kbd{M-y} can take a numeric argument, which tells it how many entries | ||
| 358 | to advance the ``last yank'' pointer by. A negative argument moves the | ||
| 359 | pointer toward the front of the ring; from the front of the ring, it | ||
| 360 | moves ``around'' to the last entry and continues forward from there. | ||
| 361 | |||
| 362 | Once the text you are looking for is brought into the buffer, you can | ||
| 363 | stop doing @kbd{M-y} commands and it will stay there. It's just a copy | ||
| 364 | of the kill ring entry, so editing it in the buffer does not change | ||
| 365 | what's in the ring. As long as no new killing is done, the ``last | ||
| 366 | yank'' pointer remains at the same place in the kill ring, so repeating | ||
| 367 | @kbd{C-y} will yank another copy of the same previous kill. | ||
| 306 | 368 | ||
| 307 | With a plain prefix argument (@kbd{C-u C-y}), the @code{yank} | 369 | When you call @kbd{C-y} with a numeric argument, that also sets the |
| 308 | command instead leaves the cursor in front of the text, and adds the | 370 | ``last yank'' pointer to the entry that it yanks. |
| 309 | position of the end of the text to the mark ring. Using any other | ||
| 310 | prefix argument specifies an earlier kill; for example, @kbd{C-u 4 | ||
| 311 | C-y} reinserts the fourth most recent kill. @xref{Earlier Kills}. | ||
| 312 | 371 | ||
| 313 | @node Appending Kills | 372 | @node Appending Kills |
| 314 | @subsection Appending Kills | 373 | @subsection Appending Kills |
| @@ -365,65 +424,6 @@ accumulate them to be yanked back in one place.@refill | |||
| 365 | A kill command following @kbd{M-w} (@code{kill-ring-save}) does not | 424 | A kill command following @kbd{M-w} (@code{kill-ring-save}) does not |
| 366 | append to the text that @kbd{M-w} copied into the kill ring. | 425 | append to the text that @kbd{M-w} copied into the kill ring. |
| 367 | 426 | ||
| 368 | @node Earlier Kills | ||
| 369 | @subsection Yanking Earlier Kills | ||
| 370 | |||
| 371 | @cindex yanking previous kills | ||
| 372 | @kindex M-y | ||
| 373 | @findex yank-pop | ||
| 374 | To recover killed text that is no longer the most recent kill, use the | ||
| 375 | @kbd{M-y} command (@code{yank-pop}). It takes the text previously | ||
| 376 | yanked and replaces it with the text from an earlier kill. So, to | ||
| 377 | recover the text of the next-to-the-last kill, first use @kbd{C-y} to | ||
| 378 | yank the last kill, and then use @kbd{M-y} to replace it with the | ||
| 379 | previous kill. @kbd{M-y} is allowed only after a @kbd{C-y} or another | ||
| 380 | @kbd{M-y}. | ||
| 381 | |||
| 382 | You can understand @kbd{M-y} in terms of a ``last yank'' pointer which | ||
| 383 | points at an entry in the kill ring. Each time you kill, the ``last | ||
| 384 | yank'' pointer moves to the newly made entry at the front of the ring. | ||
| 385 | @kbd{C-y} yanks the entry which the ``last yank'' pointer points to. | ||
| 386 | @kbd{M-y} moves the ``last yank'' pointer to a different entry, and the | ||
| 387 | text in the buffer changes to match. Enough @kbd{M-y} commands can move | ||
| 388 | the pointer to any entry in the ring, so you can get any entry into the | ||
| 389 | buffer. Eventually the pointer reaches the end of the ring; the next | ||
| 390 | @kbd{M-y} loops back around to the first entry again. | ||
| 391 | |||
| 392 | @kbd{M-y} moves the ``last yank'' pointer around the ring, but it does | ||
| 393 | not change the order of the entries in the ring, which always runs from | ||
| 394 | the most recent kill at the front to the oldest one still remembered. | ||
| 395 | |||
| 396 | @kbd{M-y} can take a numeric argument, which tells it how many entries | ||
| 397 | to advance the ``last yank'' pointer by. A negative argument moves the | ||
| 398 | pointer toward the front of the ring; from the front of the ring, it | ||
| 399 | moves ``around'' to the last entry and continues forward from there. | ||
| 400 | |||
| 401 | Once the text you are looking for is brought into the buffer, you can | ||
| 402 | stop doing @kbd{M-y} commands and it will stay there. It's just a copy | ||
| 403 | of the kill ring entry, so editing it in the buffer does not change | ||
| 404 | what's in the ring. As long as no new killing is done, the ``last | ||
| 405 | yank'' pointer remains at the same place in the kill ring, so repeating | ||
| 406 | @kbd{C-y} will yank another copy of the same previous kill. | ||
| 407 | |||
| 408 | If you know how many @kbd{M-y} commands it would take to find the | ||
| 409 | text you want, you can yank that text in one step using @kbd{C-y} with | ||
| 410 | a numeric argument. @kbd{C-y} with an argument restores the text from | ||
| 411 | the specified kill ring entry, counting back from the most recent as | ||
| 412 | 1. Thus, @kbd{C-u 2 C-y} gets the next-to-the-last block of killed | ||
| 413 | text---it is equivalent to @kbd{C-y M-y}. @kbd{C-y} with a numeric | ||
| 414 | argument starts counting from the ``last yank'' pointer, and sets the | ||
| 415 | ``last yank'' pointer to the entry that it yanks. | ||
| 416 | |||
| 417 | @vindex kill-ring-max | ||
| 418 | The length of the kill ring is controlled by the variable | ||
| 419 | @code{kill-ring-max}; no more than that many blocks of killed text are | ||
| 420 | saved. | ||
| 421 | |||
| 422 | @vindex kill-ring | ||
| 423 | The actual contents of the kill ring are stored in a variable named | ||
| 424 | @code{kill-ring}; you can view the entire contents of the kill ring with | ||
| 425 | the command @kbd{C-h v kill-ring}. | ||
| 426 | |||
| 427 | @node Cut and Paste | 427 | @node Cut and Paste |
| 428 | @section ``Cut and Paste'' Operations on Graphical Displays | 428 | @section ``Cut and Paste'' Operations on Graphical Displays |
| 429 | @cindex cut | 429 | @cindex cut |
| @@ -462,7 +462,7 @@ and yank commands in Emacs make use of it. | |||
| 462 | When you kill some text with a command such as @kbd{C-w} | 462 | When you kill some text with a command such as @kbd{C-w} |
| 463 | (@code{kill-region}), or copy it to the kill ring with a command such | 463 | (@code{kill-region}), or copy it to the kill ring with a command such |
| 464 | as @kbd{M-w} (@code{kill-ring-save}), that text is also put in the | 464 | as @kbd{M-w} (@code{kill-ring-save}), that text is also put in the |
| 465 | clipboard. @xref{Killing}. | 465 | clipboard. |
| 466 | 466 | ||
| 467 | @vindex save-interprogram-paste-before-kill | 467 | @vindex save-interprogram-paste-before-kill |
| 468 | When an Emacs kill command puts text in the clipboard, the existing | 468 | When an Emacs kill command puts text in the clipboard, the existing |
| @@ -472,12 +472,11 @@ will first save the clipboard to its kill ring, preventing you from | |||
| 472 | losing the old clipboard data---at the risk of high memory consumption | 472 | losing the old clipboard data---at the risk of high memory consumption |
| 473 | if that data turns out to be large. | 473 | if that data turns out to be large. |
| 474 | 474 | ||
| 475 | The usual yank commands, such as @kbd{C-y} (@code{yank}), also use | 475 | Yank commands, such as @kbd{C-y} (@code{yank}), also use the |
| 476 | the clipboard. If another application ``owns'' the clipboard---i.e., | 476 | clipboard. If another application ``owns'' the clipboard---i.e., if |
| 477 | if you cut or copied text there more recently than your last kill | 477 | you cut or copied text there more recently than your last kill command |
| 478 | command in Emacs---then Emacs yanks from the clipboard instead of the | 478 | in Emacs---then Emacs yanks from the clipboard instead of the kill |
| 479 | kill ring. Otherwise, it yanks from the kill ring, as described in | 479 | ring. |
| 480 | @ref{Yanking}. | ||
| 481 | 480 | ||
| 482 | @vindex yank-pop-change-selection | 481 | @vindex yank-pop-change-selection |
| 483 | Normally, rotating the kill ring with @kbd{M-y} (@code{yank-pop}) | 482 | Normally, rotating the kill ring with @kbd{M-y} (@code{yank-pop}) |
| @@ -511,20 +510,20 @@ yanks the contents of the clipboard at point. | |||
| 511 | @cindex primary selection | 510 | @cindex primary selection |
| 512 | @cindex selection, primary | 511 | @cindex selection, primary |
| 513 | 512 | ||
| 514 | Under the X window system, there exists a @dfn{primary selection} | 513 | Under the X Window System, there exists a @dfn{primary selection} |
| 515 | containing the last stretch of text selected in an X application | 514 | containing the last stretch of text selected in an X application |
| 516 | (usually by dragging the mouse). Typically, this text can be inserted | 515 | (usually by dragging the mouse). Typically, this text can be inserted |
| 517 | into other X applications by @kbd{mouse-2} clicks. The primary | 516 | into other X applications by @kbd{mouse-2} clicks. The primary |
| 518 | selection is separate from the clipboard (@pxref{Clipboard}). Its | 517 | selection is separate from the clipboard. Its contents are more |
| 519 | contents are more ``fragile''; they are overwritten by any mouse | 518 | ``fragile''; they are overwritten each time you select text with the |
| 520 | selection, whereas the clipboard is only overwritten by explicit | 519 | mouse, whereas the clipboard is only overwritten by explicit ``cut'' |
| 521 | ``cut'' or ``copy'' commands. | 520 | or ``copy'' commands. |
| 522 | 521 | ||
| 523 | Under X, whenever you set an active region (@pxref{Mark}), Emacs | 522 | Under X, whenever the region is active (@pxref{Mark}), the text in |
| 524 | saves the text in the active region to the primary selection. This | 523 | the region is saved in the primary selection. This applies regardless |
| 525 | applies to active regions made by dragging or clicking the mouse | 524 | of whether the region was made by dragging or clicking the mouse |
| 526 | (@pxref{Mouse Commands}), and those made by keyboard commands (e.g. by | 525 | (@pxref{Mouse Commands}), or by keyboard commands (e.g. by typing |
| 527 | typing @kbd{C-@key{SPC}} and moving point; see @ref{Setting Mark}). | 526 | @kbd{C-@key{SPC}} and moving point; @pxref{Setting Mark}). |
| 528 | 527 | ||
| 529 | @vindex select-active-regions | 528 | @vindex select-active-regions |
| 530 | If you change the variable @code{select-active-regions} to | 529 | If you change the variable @code{select-active-regions} to |
| @@ -636,9 +635,9 @@ starting from wherever point happens to be at that moment. | |||
| 636 | successive uses of @code{append-to-buffer} accumulate the text in the | 635 | successive uses of @code{append-to-buffer} accumulate the text in the |
| 637 | specified buffer in the same order as they were copied. Strictly | 636 | specified buffer in the same order as they were copied. Strictly |
| 638 | speaking, @code{append-to-buffer} does not always append to the text | 637 | speaking, @code{append-to-buffer} does not always append to the text |
| 639 | already in the buffer---it appends only if point in that buffer is at the end. | 638 | already in the buffer---it appends only if point in that buffer is at |
| 640 | However, if @code{append-to-buffer} is the only command you use to alter | 639 | the end. However, if @code{append-to-buffer} is the only command you |
| 641 | a buffer, then point is always at the end. | 640 | use to alter a buffer, then point is always at the end. |
| 642 | 641 | ||
| 643 | @kbd{M-x prepend-to-buffer} is just like @code{append-to-buffer} | 642 | @kbd{M-x prepend-to-buffer} is just like @code{append-to-buffer} |
| 644 | except that point in the other buffer is left before the copied text, so | 643 | except that point in the other buffer is left before the copied text, so |
| @@ -682,19 +681,16 @@ them. Rectangle commands are useful with text in multicolumn formats, | |||
| 682 | and for changing text into or out of such formats. | 681 | and for changing text into or out of such formats. |
| 683 | 682 | ||
| 684 | @cindex mark rectangle | 683 | @cindex mark rectangle |
| 685 | When you must specify a rectangle for a command to work on, you do it | 684 | To specify a rectangle for a command to work on, set the mark at one |
| 686 | by putting the mark at one corner and point at the opposite corner. The | 685 | corner and point at the opposite corner. The rectangle thus specified |
| 687 | rectangle thus specified is called the @dfn{region-rectangle} because | 686 | is called the @dfn{region-rectangle}. If point and the mark are in |
| 688 | you control it in much the same way as the region is controlled. But | 687 | the same column, the region-rectangle is empty. If they are in the |
| 689 | remember that a given combination of point and mark values can be | 688 | same line, the region-rectangle is one line high. |
| 690 | interpreted either as a region or as a rectangle, depending on the | 689 | |
| 691 | command that uses them. | 690 | The region-rectangle is controlled in much the same way as the |
| 692 | 691 | region is controlled. But remember that a given combination of point | |
| 693 | If point and the mark are in the same column, the rectangle they | 692 | and mark values can be interpreted either as a region or as a |
| 694 | delimit is empty. If they are in the same line, the rectangle is one | 693 | rectangle, depending on the command that uses them. |
| 695 | line high. This asymmetry between lines and columns comes about | ||
| 696 | because point (and likewise the mark) is between two columns, but within | ||
| 697 | a line. | ||
| 698 | 694 | ||
| 699 | @table @kbd | 695 | @table @kbd |
| 700 | @item C-x r k | 696 | @item C-x r k |
| @@ -708,7 +704,11 @@ Yank the last killed rectangle with its upper left corner at point | |||
| 708 | @item C-x r o | 704 | @item C-x r o |
| 709 | Insert blank space to fill the space of the region-rectangle | 705 | Insert blank space to fill the space of the region-rectangle |
| 710 | (@code{open-rectangle}). This pushes the previous contents of the | 706 | (@code{open-rectangle}). This pushes the previous contents of the |
| 711 | region-rectangle rightward. | 707 | region-rectangle to the right. |
| 708 | @item C-x r N | ||
| 709 | Insert line numbers along the left edge of the region-rectangle | ||
| 710 | (@code{rectangle-number-lines}). This pushes the previous contents of | ||
| 711 | the region-rectangle to the right. | ||
| 712 | @item C-x r c | 712 | @item C-x r c |
| 713 | Clear the region-rectangle by replacing all of its contents with spaces | 713 | Clear the region-rectangle by replacing all of its contents with spaces |
| 714 | (@code{clear-rectangle}). | 714 | (@code{clear-rectangle}). |
| @@ -722,42 +722,39 @@ Replace rectangle contents with @var{string} on each line | |||
| 722 | Insert @var{string} on each line of the rectangle. | 722 | Insert @var{string} on each line of the rectangle. |
| 723 | @end table | 723 | @end table |
| 724 | 724 | ||
| 725 | The rectangle operations fall into two classes: commands for | 725 | The rectangle operations fall into two classes: commands to erase or |
| 726 | deleting and inserting rectangles, and commands for blank rectangles. | 726 | insert rectangles, and commands to make blank rectangles. |
| 727 | 727 | ||
| 728 | @kindex C-x r k | 728 | @kindex C-x r k |
| 729 | @kindex C-x r d | 729 | @kindex C-x r d |
| 730 | @findex kill-rectangle | 730 | @findex kill-rectangle |
| 731 | @findex delete-rectangle | 731 | @findex delete-rectangle |
| 732 | There are two ways to get rid of the text in a rectangle: you can | 732 | There are two ways to erase the text in a rectangle: @kbd{C-x r d} |
| 733 | discard the text (delete it) or save it as the ``last killed'' | 733 | (@code{delete-rectangle}) to delete the text outright, or @kbd{C-x r |
| 734 | rectangle. The commands for these two ways are @kbd{C-x r d} | 734 | k} (@code{kill-rectangle}) to remove the text and and save it as the |
| 735 | (@code{delete-rectangle}) and @kbd{C-x r k} (@code{kill-rectangle}). In | 735 | @dfn{last killed rectangle}. In both cases, erasing the |
| 736 | either case, the portion of each line that falls inside the rectangle's | 736 | region-rectangle is like erasing the specified text on each line of |
| 737 | boundaries is deleted, causing any following text on the line to | 737 | the rectange; if there is any following text on the line, it moves |
| 738 | move left into the gap. | 738 | backwards to fill the gap. |
| 739 | 739 | ||
| 740 | Note that ``killing'' a rectangle is not killing in the usual sense; the | 740 | ``Killing'' a rectangle is not killing in the usual sense; the |
| 741 | rectangle is not stored in the kill ring, but in a special place that | 741 | rectangle is not stored in the kill ring, but in a special place that |
| 742 | can only record the most recent rectangle killed. This is because yanking | 742 | only records the most recent rectangle killed. This is because |
| 743 | a rectangle is so different from yanking linear text that different yank | 743 | yanking a rectangle is so different from yanking linear text that |
| 744 | commands have to be used. It is hard to define yank-popping for rectangles, | 744 | different yank commands have to be used. Yank-popping is not defined |
| 745 | so we do not try. | 745 | for rectangles. |
| 746 | 746 | ||
| 747 | @kindex C-x r y | 747 | @kindex C-x r y |
| 748 | @findex yank-rectangle | 748 | @findex yank-rectangle |
| 749 | To yank the last killed rectangle, type @kbd{C-x r y} | 749 | To yank the last killed rectangle, type @kbd{C-x r y} |
| 750 | (@code{yank-rectangle}). Yanking a rectangle is the opposite of killing | 750 | (@code{yank-rectangle}). The rectangle's first line is inserted at |
| 751 | one. Point specifies where to put the rectangle's upper left corner. | 751 | point, the rectangle's second line is inserted at the same horizontal |
| 752 | The rectangle's first line is inserted there, the rectangle's second | 752 | position one line vertically below, and so on. The number of lines |
| 753 | line is inserted at the same horizontal position, but one line | 753 | affected is determined by the height of the saved rectangle. |
| 754 | vertically down, and so on. The number of lines affected is determined | 754 | |
| 755 | by the height of the saved rectangle. | 755 | For example, you can convert two single-column lists into a |
| 756 | 756 | double-column list by killing one of the single-column lists as a | |
| 757 | You can convert single-column lists into double-column lists using | 757 | rectangle, and then yanking it beside the other list. |
| 758 | rectangle killing and yanking; kill the second half of the list as a | ||
| 759 | rectangle and then yank it beside the first line of the list. | ||
| 760 | @xref{Two-Column}, for another way to edit multi-column text. | ||
| 761 | 758 | ||
| 762 | You can also copy rectangles into and out of registers with @kbd{C-x r | 759 | You can also copy rectangles into and out of registers with @kbd{C-x r |
| 763 | r @var{r}} and @kbd{C-x r i @var{r}}. @xref{Rectangle Registers}. | 760 | r @var{r}} and @kbd{C-x r i @var{r}}. @xref{Rectangle Registers}. |
| @@ -767,17 +764,26 @@ r @var{r}} and @kbd{C-x r i @var{r}}. @xref{Rectangle Registers}. | |||
| 767 | @kindex C-x r c | 764 | @kindex C-x r c |
| 768 | @findex clear-rectangle | 765 | @findex clear-rectangle |
| 769 | There are two commands you can use for making blank rectangles: | 766 | There are two commands you can use for making blank rectangles: |
| 770 | @kbd{C-x r c} (@code{clear-rectangle}) which blanks out existing text, | 767 | @kbd{C-x r c} (@code{clear-rectangle}) blanks out existing text in the |
| 771 | and @kbd{C-x r o} (@code{open-rectangle}) which inserts a blank | 768 | region-rectangle, and @kbd{C-x r o} (@code{open-rectangle}) inserts a |
| 772 | rectangle. Clearing a rectangle is equivalent to deleting it and then | 769 | blank rectangle. |
| 773 | inserting a blank rectangle of the same size. | ||
| 774 | 770 | ||
| 775 | @findex delete-whitespace-rectangle | 771 | @findex delete-whitespace-rectangle |
| 776 | The command @kbd{M-x delete-whitespace-rectangle} deletes horizontal | 772 | @kbd{M-x delete-whitespace-rectangle} deletes horizontal whitespace |
| 777 | whitespace starting from a particular column. This applies to each of | 773 | starting from a particular column. This applies to each of the lines |
| 778 | the lines in the rectangle, and the column is specified by the left | 774 | in the rectangle, and the column is specified by the left edge of the |
| 779 | edge of the rectangle. The right edge of the rectangle does not make | 775 | rectangle. The right edge of the rectangle does not make any |
| 780 | any difference to this command. | 776 | difference to this command. |
| 777 | |||
| 778 | @kindex C-x r N | ||
| 779 | @findex rectangle | ||
| 780 | The command @kbd{C-x r N} (@code{rectangle-number-lines}) inserts | ||
| 781 | line numbers along the left edge of the region-rectangle. Normally, | ||
| 782 | the numbering begins from 1 (for the first line of the rectangle). | ||
| 783 | With a prefix argument, the command prompts for a number to begin | ||
| 784 | from, and for a format string with which to print the numbers | ||
| 785 | (@pxref{Formatting Strings,,, elisp, The Emacs Lisp Reference | ||
| 786 | Manual}). | ||
| 781 | 787 | ||
| 782 | @kindex C-x r t | 788 | @kindex C-x r t |
| 783 | @findex string-rectangle | 789 | @findex string-rectangle |
| @@ -801,18 +807,25 @@ shifting the original text to the right. | |||
| 801 | @vindex cua-enable-cua-keys | 807 | @vindex cua-enable-cua-keys |
| 802 | The command @kbd{M-x cua-mode} sets up key bindings that are | 808 | The command @kbd{M-x cua-mode} sets up key bindings that are |
| 803 | compatible with the Common User Access (CUA) system used in many other | 809 | compatible with the Common User Access (CUA) system used in many other |
| 804 | applications. @kbd{C-x} means cut (kill), @kbd{C-c} copy, @kbd{C-v} | 810 | applications. |
| 805 | paste (yank), and @kbd{C-z} undo. Standard Emacs commands like | 811 | |
| 806 | @kbd{C-x C-c} still work, because @kbd{C-x} and @kbd{C-c} only take | 812 | When CUA mode is enabled, the keys @kbd{C-x}, @kbd{C-c}, @kbd{C-v}, |
| 807 | effect when the mark is active (and the region is highlighted). | 813 | and @kbd{C-z} invoke commands that cut (kill), copy, paste (yank), and |
| 808 | However, if you don't want to override these bindings in Emacs at all, | 814 | undo respectively. The @kbd{C-x} and @kbd{C-c} keys perform cut and |
| 809 | set @code{cua-enable-cua-keys} to @code{nil}. | 815 | copy only if the region is active. Otherwise, they still act as |
| 816 | prefix keys, so that standard Emacs commands like @kbd{C-x C-c} still | ||
| 817 | work. Note that this means the variable @code{mark-even-if-inactive} | ||
| 818 | has no effect for @kbd{C-x} and @kbd{C-c} (@pxref{Using Region}). | ||
| 810 | 819 | ||
| 811 | To enter an Emacs command like @kbd{C-x C-f} while the mark is | 820 | To enter an Emacs command like @kbd{C-x C-f} while the mark is |
| 812 | active, use one of the following methods: either hold @kbd{Shift} | 821 | active, use one of the following methods: either hold @kbd{Shift} |
| 813 | together with the prefix key, e.g. @kbd{S-C-x C-f}, or quickly type | 822 | together with the prefix key, e.g. @kbd{S-C-x C-f}, or quickly type |
| 814 | the prefix key twice, e.g. @kbd{C-x C-x C-f}. | 823 | the prefix key twice, e.g. @kbd{C-x C-x C-f}. |
| 815 | 824 | ||
| 825 | To disable the overriding of standard Emacs binding by CUA mode, | ||
| 826 | while retaining the other features of CUA mode described below, set | ||
| 827 | the variable @code{cua-enable-cua-keys} to @code{nil}. | ||
| 828 | |||
| 816 | In CUA mode, typed text replaces the active region as in | 829 | In CUA mode, typed text replaces the active region as in |
| 817 | Delete-Selection mode (@pxref{Mouse Commands}). | 830 | Delete-Selection mode (@pxref{Mouse Commands}). |
| 818 | 831 | ||
diff --git a/doc/emacs/mark.texi b/doc/emacs/mark.texi index 21d90a3fc79..0eccef41711 100644 --- a/doc/emacs/mark.texi +++ b/doc/emacs/mark.texi | |||
| @@ -16,18 +16,22 @@ The region always extends between point and the mark, no matter which | |||
| 16 | one comes earlier in the text; each time you move point, the region | 16 | one comes earlier in the text; each time you move point, the region |
| 17 | changes. | 17 | changes. |
| 18 | 18 | ||
| 19 | @cindex active region | ||
| 19 | Setting the mark at a position in the text also @dfn{activates} it. | 20 | Setting the mark at a position in the text also @dfn{activates} it. |
| 20 | When the mark is active, Emacs indicates the extent of the region by | 21 | When the mark is active, we say also that the region is active; Emacs |
| 21 | highlighting the text within it, using the @code{region} face | 22 | indicates its extent by highlighting the text within it, using the |
| 22 | (@pxref{Face Customization}). After certain non-motion commands, | 23 | @code{region} face (@pxref{Face Customization}). |
| 23 | including any command that changes the text in the buffer, Emacs | 24 | |
| 24 | automatically @dfn{deactivates} the mark; this turns off the | 25 | After certain non-motion commands, including any command that |
| 25 | highlighting. You can also explicitly deactivate the mark at any | 26 | changes the text in the buffer, Emacs automatically @dfn{deactivates} |
| 26 | time, by typing @kbd{C-g} (@pxref{Quitting}). | 27 | the mark; this turns off the highlighting. You can also explicitly |
| 27 | 28 | deactivate the mark at any time, by typing @kbd{C-g} | |
| 28 | This default behavior is known as Transient Mark mode. Disabling | 29 | (@pxref{Quitting}). |
| 29 | Transient Mark mode switches Emacs to an alternative behavior, in | 30 | |
| 30 | which the region is usually not highlighted. @xref{Disabled Transient Mark}. | 31 | The above default behavior is known as Transient Mark mode. |
| 32 | Disabling Transient Mark mode switches Emacs to an alternative | ||
| 33 | behavior, in which the region is usually not highlighted. | ||
| 34 | @xref{Disabled Transient Mark}. | ||
| 31 | 35 | ||
| 32 | @vindex highlight-nonselected-windows | 36 | @vindex highlight-nonselected-windows |
| 33 | Setting the mark in one buffer has no effect on the marks in other | 37 | Setting the mark in one buffer has no effect on the marks in other |
| @@ -141,10 +145,10 @@ can tell that a command does this when it shows @samp{Mark set} in the | |||
| 141 | echo area. | 145 | echo area. |
| 142 | 146 | ||
| 143 | @cindex primary selection | 147 | @cindex primary selection |
| 144 | Under X, every time the region changes while the mark is active, | 148 | Under X, every time the active region changes, Emacs saves the text |
| 145 | Emacs saves the text in the region to the @dfn{primary selection}. | 149 | in the region to the @dfn{primary selection}. This lets you insert |
| 146 | This lets you insert that text into other X applications with | 150 | that text into other X applications with @kbd{mouse-2} clicks. |
| 147 | @kbd{mouse-2} clicks. @xref{Primary Selection}. | 151 | @xref{Primary Selection}. |
| 148 | 152 | ||
| 149 | @node Marking Objects | 153 | @node Marking Objects |
| 150 | @section Commands to Mark Textual Objects | 154 | @section Commands to Mark Textual Objects |
| @@ -243,18 +247,30 @@ Save it in a buffer or a file (@pxref{Accumulating Text}). | |||
| 243 | @end itemize | 247 | @end itemize |
| 244 | 248 | ||
| 245 | Some commands have a default behavior when the mark is inactive, but | 249 | Some commands have a default behavior when the mark is inactive, but |
| 246 | operate on the text in the region if the mark is active. For example, | 250 | operate on the region if the mark is active. For example, @kbd{M-$} |
| 247 | @kbd{M-$} (@code{ispell-word}) normally checks the spelling of the | 251 | (@code{ispell-word}) normally checks the spelling of the word at |
| 248 | word at point, but it checks the text in the region if the region is | 252 | point, but it checks the text in the region if the mark is active |
| 249 | active (@pxref{Spelling}). Normally, such commands use their default | 253 | (@pxref{Spelling}). Normally, such commands use their default |
| 250 | behavior if the region is empty (i.e., if mark and point are at the | 254 | behavior if the region is empty (i.e., if mark and point are at the |
| 251 | same position). If you want them to operate on the empty region, | 255 | same position). If you want them to operate on the empty region, |
| 252 | change the variable @code{use-empty-active-region} to @code{t}. | 256 | change the variable @code{use-empty-active-region} to @code{t}. |
| 253 | 257 | ||
| 258 | @vindex delete-active-region | ||
| 259 | As described in @ref{Erasing}, the @key{DEL} | ||
| 260 | (@code{backward-delete-char}) and @key{delete} | ||
| 261 | (@code{delete-forward-char}) commands also act this way. If the mark | ||
| 262 | is active, they delete the text in the region. (As an exception, if | ||
| 263 | you supply a numeric argument @var{n}, where @var{n} is not one, these | ||
| 264 | commands delete @var{n} characters regardless of whether the mark is | ||
| 265 | active). If you change the variable @code{delete-active-region} to | ||
| 266 | @code{nil}, then these commands don't act differently when the mark is | ||
| 267 | active. If you change the value to @code{kill}, these commands | ||
| 268 | @dfn{kill} the region instead of deleting it (@pxref{Killing}). | ||
| 269 | |||
| 254 | @vindex mark-even-if-inactive | 270 | @vindex mark-even-if-inactive |
| 255 | Other commands always operate on the text in the region, and have no | 271 | Other commands always operate on the region, and have no default |
| 256 | default behavior. Such commands usually have the word @code{region} | 272 | behavior. Such commands usually have the word @code{region} in their |
| 257 | in their names, like @kbd{C-w} (@code{kill-region}) and @code{C-x C-u} | 273 | names, like @kbd{C-w} (@code{kill-region}) and @code{C-x C-u} |
| 258 | (@code{upcase-region}). If the mark is inactive, they operate on the | 274 | (@code{upcase-region}). If the mark is inactive, they operate on the |
| 259 | ``inactive region''---that is, on the text between point and the | 275 | ``inactive region''---that is, on the text between point and the |
| 260 | position at which the mark was last set (@pxref{Mark Ring}). To | 276 | position at which the mark was last set (@pxref{Mark Ring}). To |
diff --git a/doc/emacs/mule.texi b/doc/emacs/mule.texi index 29b6c69e38f..f676f0b96ce 100644 --- a/doc/emacs/mule.texi +++ b/doc/emacs/mule.texi | |||
| @@ -81,8 +81,8 @@ appropriate keyboard coding system (@pxref{Terminal Coding}), and Emacs | |||
| 81 | will accept those characters. Latin-1 characters can also be input by | 81 | will accept those characters. Latin-1 characters can also be input by |
| 82 | using the @kbd{C-x 8} prefix, see @ref{Unibyte Mode}. | 82 | using the @kbd{C-x 8} prefix, see @ref{Unibyte Mode}. |
| 83 | 83 | ||
| 84 | On X Window systems, your locale should be set to an appropriate value | 84 | On the X Window System, your locale should be set to an appropriate |
| 85 | to make sure Emacs interprets keyboard input correctly; see | 85 | value to make sure Emacs interprets keyboard input correctly; see |
| 86 | @ref{Language Environments, locales}. | 86 | @ref{Language Environments, locales}. |
| 87 | @end itemize | 87 | @end itemize |
| 88 | 88 | ||
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index fa5aac6e9ec..345e69e6989 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2011-10-13 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * text.texi (Yanking): Document yank-excluded-properties. | ||
| 4 | |||
| 5 | * package.texi (Packaging Basics): The commentary should say how | ||
| 6 | to begin using the package. | ||
| 7 | |||
| 1 | 2011-10-11 Martin Rudalics <rudalics@gmx.at> | 8 | 2011-10-11 Martin Rudalics <rudalics@gmx.at> |
| 2 | 9 | ||
| 3 | * windows.texi (Deleting Windows): Mention which window gets | 10 | * windows.texi (Deleting Windows): Mention which window gets |
diff --git a/doc/lispref/package.texi b/doc/lispref/package.texi index 62fbc2a9a07..5533f8ab5fa 100644 --- a/doc/lispref/package.texi +++ b/doc/lispref/package.texi | |||
| @@ -63,7 +63,8 @@ should occupy a single line, ideally in 36 characters or less. | |||
| 63 | This is shown in the buffer created by @kbd{C-h P} | 63 | This is shown in the buffer created by @kbd{C-h P} |
| 64 | (@code{describe-package}), following the package's brief description | 64 | (@code{describe-package}), following the package's brief description |
| 65 | and installation status. It normally spans multiple lines, and should | 65 | and installation status. It normally spans multiple lines, and should |
| 66 | fully describe the package and its capabilities. | 66 | fully describe the package's capabilities and how to begin using it |
| 67 | once it is installed. | ||
| 67 | 68 | ||
| 68 | @item Dependencies | 69 | @item Dependencies |
| 69 | A list of other packages (possibly including minimal acceptable | 70 | A list of other packages (possibly including minimal acceptable |
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi index 2348e3706dc..3a081dddc61 100644 --- a/doc/lispref/text.texi +++ b/doc/lispref/text.texi | |||
| @@ -907,10 +907,11 @@ text that they copy into the buffer. | |||
| 907 | 907 | ||
| 908 | @defun insert-for-yank string | 908 | @defun insert-for-yank string |
| 909 | This function normally works like @code{insert} except that it doesn't | 909 | This function normally works like @code{insert} except that it doesn't |
| 910 | insert the text properties in the @code{yank-excluded-properties} | 910 | insert the text properties (@pxref{Text Properties}) in the list |
| 911 | list. However, if any part of @var{string} has a non-@code{nil} | 911 | variable @code{yank-excluded-properties}. However, if any part of |
| 912 | @code{yank-handler} text property, that property can do various | 912 | @var{string} has a non-@code{nil} @code{yank-handler} text property, |
| 913 | special processing on that part of the text being inserted. | 913 | that property can do various special processing on that part of the |
| 914 | text being inserted. | ||
| 914 | @end defun | 915 | @end defun |
| 915 | 916 | ||
| 916 | @defun insert-buffer-substring-as-yank buf &optional start end | 917 | @defun insert-buffer-substring-as-yank buf &optional start end |
| @@ -958,6 +959,15 @@ region. @var{function} can set @code{yank-undo-function} to override | |||
| 958 | the @var{undo} value. | 959 | the @var{undo} value. |
| 959 | @end table | 960 | @end table |
| 960 | 961 | ||
| 962 | @cindex yanking and text properties | ||
| 963 | @defopt yank-excluded-properties | ||
| 964 | Yanking discards certain text properties from the yanked text, as | ||
| 965 | described above. The value of this variable is the list of properties | ||
| 966 | to discard. Its default value contains properties that might lead to | ||
| 967 | annoying results, such as causing the text to respond to the mouse or | ||
| 968 | specifying key bindings. | ||
| 969 | @end defopt | ||
| 970 | |||
| 961 | @node Yank Commands | 971 | @node Yank Commands |
| 962 | @comment node-name, next, previous, up | 972 | @comment node-name, next, previous, up |
| 963 | @subsection Functions for Yanking | 973 | @subsection Functions for Yanking |
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog index 294c6472000..02c2d2b8750 100644 --- a/doc/misc/ChangeLog +++ b/doc/misc/ChangeLog | |||
| @@ -1,3 +1,16 @@ | |||
| 1 | 2011-10-14 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * ert.texi (Introduction, How to Run Tests) | ||
| 4 | (Running Tests Interactively, Expected Failures) | ||
| 5 | (Tests and Their Environment, Useful Techniques) | ||
| 6 | (Interactive Debugging, Fixtures and Test Suites): | ||
| 7 | Minor rephrasings. | ||
| 8 | (Running Tests Interactively, The @code{should} Macro): Add xrefs. | ||
| 9 | (Running Tests in Batch Mode): Simplify loading instructions. | ||
| 10 | (Test Selectors): Clarify some selectors. | ||
| 11 | (Expected Failures, Useful Techniques): | ||
| 12 | Make examples fit in 80 columns. | ||
| 13 | |||
| 1 | 2011-10-13 Jay Belanger <jay.p.belanger@gmail.com> | 14 | 2011-10-13 Jay Belanger <jay.p.belanger@gmail.com> |
| 2 | 15 | ||
| 3 | * calc.texi (Basic Operations on Units): Discuss temperature | 16 | * calc.texi (Basic Operations on Units): Discuss temperature |
diff --git a/doc/misc/ert.texi b/doc/misc/ert.texi index c9b624c6767..d1cecf1347a 100644 --- a/doc/misc/ert.texi +++ b/doc/misc/ert.texi | |||
| @@ -82,8 +82,8 @@ Extending ERT | |||
| 82 | 82 | ||
| 83 | Other Testing Concepts | 83 | Other Testing Concepts |
| 84 | 84 | ||
| 85 | * Mocks and Stubs:: Stubbing out code that is irrelevant to the test. | 85 | * Mocks and Stubs:: Stubbing out code that is irrelevant to the test. |
| 86 | * Fixtures and Test Suites:: How ERT differs from tools for other languages. | 86 | * Fixtures and Test Suites:: How ERT differs from tools for other languages. |
| 87 | 87 | ||
| 88 | @end detailmenu | 88 | @end detailmenu |
| 89 | @end menu | 89 | @end menu |
| @@ -133,8 +133,8 @@ will pass if the three calls to @code{equal} all return true | |||
| 133 | @code{should} is a macro with the same meaning as @code{assert} but | 133 | @code{should} is a macro with the same meaning as @code{assert} but |
| 134 | better error reporting. @xref{The @code{should} Macro}. | 134 | better error reporting. @xref{The @code{should} Macro}. |
| 135 | 135 | ||
| 136 | Each test should have a name that describes what functionality the | 136 | Each test should have a name that describes what functionality it tests. |
| 137 | test tests. Test names can be chosen arbitrarily --- they are in a | 137 | Test names can be chosen arbitrarily --- they are in a |
| 138 | namespace separate from functions and variables --- but should follow | 138 | namespace separate from functions and variables --- but should follow |
| 139 | the usual Emacs Lisp convention of having a prefix that indicates | 139 | the usual Emacs Lisp convention of having a prefix that indicates |
| 140 | which package they belong to. Test names are displayed by ERT when | 140 | which package they belong to. Test names are displayed by ERT when |
| @@ -142,7 +142,7 @@ reporting failures and can be used when selecting which tests to run. | |||
| 142 | 142 | ||
| 143 | The empty parentheses @code{()} in the first line don't currently have | 143 | The empty parentheses @code{()} in the first line don't currently have |
| 144 | any meaning and are reserved for future extension. They also make | 144 | any meaning and are reserved for future extension. They also make |
| 145 | @code{ert-deftest}'s syntax more similar to @code{defun}. | 145 | the syntax of @code{ert-deftest} more similar to that of @code{defun}. |
| 146 | 146 | ||
| 147 | The docstring describes what feature this test tests. When running | 147 | The docstring describes what feature this test tests. When running |
| 148 | tests interactively, the first line of the docstring is displayed for | 148 | tests interactively, the first line of the docstring is displayed for |
| @@ -163,14 +163,14 @@ You can run tests either in the Emacs you are working in, or on the | |||
| 163 | command line in a separate Emacs process in batch mode (i.e., with no | 163 | command line in a separate Emacs process in batch mode (i.e., with no |
| 164 | user interface). The former mode is convenient during interactive | 164 | user interface). The former mode is convenient during interactive |
| 165 | development, the latter is useful to make sure that tests pass | 165 | development, the latter is useful to make sure that tests pass |
| 166 | independently of your customizations, allows tests to be invoked from | 166 | independently of your customizations; and it allows you to invoke |
| 167 | makefiles and scripts to be written that run tests in several | 167 | tests from makefiles, and to write scripts that run tests in several |
| 168 | different Emacs versions. | 168 | different Emacs versions. |
| 169 | 169 | ||
| 170 | @menu | 170 | @menu |
| 171 | * Running Tests Interactively:: Run tests in your current Emacs. | 171 | * Running Tests Interactively:: Run tests in your current Emacs. |
| 172 | * Running Tests in Batch Mode:: Run tests in emacs -Q. | 172 | * Running Tests in Batch Mode:: Run tests in emacs -Q. |
| 173 | * Test Selectors:: Choose which tests to run. | 173 | * Test Selectors:: Choose which tests to run. |
| 174 | @end menu | 174 | @end menu |
| 175 | 175 | ||
| 176 | 176 | ||
| @@ -178,7 +178,8 @@ different Emacs versions. | |||
| 178 | @section Running Tests Interactively | 178 | @section Running Tests Interactively |
| 179 | 179 | ||
| 180 | You can run the tests that are currently defined in your Emacs with | 180 | You can run the tests that are currently defined in your Emacs with |
| 181 | the command @kbd{@kbd{M-x} ert @kbd{RET} t @kbd{RET}}. ERT will pop | 181 | the command @kbd{@kbd{M-x} ert @kbd{RET} t @kbd{RET}}. (For an |
| 182 | explanation of the @code{t} argument, @pxref{Test Selectors}.) ERT will pop | ||
| 182 | up a new buffer, the ERT results buffer, showing the results of the | 183 | up a new buffer, the ERT results buffer, showing the results of the |
| 183 | tests run. It looks like this: | 184 | tests run. It looks like this: |
| 184 | 185 | ||
| @@ -219,10 +220,10 @@ F list-test | |||
| 219 | (different-atoms c d)))) | 220 | (different-atoms c d)))) |
| 220 | @end example | 221 | @end example |
| 221 | 222 | ||
| 222 | At the top, there is a summary of the results: We ran all tests in the | 223 | At the top, there is a summary of the results: we ran all tests defined |
| 223 | current Emacs (@code{Selector: t}), 31 of them passed, and 2 failed | 224 | in the current Emacs (@code{Selector: t}), 31 of them passed, and 2 |
| 224 | unexpectedly. @xref{Expected Failures}, for an explanation of the | 225 | failed unexpectedly. @xref{Expected Failures}, for an explanation of |
| 225 | term @emph{unexpected} in this context. | 226 | the term @emph{unexpected} in this context. |
| 226 | 227 | ||
| 227 | The line of dots and @code{F}s is a progress bar where each character | 228 | The line of dots and @code{F}s is a progress bar where each character |
| 228 | represents one test; it fills while the tests are running. A dot | 229 | represents one test; it fills while the tests are running. A dot |
| @@ -261,7 +262,7 @@ scripts or makefiles. There are two functions for this purpose, | |||
| 261 | They can be used like this: | 262 | They can be used like this: |
| 262 | 263 | ||
| 263 | @example | 264 | @example |
| 264 | emacs -batch -L /path/to/ert -l ert.el -l my-tests.el -f ert-run-tests-batch-and-exit | 265 | emacs -batch -l ert -l my-tests.el -f ert-run-tests-batch-and-exit |
| 265 | @end example | 266 | @end example |
| 266 | 267 | ||
| 267 | This command will start up Emacs in batch mode, load ERT, load | 268 | This command will start up Emacs in batch mode, load ERT, load |
| @@ -270,9 +271,10 @@ with a zero exit status if all tests passed, or nonzero if any tests | |||
| 270 | failed or if anything else went wrong. It will also print progress | 271 | failed or if anything else went wrong. It will also print progress |
| 271 | messages and error diagnostics to standard output. | 272 | messages and error diagnostics to standard output. |
| 272 | 273 | ||
| 273 | You may need additional @code{-L} flags to ensure that | 274 | If ERT is not part of your Emacs distribution, you may need to use |
| 274 | @code{my-tests.el} and all the files that it requires are on your | 275 | @code{-L /path/to/ert/} so that Emacs can find it. You may need |
| 275 | @code{load-path}. | 276 | additional @code{-L} flags to ensure that @code{my-tests.el} and all the |
| 277 | files that it requires are on your @code{load-path}. | ||
| 276 | 278 | ||
| 277 | 279 | ||
| 278 | @node Test Selectors, , Running Tests in Batch Mode, How to Run Tests | 280 | @node Test Selectors, , Running Tests in Batch Mode, How to Run Tests |
| @@ -288,23 +290,26 @@ to Common Lisp's type specifier syntax: | |||
| 288 | @item @code{:new} selects all tests that have not been run yet. | 290 | @item @code{:new} selects all tests that have not been run yet. |
| 289 | @item @code{:failed} and @code{:passed} select tests according to their most recent result. | 291 | @item @code{:failed} and @code{:passed} select tests according to their most recent result. |
| 290 | @item @code{:expected}, @code{:unexpected} select tests according to their most recent result. | 292 | @item @code{:expected}, @code{:unexpected} select tests according to their most recent result. |
| 291 | @item A string selects all tests that have a name that matches the string, a regexp. | 293 | @item A string is a regular expression that selects all tests with matching names. |
| 292 | @item A test selects that test. | 294 | @item A test (i.e., an object of @code{ert-test} data type) selects that test. |
| 293 | @item A symbol selects the test that the symbol names. | 295 | @item A symbol selects the test that the symbol names. |
| 294 | @item @code{(member TESTS...)} selects TESTS, a list of tests or symbols naming tests. | 296 | @item @code{(member TESTS...)} selects the elements of TESTS, a list of |
| 297 | tests or symbols naming tests. | ||
| 295 | @item @code{(eql TEST)} selects TEST, a test or a symbol naming a test. | 298 | @item @code{(eql TEST)} selects TEST, a test or a symbol naming a test. |
| 296 | @item @code{(and SELECTORS...)} selects the tests that match all SELECTORS. | 299 | @item @code{(and SELECTORS...)} selects the tests that match all SELECTORS. |
| 297 | @item @code{(or SELECTORS...)} selects the tests that match any SELECTOR. | 300 | @item @code{(or SELECTORS...)} selects the tests that match any SELECTOR. |
| 298 | @item @code{(not SELECTOR)} selects all tests that do not match SELECTOR. | 301 | @item @code{(not SELECTOR)} selects all tests that do not match SELECTOR. |
| 299 | @item @code{(tag TAG)} selects all tests that have TAG on their tags list. | 302 | @item @code{(tag TAG)} selects all tests that have TAG on their tags list. |
| 300 | @item @code{(satisfies PREDICATE)} Selects all tests that satisfy PREDICATE. | 303 | (Tags are optional labels you can apply to tests when you define them.) |
| 304 | @item @code{(satisfies PREDICATE)} selects all tests that satisfy PREDICATE, | ||
| 305 | a function that takes a test as argument and returns non-nil if it is selected. | ||
| 301 | @end itemize | 306 | @end itemize |
| 302 | 307 | ||
| 303 | Selectors that are frequently useful when selecting tests to run | 308 | Selectors that are frequently useful when selecting tests to run |
| 304 | include @code{t} to run all tests that are currently defined in Emacs, | 309 | include @code{t} to run all tests that are currently defined in Emacs, |
| 305 | @code{"^foo-"} to run all tests in package @code{foo} --- this assumes | 310 | @code{"^foo-"} to run all tests in package @code{foo} (this assumes |
| 306 | that package @code{foo} uses the prefix @code{foo-} for its test names | 311 | that package @code{foo} uses the prefix @code{foo-} for its test names), |
| 307 | ---, result-based selectors such as @code{(or :new :unexpected)} to | 312 | result-based selectors such as @code{(or :new :unexpected)} to |
| 308 | run all tests that have either not run yet or that had an unexpected | 313 | run all tests that have either not run yet or that had an unexpected |
| 309 | result in the last run, and tag-based selectors such as @code{(not | 314 | result in the last run, and tag-based selectors such as @code{(not |
| 310 | (tag :causes-redisplay))} to run all tests that are not tagged | 315 | (tag :causes-redisplay))} to run all tests that are not tagged |
| @@ -325,9 +330,9 @@ to find where a test was defined if the test was loaded from a file. | |||
| 325 | 330 | ||
| 326 | 331 | ||
| 327 | @menu | 332 | @menu |
| 328 | * The @code{should} Macro:: A powerful way to express assertions. | 333 | * The @code{should} Macro:: A powerful way to express assertions. |
| 329 | * Expected Failures:: Tests for known bugs. | 334 | * Expected Failures:: Tests for known bugs. |
| 330 | * Tests and Their Environment:: Don't depend on customizations; no side effects. | 335 | * Tests and Their Environment:: Don't depend on customizations; no side effects. |
| 331 | * Useful Techniques:: Some examples. | 336 | * Useful Techniques:: Some examples. |
| 332 | @end menu | 337 | @end menu |
| 333 | 338 | ||
| @@ -335,10 +340,12 @@ to find where a test was defined if the test was loaded from a file. | |||
| 335 | @section The @code{should} Macro | 340 | @section The @code{should} Macro |
| 336 | 341 | ||
| 337 | Test bodies can include arbitrary code; but to be useful, they need to | 342 | Test bodies can include arbitrary code; but to be useful, they need to |
| 338 | have checks whether the code being tested (or @emph{code under test}) | 343 | check whether the code being tested (or @emph{code under test}) |
| 339 | does what it is supposed to do. The macro @code{should} is similar to | 344 | does what it is supposed to do. The macro @code{should} is similar to |
| 340 | @code{assert} from the cl package, but analyzes its argument form and | 345 | @code{assert} from the cl package |
| 341 | records information that ERT can display to help debugging. | 346 | (@pxref{Assertions,,, cl, Common Lisp Extensions}), |
| 347 | but analyzes its argument form and records information that ERT can | ||
| 348 | display to help debugging. | ||
| 342 | 349 | ||
| 343 | This test definition | 350 | This test definition |
| 344 | 351 | ||
| @@ -396,7 +403,7 @@ default. | |||
| 396 | @node Expected Failures, Tests and Their Environment, The @code{should} Macro, How to Write Tests | 403 | @node Expected Failures, Tests and Their Environment, The @code{should} Macro, How to Write Tests |
| 397 | @section Expected Failures | 404 | @section Expected Failures |
| 398 | 405 | ||
| 399 | Some bugs are complicated to fix or not very important and are left as | 406 | Some bugs are complicated to fix, or not very important, and are left as |
| 400 | @emph{known bugs}. If there is a test case that triggers the bug and | 407 | @emph{known bugs}. If there is a test case that triggers the bug and |
| 401 | fails, ERT will alert you of this failure every time you run all | 408 | fails, ERT will alert you of this failure every time you run all |
| 402 | tests. For known bugs, this alert is a distraction. The way to | 409 | tests. For known bugs, this alert is a distraction. The way to |
| @@ -406,7 +413,7 @@ definition: | |||
| 406 | @lisp | 413 | @lisp |
| 407 | (ert-deftest future-bug () | 414 | (ert-deftest future-bug () |
| 408 | "Test `time-forward' with negative arguments. | 415 | "Test `time-forward' with negative arguments. |
| 409 | Since this functionality isn't implemented yet, the test is known to fail." | 416 | Since this functionality isn't implemented, the test is known to fail." |
| 410 | :expected-result :failed | 417 | :expected-result :failed |
| 411 | (time-forward -1)) | 418 | (time-forward -1)) |
| 412 | @end lisp | 419 | @end lisp |
| @@ -427,7 +434,7 @@ makes it much easier to fix the bug, demonstrate that it is fixed, and | |||
| 427 | prevent future regressions. | 434 | prevent future regressions. |
| 428 | 435 | ||
| 429 | ERT displays the same kind of alerts for tests that pass unexpectedly | 436 | ERT displays the same kind of alerts for tests that pass unexpectedly |
| 430 | that it displays for unexpected failures. This way, if you make code | 437 | as it displays for unexpected failures. This way, if you make code |
| 431 | changes that happen to fix a bug that you weren't aware of, you will | 438 | changes that happen to fix a bug that you weren't aware of, you will |
| 432 | know to remove the @code{:expected-result} clause of that test and | 439 | know to remove the @code{:expected-result} clause of that test and |
| 433 | close the corresponding bug report, if any. | 440 | close the corresponding bug report, if any. |
| @@ -453,8 +460,8 @@ The outcome of running a test should not depend on the current state | |||
| 453 | of the environment, and each test should leave its environment in the | 460 | of the environment, and each test should leave its environment in the |
| 454 | same state it found it in. In particular, a test should not depend on | 461 | same state it found it in. In particular, a test should not depend on |
| 455 | any Emacs customization variables or hooks, and if it has to make any | 462 | any Emacs customization variables or hooks, and if it has to make any |
| 456 | changes to Emacs' state or state external to Emacs such as the file | 463 | changes to Emacs's state or state external to Emacs (such as the file |
| 457 | system, it should undo these changes before it returns, regardless of | 464 | system), it should undo these changes before it returns, regardless of |
| 458 | whether it passed or failed. | 465 | whether it passed or failed. |
| 459 | 466 | ||
| 460 | Tests should not depend on the environment because any such | 467 | Tests should not depend on the environment because any such |
| @@ -462,14 +469,14 @@ dependencies can make the test brittle or lead to failures that occur | |||
| 462 | only under certain circumstances and are hard to reproduce. Of | 469 | only under certain circumstances and are hard to reproduce. Of |
| 463 | course, the code under test may have settings that affect its | 470 | course, the code under test may have settings that affect its |
| 464 | behavior. In that case, it is best to make the test @code{let}-bind | 471 | behavior. In that case, it is best to make the test @code{let}-bind |
| 465 | all such settings variables to set up a specific configuration for the | 472 | all such setting variables to set up a specific configuration for the |
| 466 | duration of the test. The test can also set up a number of different | 473 | duration of the test. The test can also set up a number of different |
| 467 | configurations and run the code under test with each. | 474 | configurations and run the code under test with each. |
| 468 | 475 | ||
| 469 | Tests that have side effects on their environment should restore it to | 476 | Tests that have side effects on their environment should restore it to |
| 470 | its original state because any side effects that persist after the | 477 | its original state because any side effects that persist after the |
| 471 | test can disrupt the workflow of the programmer running the tests. If | 478 | test can disrupt the workflow of the programmer running the tests. If |
| 472 | the code under test has side effects on Emacs' current state, such as | 479 | the code under test has side effects on Emacs's current state, such as |
| 473 | on the current buffer or window configuration, the test should create | 480 | on the current buffer or window configuration, the test should create |
| 474 | a temporary buffer for the code to manipulate (using | 481 | a temporary buffer for the code to manipulate (using |
| 475 | @code{with-temp-buffer}), or save and restore the window configuration | 482 | @code{with-temp-buffer}), or save and restore the window configuration |
| @@ -490,13 +497,13 @@ such commands are what they want to test. The exact behavior of | |||
| 490 | @code{auto-mode-alist}. It is difficult to write a meaningful test if | 497 | @code{auto-mode-alist}. It is difficult to write a meaningful test if |
| 491 | its behavior can be affected by so many external factors. Also, | 498 | its behavior can be affected by so many external factors. Also, |
| 492 | @code{find-file} has side effects that are hard to predict and thus | 499 | @code{find-file} has side effects that are hard to predict and thus |
| 493 | hard to undo: It may create a new buffer or may reuse an existing | 500 | hard to undo: It may create a new buffer or reuse an existing |
| 494 | buffer if one is already visiting the requested file; and it runs | 501 | buffer if one is already visiting the requested file; and it runs |
| 495 | @code{find-file-hook}, which can have arbitrary side effects. | 502 | @code{find-file-hook}, which can have arbitrary side effects. |
| 496 | 503 | ||
| 497 | Instead, it is better to use lower-level mechanisms with simple and | 504 | Instead, it is better to use lower-level mechanisms with simple and |
| 498 | predictable semantics like @code{with-temp-buffer}, @code{insert} or | 505 | predictable semantics like @code{with-temp-buffer}, @code{insert} or |
| 499 | @code{insert-file-contents-literally}, and activating the desired mode | 506 | @code{insert-file-contents-literally}, and to activate any desired mode |
| 500 | by calling the corresponding function directly --- after binding the | 507 | by calling the corresponding function directly --- after binding the |
| 501 | hook variables to nil. This avoids the above problems. | 508 | hook variables to nil. This avoids the above problems. |
| 502 | 509 | ||
| @@ -534,8 +541,10 @@ Here's a more complicated test: | |||
| 534 | (ert--print-backtrace (ert-test-failed-backtrace result)) | 541 | (ert--print-backtrace (ert-test-failed-backtrace result)) |
| 535 | (goto-char (point-min)) | 542 | (goto-char (point-min)) |
| 536 | (end-of-line) | 543 | (end-of-line) |
| 537 | (let ((first-line (buffer-substring-no-properties (point-min) (point)))) | 544 | (let ((first-line (buffer-substring-no-properties |
| 538 | (should (equal first-line " signal(ert-test-failed (\"foo\"))"))))))) | 545 | (point-min) (point)))) |
| 546 | (should (equal first-line | ||
| 547 | " signal(ert-test-failed (\"foo\"))"))))))) | ||
| 539 | @end lisp | 548 | @end lisp |
| 540 | 549 | ||
| 541 | This test creates a test object using @code{make-ert-test} whose body | 550 | This test creates a test object using @code{make-ert-test} whose body |
| @@ -562,7 +571,7 @@ under test was structured with testing in mind. | |||
| 562 | For example, if @code{ert-run-test} accepted only symbols that name | 571 | For example, if @code{ert-run-test} accepted only symbols that name |
| 563 | tests rather than test objects, the test would need a name for the | 572 | tests rather than test objects, the test would need a name for the |
| 564 | failing test, which would have to be a temporary symbol generated with | 573 | failing test, which would have to be a temporary symbol generated with |
| 565 | @code{make-symbol}, to avoid side effects on Emacs' state. Choosing | 574 | @code{make-symbol}, to avoid side effects on Emacs's state. Choosing |
| 566 | the right interface for @code{ert-run-tests} allows the test to be | 575 | the right interface for @code{ert-run-tests} allows the test to be |
| 567 | simpler. | 576 | simpler. |
| 568 | 577 | ||
| @@ -663,7 +672,7 @@ function registered. @xref{Defining Explanation Functions}. | |||
| 663 | @node Interactive Debugging, , Understanding Explanations, How to Debug Tests | 672 | @node Interactive Debugging, , Understanding Explanations, How to Debug Tests |
| 664 | @section Interactive Debugging | 673 | @section Interactive Debugging |
| 665 | 674 | ||
| 666 | Debugging failed tests works essentially the same way as debugging any | 675 | Debugging failed tests essentially works the same way as debugging any |
| 667 | other problems with Lisp code. Here are a few tricks specific to | 676 | other problems with Lisp code. Here are a few tricks specific to |
| 668 | tests: | 677 | tests: |
| 669 | 678 | ||
| @@ -673,8 +682,8 @@ each time. It's good to find out whether the behavior is | |||
| 673 | deterministic before spending any time looking for a cause. In the | 682 | deterministic before spending any time looking for a cause. In the |
| 674 | ERT results buffer, @kbd{r} re-runs the selected test. | 683 | ERT results buffer, @kbd{r} re-runs the selected test. |
| 675 | 684 | ||
| 676 | @item Use @kbd{.} to jump to the source code of the test to find out what | 685 | @item Use @kbd{.} to jump to the source code of the test to find out exactly |
| 677 | exactly it does. Perhaps the test is broken rather than the code | 686 | what it does. Perhaps the test is broken rather than the code |
| 678 | under test. | 687 | under test. |
| 679 | 688 | ||
| 680 | @item If the test contains a series of @code{should} forms and you can't | 689 | @item If the test contains a series of @code{should} forms and you can't |
| @@ -699,8 +708,8 @@ re-run the test with @kbd{r} or @kbd{d}. | |||
| 699 | @item If you have been editing and rearranging tests, it is possible that | 708 | @item If you have been editing and rearranging tests, it is possible that |
| 700 | ERT remembers an old test that you have since renamed or removed --- | 709 | ERT remembers an old test that you have since renamed or removed --- |
| 701 | renamings or removals of definitions in the source code leave around a | 710 | renamings or removals of definitions in the source code leave around a |
| 702 | stray definition under the old name in the running process, this is a | 711 | stray definition under the old name in the running process (this is a |
| 703 | common problem in Lisp. In such a situation, hit @kbd{D} to let ERT | 712 | common problem in Lisp). In such a situation, hit @kbd{D} to let ERT |
| 704 | forget about the obsolete test. | 713 | forget about the obsolete test. |
| 705 | @end itemize | 714 | @end itemize |
| 706 | 715 | ||
| @@ -739,14 +748,13 @@ explanation function. | |||
| 739 | 748 | ||
| 740 | Both @code{ert-run-tests-interactively} and @code{ert-run-tests-batch} | 749 | Both @code{ert-run-tests-interactively} and @code{ert-run-tests-batch} |
| 741 | are implemented on top of the lower-level test handling code in the | 750 | are implemented on top of the lower-level test handling code in the |
| 742 | sections named ``Facilities for running a single test'', ``Test | 751 | sections of @file{ert.el} labelled ``Facilities for running a single test'', |
| 743 | selectors'', and ``Facilities for running a whole set of tests''. | 752 | ``Test selectors'', and ``Facilities for running a whole set of tests''. |
| 744 | 753 | ||
| 745 | If you want to write code that works with ERT tests, you should take a | 754 | If you want to write code that works with ERT tests, you should take a |
| 746 | look at this lower-level code. Symbols that start with @code{ert--} | 755 | look at this lower-level code. Symbols that start with @code{ert--} |
| 747 | are internal to ERT, those that start with @code{ert-} but not | 756 | are internal to ERT, whereas those that start with @code{ert-} are |
| 748 | @code{ert--} are meant to be usable by other code. But there is no | 757 | meant to be usable by other code. But there is no mature API yet. |
| 749 | mature API yet. | ||
| 750 | 758 | ||
| 751 | Contributions to ERT are welcome. | 759 | Contributions to ERT are welcome. |
| 752 | 760 | ||
| @@ -758,8 +766,8 @@ For information on mocks, stubs, fixtures, or test suites, see below. | |||
| 758 | 766 | ||
| 759 | 767 | ||
| 760 | @menu | 768 | @menu |
| 761 | * Mocks and Stubs:: Stubbing out code that is irrelevant to the test. | 769 | * Mocks and Stubs:: Stubbing out code that is irrelevant to the test. |
| 762 | * Fixtures and Test Suites:: How ERT differs from tools for other languages. | 770 | * Fixtures and Test Suites:: How ERT differs from tools for other languages. |
| 763 | @end menu | 771 | @end menu |
| 764 | 772 | ||
| 765 | @node Mocks and Stubs, Fixtures and Test Suites, Other Testing Concepts, Other Testing Concepts | 773 | @node Mocks and Stubs, Fixtures and Test Suites, Other Testing Concepts, Other Testing Concepts |
| @@ -782,8 +790,8 @@ In many ways, ERT is similar to frameworks for other languages like | |||
| 782 | SUnit or JUnit. However, two features commonly found in such | 790 | SUnit or JUnit. However, two features commonly found in such |
| 783 | frameworks are notably absent from ERT: fixtures and test suites. | 791 | frameworks are notably absent from ERT: fixtures and test suites. |
| 784 | 792 | ||
| 785 | Fixtures, as used e.g. in SUnit or JUnit, are mainly used to provide | 793 | Fixtures are mainly used (e.g., in SUnit or JUnit) to provide an |
| 786 | an environment for a set of tests, and consist of set-up and tear-down | 794 | environment for a set of tests, and consist of set-up and tear-down |
| 787 | functions. | 795 | functions. |
| 788 | 796 | ||
| 789 | While fixtures are a useful syntactic simplification in other | 797 | While fixtures are a useful syntactic simplification in other |
| @@ -829,13 +837,13 @@ separating module namespaces in Emacs Lisp, test selectors already | |||
| 829 | solve this by allowing regexp matching on test names; e.g., the | 837 | solve this by allowing regexp matching on test names; e.g., the |
| 830 | selector "^ert-" selects ERT's self-tests. | 838 | selector "^ert-" selects ERT's self-tests. |
| 831 | 839 | ||
| 832 | Other uses include grouping tests by their expected execution time to | 840 | Other uses include grouping tests by their expected execution time, |
| 833 | run quick tests during interactive development and slow tests less | 841 | e.g. to run quick tests during interactive development and slow tests less |
| 834 | frequently. This can be achieved with the @code{:tag} argument to | 842 | often. This can be achieved with the @code{:tag} argument to |
| 835 | @code{ert-deftest} and @code{tag} test selectors. | 843 | @code{ert-deftest} and @code{tag} test selectors. |
| 836 | 844 | ||
| 837 | @bye | 845 | @bye |
| 838 | 846 | ||
| 839 | @c LocalWords: ERT Hagelberg Ohler JUnit namespace docstring ERT's | 847 | @c LocalWords: ERT JUnit namespace docstring ERT's |
| 840 | @c LocalWords: backtrace makefiles workflow backtraces API SUnit | 848 | @c LocalWords: backtrace makefiles workflow backtraces API SUnit |
| 841 | @c LocalWords: subexpressions | 849 | @c LocalWords: subexpressions |