Function: undo-auto-amalgamate
undo-auto-amalgamate is a byte-compiled function defined in
simple.el.gz.
Signature
(undo-auto-amalgamate)
Documentation
Amalgamate undo if necessary.
This function can be called before an amalgamating command. It
removes the previous undo-boundary if a series of such calls
have been made. self-insert-command and delete-char are the
most common amalgamating commands, although this function can be
called by any command which desires this behavior.
analyze-text-conversion (which see) is also an amalgamating
command in most circumstances.
Probably introduced at or before Emacs version 25.1.
Source Code
;; Defined in /usr/src/emacs/lisp/simple.el.gz
(defun undo-auto-amalgamate ()
"Amalgamate undo if necessary.
This function can be called before an amalgamating command. It
removes the previous `undo-boundary' if a series of such calls
have been made. `self-insert-command' and `delete-char' are the
most common amalgamating commands, although this function can be
called by any command which desires this behavior.
`analyze-text-conversion' (which see) is also an amalgamating
command in most circumstances."
(let ((last-amalgamating-count
(undo-auto--last-boundary-amalgamating-number)))
(setq undo-auto--this-command-amalgamating t)
(when last-amalgamating-count
(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
;; reflected these changes in some other buffer.
(dolist (b (cdr undo-auto--last-boundary-cause))
(when (buffer-live-p b)
(with-current-buffer
b
(when (and (consp buffer-undo-list)
;; `car-safe' doesn't work because
;; `buffer-undo-list' need not be a list!
(null (car buffer-undo-list)))
;; The head of `buffer-undo-list' is nil.
(setq buffer-undo-list
(cdr buffer-undo-list))))))
(setq undo-auto--last-boundary-cause 0)))))