Function: wgrep-set-readonly-area
wgrep-set-readonly-area is a natively compiled function defined in
wgrep.el.
Signature
(wgrep-set-readonly-area STATE)
Source Code
;; Defined in /nix/store/pbj4kr4ar755h56yscbqpnmv3swf8i1k-emacs-packages-deps/share/emacs/site-lisp/elpa/wgrep-20230203.1214/wgrep.el
(defun wgrep-set-readonly-area (state)
(let ((inhibit-read-only t)
(wgrep-inhibit-modification-hook t)
pos start end)
(save-excursion
;; set readonly grep result filename
(setq pos (point-min))
(while (setq start (next-single-property-change
pos 'wgrep-line-filename))
(setq end (next-single-property-change
start 'wgrep-line-filename))
(put-text-property start end 'read-only state)
(put-text-property (1- end) end 'rear-nonsticky t)
;; set readonly all newline at end of grep line
(when (eq (char-before start) ?\n)
(put-text-property (1- start) start 'read-only state))
(setq pos end))
(setq pos (point-min))
(while (setq start (next-single-property-change
pos 'wgrep-ignore))
(setq end (next-single-property-change
start 'wgrep-ignore))
(put-text-property start end 'read-only state)
;; set readonly all newline at end of grep line
(when (eq (char-before start) ?\n)
(put-text-property (1- start) start 'read-only state))
(setq pos end))
;; set readonly last of grep line
(let ((footer (or (next-single-property-change (point-min) 'wgrep-footer)
;; to consider empty footer.
(point-max))))
(when (eq (char-before footer) ?\n)
(put-text-property (1- footer) footer 'read-only state))))
(setq wgrep-readonly-state state)))