Function: undo-adjust-beg-end
undo-adjust-beg-end is a byte-compiled function defined in
simple.el.gz.
Signature
(undo-adjust-beg-end BEG END DELTAS)
Documentation
Return cons of adjustments to BEG and END by the undo DELTAS list.
Source Code
;; Defined in /usr/src/emacs/lisp/simple.el.gz
;; (BEG . END) can adjust to the same positions, commonly when an
;; insertion was undone and they are out of region, for example:
;;
;; buf pos:
;; 123456789 buffer-undo-list undo-deltas
;; --------- ---------------- -----------
;; [...]
;; abbaa (2 . 4) (2 . -2)
;; aaa ("bb" . 2) (2 . 2)
;; [...]
;;
;; "bb" insertion (2 . 4) adjusts to (2 . 2) because of the subsequent
;; undo. Further adjustments to such an element should be the same as
;; for (TEXT . POSITION) elements. The options are:
;;
;; 1: POSITION adjusts using <= (use-< nil), resulting in behavior
;; analogous to marker insertion-type t.
;;
;; 2: POSITION adjusts using <, resulting in behavior analogous to
;; marker insertion-type nil.
;;
;; There was no strong reason to prefer one or the other, except that
;; the first is more consistent with prior undo in region behavior.
(defun undo-adjust-beg-end (beg end deltas)
"Return cons of adjustments to BEG and END by the undo DELTAS list."
(let ((adj-beg (undo-adjust-pos beg deltas)))
;; Note: option 2 above would be like (cons (min ...) adj-end)
(cons adj-beg
(max adj-beg (undo-adjust-pos end deltas t)))))