diff options
| -rw-r--r-- | doc/lispref/text.texi | 41 | ||||
| -rw-r--r-- | etc/NEWS | 6 | ||||
| -rw-r--r-- | lisp/simple.el | 2 |
3 files changed, 32 insertions, 17 deletions
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi index 6d9d26f0ad1..2ceb3529689 100644 --- a/doc/lispref/text.texi +++ b/doc/lispref/text.texi | |||
| @@ -1343,27 +1343,38 @@ This function places a boundary element in the undo list. The undo | |||
| 1343 | command stops at such a boundary, and successive undo commands undo | 1343 | command stops at such a boundary, and successive undo commands undo |
| 1344 | to earlier and earlier boundaries. This function returns @code{nil}. | 1344 | to earlier and earlier boundaries. This function returns @code{nil}. |
| 1345 | 1345 | ||
| 1346 | The editor command loop automatically calls @code{undo-boundary} just | ||
| 1347 | before executing each key sequence, so that each undo normally undoes | ||
| 1348 | the effects of one command. As an exception, the command | ||
| 1349 | @code{self-insert-command}, which produces self-inserting input | ||
| 1350 | characters (@pxref{Commands for Insertion}), may remove the boundary | ||
| 1351 | inserted by the command loop: a boundary is accepted for the first | ||
| 1352 | such character, the next 19 consecutive self-inserting input | ||
| 1353 | characters do not have boundaries, and then the 20th does; and so on | ||
| 1354 | as long as the self-inserting characters continue. Hence, sequences | ||
| 1355 | of consecutive character insertions can be undone as a group. | ||
| 1356 | |||
| 1357 | All buffer modifications add a boundary whenever the previous undoable | ||
| 1358 | change was made in some other buffer. This is to ensure that | ||
| 1359 | each command makes a boundary in each buffer where it makes changes. | ||
| 1360 | |||
| 1361 | Calling this function explicitly is useful for splitting the effects of | 1346 | Calling this function explicitly is useful for splitting the effects of |
| 1362 | a command into more than one unit. For example, @code{query-replace} | 1347 | a command into more than one unit. For example, @code{query-replace} |
| 1363 | calls @code{undo-boundary} after each replacement, so that the user can | 1348 | calls @code{undo-boundary} after each replacement, so that the user can |
| 1364 | undo individual replacements one by one. | 1349 | undo individual replacements one by one. |
| 1350 | |||
| 1351 | Mostly, however, this function is called automatically at an | ||
| 1352 | appropriate time. | ||
| 1365 | @end defun | 1353 | @end defun |
| 1366 | 1354 | ||
| 1355 | @defun undo-auto--amalgamate | ||
| 1356 | The editor command loop automatically calls @code{undo-boundary} just | ||
| 1357 | before executing each key sequence, so that each undo normally undoes | ||
| 1358 | the effects of one command. A few exceptional commands are | ||
| 1359 | @emph{amalgamating}: these commands generally cause small changes to | ||
| 1360 | buffers. So with these a boundary is inserted only every 20th command, | ||
| 1361 | so that these can be undone as a group. By default commands | ||
| 1362 | @code{self-insert-command}, which produces self-inserting input | ||
| 1363 | characters (@pxref{Commands for Insertion}), and @code{delete-char} | ||
| 1364 | which deletes characters (@pxref{Deleting Text}) are amalgamating. | ||
| 1365 | Where a command affects the contents of several buffers as may happen, | ||
| 1366 | for example, if a function on the @code{post-command-hook} affects a | ||
| 1367 | buffer other than the @code{current-buffer}, then @code{undo-boundary} | ||
| 1368 | will be called in each of them. | ||
| 1369 | @end defun | ||
| 1370 | |||
| 1371 | @defvar undo-auto--boundary-timer | ||
| 1372 | Some buffers, such as process buffers, can change even when no | ||
| 1373 | commands are executing. In these cases, @code{undo-boundary} is | ||
| 1374 | normally called periodically by the timer in this variable. Setting | ||
| 1375 | this variable to non-@code{nil} prevents this behaviour. | ||
| 1376 | @end defvar | ||
| 1377 | |||
| 1367 | @defvar undo-in-progress | 1378 | @defvar undo-in-progress |
| 1368 | This variable is normally @code{nil}, but the undo commands bind it to | 1379 | This variable is normally @code{nil}, but the undo commands bind it to |
| 1369 | @code{t}. This is so that various kinds of change hooks can tell when | 1380 | @code{t}. This is so that various kinds of change hooks can tell when |
| @@ -262,7 +262,11 @@ at configure time. | |||
| 262 | ** M-x suggests shorthands and ignores obsolete commands for completion. | 262 | ** M-x suggests shorthands and ignores obsolete commands for completion. |
| 263 | 263 | ||
| 264 | ** Successive single-char deletions are collapsed in the undo-log just like | 264 | ** Successive single-char deletions are collapsed in the undo-log just like |
| 265 | successive char insertions. | 265 | successive char insertions. This behaviour can be extended to other |
| 266 | commands, using the `undo-auto--amalgamate' function. | ||
| 267 | |||
| 268 | ** The heuristic used to insert `undo-boundary' after each command has changed, | ||
| 269 | so that it supports commands which potentially affect multiple buffers. | ||
| 266 | 270 | ||
| 267 | +++ | 271 | +++ |
| 268 | ** New command `comment-line' bound to `C-x C-;'. | 272 | ** New command `comment-line' bound to `C-x C-;'. |
diff --git a/lisp/simple.el b/lisp/simple.el index b6bf010ed3a..99e6bd31363 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -2880,7 +2880,7 @@ See also `undo-auto--buffer-undoably-changed'.") | |||
| 2880 | 2880 | ||
| 2881 | (defun undo-auto--amalgamate () | 2881 | (defun undo-auto--amalgamate () |
| 2882 | "Amalgamate undo if necessary. | 2882 | "Amalgamate undo if necessary. |
| 2883 | This function can be called after an amalgamating command. It | 2883 | This function can be called before an amalgamating command. It |
| 2884 | removes the previous `undo-boundary' if a series of such calls | 2884 | removes the previous `undo-boundary' if a series of such calls |
| 2885 | have been made. By default `self-insert-command' and | 2885 | have been made. By default `self-insert-command' and |
| 2886 | `delete-char' are the only amalgamating commands, although this | 2886 | `delete-char' are the only amalgamating commands, although this |