Function: glc-adjust-pos
glc-adjust-pos is a byte-compiled function defined in goto-chg.el.
Signature
(glc-adjust-pos POS E)
Documentation
Given POS, a buffer position before the edit E, compute and return
the "same" buffer position after E happened.
Exception: return nil if POS is closer than glc-current-span to the edit E.
Insertion edits before POS returns a larger value. Deletion edits before POS returns a smaller value.
The edit E is an entry from the buffer-undo-list. See for details.
Source Code
;; Defined in ~/.emacs.d/elpa/goto-chg-20240407.1110/goto-chg.el
(defun glc-adjust-pos (pos e)
"Given POS, a buffer position before the edit E, compute and return
the \"same\" buffer position after E happened.
Exception: return nil if POS is closer than `glc-current-span' to the edit E.
\nInsertion edits before POS returns a larger value.
Deletion edits before POS returns a smaller value.
\nThe edit E is an entry from the `buffer-undo-list'. See for details."
(setq e (glc-fixup-edit e))
(cond ((atom e) ; nil==cmd boundary, or, num==changed pos
pos)
((numberp (car e)) ; (beg . end)==insertion
(glc-adjust-pos2 pos (car e) (car e) (- (cdr e) (car e))))
((stringp (car e)) ; (string . pos)==deletion
(glc-adjust-pos2 pos (abs (cdr e)) (+ (abs (cdr e)) (length (car e))) (- (length (car e)))))
((null (car e)) ; (nil prop val beg . end)==prop change
(glc-adjust-pos2 pos (nth 3 e) (nthcdr 4 e) 0))
(t ; (marker . dist)==marker moved
pos)))