Function: avy--update-offset-and-str
avy--update-offset-and-str is a byte-compiled function defined in
avy.el.
Signature
(avy--update-offset-and-str OFFSET STR LEP)
Documentation
Recalculate the length of the new overlay at point.
OFFSET is the previous overlay length. STR is the overlay string that we wish to add. LEP is the line end position.
We want to add an overlay between point and END=point+OFFSET. When other overlays already exist between point and END, set OFFSET to be the difference between the start of the first overlay and point. This is equivalent to truncating our new overlay, so that it doesn't intersect with overlays that already exist.
Source Code
;; Defined in ~/.emacs.d/elpa/avy-20241101.1357/avy.el
(defun avy--update-offset-and-str (offset str lep)
"Recalculate the length of the new overlay at point.
OFFSET is the previous overlay length.
STR is the overlay string that we wish to add.
LEP is the line end position.
We want to add an overlay between point and END=point+OFFSET.
When other overlays already exist between point and END, set
OFFSET to be the difference between the start of the first
overlay and point. This is equivalent to truncating our new
overlay, so that it doesn't intersect with overlays that already
exist."
(let* ((wnd (selected-window))
(beg (point))
(oov (delq nil
(mapcar
(lambda (o)
(and (eq (overlay-get o 'category) 'avy)
(eq (overlay-get o 'window) wnd)
(overlay-start o)))
(overlays-in beg (min (+ beg offset) lep))))))
(when oov
(setq offset (- (apply #'min oov) beg))
(setq str (substring str 0 offset)))
(let ((other-ov (cl-find-if
(lambda (o)
(and (eq (overlay-get o 'category) 'avy)
(eq (overlay-start o) beg)
(not (eq (overlay-get o 'window) wnd))))
(overlays-in (point) (min (+ (point) offset) lep)))))
(when (and other-ov
(> (overlay-end other-ov)
(+ beg offset)))
(setq str (concat str (buffer-substring
(+ beg offset)
(overlay-end other-ov))))
(setq offset (- (overlay-end other-ov)
beg))))
(cons offset str)))