diff options
| author | Richard M. Stallman | 2002-02-06 15:44:48 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2002-02-06 15:44:48 +0000 |
| commit | 108eaabb6b8fd0deb527e0b53b3d0cbf731e280a (patch) | |
| tree | 5229f6c6839cece2a33f4ea8651c61bf6ee130ff /etc | |
| parent | fa5c314daad6a222fb410abfed34e8e74266cc35 (diff) | |
| download | emacs-108eaabb6b8fd0deb527e0b53b3d0cbf731e280a.tar.gz emacs-108eaabb6b8fd0deb527e0b53b3d0cbf731e280a.zip | |
*** empty log message ***
Diffstat (limited to 'etc')
| -rw-r--r-- | etc/NEWS | 57 |
1 files changed, 57 insertions, 0 deletions
| @@ -416,6 +416,63 @@ SQL buffer. | |||
| 416 | 416 | ||
| 417 | * Lisp Changes in Emacs 21.3 | 417 | * Lisp Changes in Emacs 21.3 |
| 418 | 418 | ||
| 419 | ** Atomic change groups. | ||
| 420 | |||
| 421 | To perform some changes in the current buffer "atomically" so that | ||
| 422 | they either all succeed or are all undone, use `atomic-change-group' | ||
| 423 | around the code that makes changes. For instance: | ||
| 424 | |||
| 425 | (atomic-change-group | ||
| 426 | (insert foo) | ||
| 427 | (delete-region x y)) | ||
| 428 | |||
| 429 | If an error (or other nonlocal exit) occurs inside the body of | ||
| 430 | `atomic-change-group', it unmakes all the changes in that buffer that | ||
| 431 | were during the execution of the body. The change group has no effect | ||
| 432 | on any other buffers--any such changes remain. | ||
| 433 | |||
| 434 | If you need something more sophisticated, you can directly call the | ||
| 435 | lower-level functions that `atomic-change-group' uses. Here is how. | ||
| 436 | |||
| 437 | To set up a change group for one buffer, call `prepare-change-group'. | ||
| 438 | Specify the buffer as argument; it defaults to the current buffer. | ||
| 439 | This function returns a "handle" for the change group. You must save | ||
| 440 | the handle to activate the change group and then finish it. | ||
| 441 | |||
| 442 | Before you change the buffer again, you must activate the change | ||
| 443 | group. Pass the handle to `activate-change-group' afterward to | ||
| 444 | do this. | ||
| 445 | |||
| 446 | After you make the changes, you must finish the change group. You can | ||
| 447 | either accept the changes or cancel them all. Call | ||
| 448 | `accept-change-group' to accept the changes in the group as final; | ||
| 449 | call `cancel-change-group' to undo them all. | ||
| 450 | |||
| 451 | You should use `unwind-protect' to make sure the group is always | ||
| 452 | finished. The call to `activate-change-group' should be inside the | ||
| 453 | `unwind-protect', in case the user types C-g just after it runs. | ||
| 454 | (This is one reason why `prepare-change-group' and | ||
| 455 | `activate-change-group' are separate functions.) Once you finish the | ||
| 456 | group, don't use the handle again--don't try to finish the same group | ||
| 457 | twice. | ||
| 458 | |||
| 459 | To make a multibuffer change group, call `prepare-change-group' once | ||
| 460 | for each buffer you want to cover, then use `nconc' to combine the | ||
| 461 | returned values, like this: | ||
| 462 | |||
| 463 | (nconc (prepare-change-group buffer-1) | ||
| 464 | (prepare-change-group buffer-2)) | ||
| 465 | |||
| 466 | You can then activate the multibuffer change group with a single call | ||
| 467 | to `activate-change-group', and finish it with a single call to | ||
| 468 | `accept-change-group' or `cancel-change-group'. | ||
| 469 | |||
| 470 | Nested use of several change groups for the same buffer works as you | ||
| 471 | would expect. Non-nested use of change groups for the same buffer | ||
| 472 | will lead to undesirable results, so don't let it happen; the first | ||
| 473 | change group you start for any given buffer should be the last one | ||
| 474 | finished. | ||
| 475 | |||
| 419 | ** New function substring-no-properties. | 476 | ** New function substring-no-properties. |
| 420 | 477 | ||
| 421 | +++ | 478 | +++ |