diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi index ef11ac26690..bf88477adbd 100644 --- a/doc/lispref/text.texi +++ b/doc/lispref/text.texi @@ -1399,6 +1399,7 @@ appropriate time. @defun undo-auto-amalgamate @cindex amalgamating commands, and undo +@vindex amalgamating-undo-limit The editor command loop automatically calls @code{undo-boundary} just before executing each key sequence, so that each undo normally undoes the effects of one command. A few exceptional commands are @@ -1416,6 +1417,10 @@ will be called in each of the affected buffers. This function can be called before an amalgamating command. It removes the previous @code{undo-boundary} if a series of such calls have been made. + +The maximum number of changes that can be amalgamated is controlled by +the @code{amalgamating-undo-limit} variable. If this variable is 1, +no changes are amalgamated. @end defun @defvar undo-auto-current-boundary-timer diff --git a/etc/NEWS b/etc/NEWS index 4135d47ee18..a3a7ff28e80 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -453,6 +453,10 @@ Note that this key binding will not work on MS-Windows systems if * Editing Changes in Emacs 27.1 ++++ +** The new 'amalgamating-undo-limit' variable can be used to control +how many changes should be amalgamated when using the 'undo' command. + --- ** The 'newline-and-indent' command (commonly bound to 'RET' in many modes) now takes an optional numeric argument to specify how many diff --git a/lisp/simple.el b/lisp/simple.el index b5205dd7648..597278ae2b4 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -45,6 +45,14 @@ wait this many seconds after Emacs becomes idle before doing an update." :group 'display :version "22.1") +(defvar amalgamating-undo-limit 20 + "The maximum number of changes to possibly amalgamate when undoing changes. +The `undo' command will normally consider \"similar\" changes +(like inserting characters) to be part of the same change. This +is called \"amalgamating\" the changes. This variable says what +the maximum number of changes condidered is when amalgamating. A +value of 1 means that nothing is amalgamated.") + (defgroup killing nil "Killing and yanking commands." :group 'editing) @@ -3124,7 +3132,7 @@ behavior." (undo-auto--last-boundary-amalgamating-number))) (setq undo-auto--this-command-amalgamating t) (when last-amalgamating-count - (if (and (< last-amalgamating-count 20) + (if (and (< last-amalgamating-count amalgamating-undo-limit) (eq this-command last-command)) ;; Amalgamate all buffers that have changed. ;; This may be needed for example if some *-change-functions