aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhillip Lord2015-11-24 23:02:11 +0000
committerPhillip Lord2015-11-30 20:14:13 +0000
commitc2ba4a20aafc3ea0a907bcbb17fb41590b44cf09 (patch)
treef3f7e6be7a8ab5be5f7d5fb7f689b26685b07e38
parent3eb93c07f7a60ac9ce8a16f10c3afd5a3a31243a (diff)
downloademacs-c2ba4a20aafc3ea0a907bcbb17fb41590b44cf09.tar.gz
emacs-c2ba4a20aafc3ea0a907bcbb17fb41590b44cf09.zip
; Added documentation for undo-auto functionality.
* doc/lispref/text.texi: Documentation added * etc/NEWS: Annoucement added * lisp/simple.el (undo-auto--amalgamate): Docstring fix.
-rw-r--r--doc/lispref/text.texi41
-rw-r--r--etc/NEWS6
-rw-r--r--lisp/simple.el2
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
1343command stops at such a boundary, and successive undo commands undo 1343command stops at such a boundary, and successive undo commands undo
1344to earlier and earlier boundaries. This function returns @code{nil}. 1344to earlier and earlier boundaries. This function returns @code{nil}.
1345 1345
1346The editor command loop automatically calls @code{undo-boundary} just
1347before executing each key sequence, so that each undo normally undoes
1348the effects of one command. As an exception, the command
1349@code{self-insert-command}, which produces self-inserting input
1350characters (@pxref{Commands for Insertion}), may remove the boundary
1351inserted by the command loop: a boundary is accepted for the first
1352such character, the next 19 consecutive self-inserting input
1353characters do not have boundaries, and then the 20th does; and so on
1354as long as the self-inserting characters continue. Hence, sequences
1355of consecutive character insertions can be undone as a group.
1356
1357All buffer modifications add a boundary whenever the previous undoable
1358change was made in some other buffer. This is to ensure that
1359each command makes a boundary in each buffer where it makes changes.
1360
1361Calling this function explicitly is useful for splitting the effects of 1346Calling this function explicitly is useful for splitting the effects of
1362a command into more than one unit. For example, @code{query-replace} 1347a command into more than one unit. For example, @code{query-replace}
1363calls @code{undo-boundary} after each replacement, so that the user can 1348calls @code{undo-boundary} after each replacement, so that the user can
1364undo individual replacements one by one. 1349undo individual replacements one by one.
1350
1351Mostly, however, this function is called automatically at an
1352appropriate time.
1365@end defun 1353@end defun
1366 1354
1355@defun undo-auto--amalgamate
1356The editor command loop automatically calls @code{undo-boundary} just
1357before executing each key sequence, so that each undo normally undoes
1358the effects of one command. A few exceptional commands are
1359@emph{amalgamating}: these commands generally cause small changes to
1360buffers. So with these a boundary is inserted only every 20th command,
1361so that these can be undone as a group. By default commands
1362@code{self-insert-command}, which produces self-inserting input
1363characters (@pxref{Commands for Insertion}), and @code{delete-char}
1364which deletes characters (@pxref{Deleting Text}) are amalgamating.
1365Where a command affects the contents of several buffers as may happen,
1366for example, if a function on the @code{post-command-hook} affects a
1367buffer other than the @code{current-buffer}, then @code{undo-boundary}
1368will be called in each of them.
1369@end defun
1370
1371@defvar undo-auto--boundary-timer
1372Some buffers, such as process buffers, can change even when no
1373commands are executing. In these cases, @code{undo-boundary} is
1374normally called periodically by the timer in this variable. Setting
1375this variable to non-@code{nil} prevents this behaviour.
1376@end defvar
1377
1367@defvar undo-in-progress 1378@defvar undo-in-progress
1368This variable is normally @code{nil}, but the undo commands bind it to 1379This 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
diff --git a/etc/NEWS b/etc/NEWS
index 117be559192..0e38db6544d 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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
265successive char insertions. 265successive char insertions. This behaviour can be extended to other
266commands, using the `undo-auto--amalgamate' function.
267
268** The heuristic used to insert `undo-boundary' after each command has changed,
269so 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.
2883This function can be called after an amalgamating command. It 2883This function can be called before an amalgamating command. It
2884removes the previous `undo-boundary' if a series of such calls 2884removes the previous `undo-boundary' if a series of such calls
2885have been made. By default `self-insert-command' and 2885have 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