Function: wgrep-editing-overlay
wgrep-editing-overlay is a natively compiled function defined in
wgrep.el.
Signature
(wgrep-editing-overlay &optional START END)
Source Code
;; Defined in /nix/store/pbj4kr4ar755h56yscbqpnmv3swf8i1k-emacs-packages-deps/share/emacs/site-lisp/elpa/wgrep-20230203.1214/wgrep.el
;;;
;;; Editing handlers
;;;
;; get overlay BEG and END is passed by `after-change-functions'
(defun wgrep-editing-overlay (&optional start end)
(let ((beg (or start (line-beginning-position)))
(fin (or end (line-end-position)))
ov bol eol
;; beginning/end of grep
bog eog)
(goto-char beg)
(setq bol (line-beginning-position))
(goto-char fin)
(setq eol (line-end-position))
(catch 'done
(dolist (o (overlays-in bol eol))
;; find overlay that have changed by user.
(when (overlay-get o 'wgrep-changed)
(setq ov o)
(throw 'done o))))
(if ov
(setq bog (min beg (overlay-start ov))
eog (max (overlay-end ov) fin))
(setq bog bol
eog eol))
(goto-char bog)
(cond
;; When handling whole line, BOL equal beginning of edit.
((and (null ov) start (= bog start)))
((get-text-property (point) 'wgrep-line-filename)
(let* ((header-end
(next-single-property-change (point) 'wgrep-line-filename nil eol))
(filename (get-text-property (point) 'wgrep-line-filename))
(linum (get-text-property (point) 'wgrep-line-number))
(value (buffer-substring-no-properties header-end eog))
contents-begin)
(goto-char header-end)
(setq contents-begin (point-marker))
;; create editing overlay
(cond
((null ov)
(let ((old (wgrep-get-old-text filename linum)))
(setq ov (wgrep-make-overlay bog eog))
(overlay-put ov 'wgrep-contents-begin contents-begin)
(overlay-put ov 'wgrep-filename filename)
(overlay-put ov 'wgrep-linum linum)
(overlay-put ov 'wgrep-changed t)
(overlay-put ov 'priority 0)
(overlay-put ov 'evaporate t)
(overlay-put ov 'wgrep-old-text old)))
(t
(move-overlay ov bog eog)))
(overlay-put ov 'wgrep-edit-text value))))
ov))