Function: erc-fill--wrap-rejigger-region
erc-fill--wrap-rejigger-region is a byte-compiled function defined in
erc-fill.el.gz.
Signature
(erc-fill--wrap-rejigger-region START FINISH ON-NEXT REPAIRP)
Documentation
Recalculate line-prefix from START to FINISH.
After refilling each message, call ON-NEXT with no args. But
stash and restore erc-fill--wrap-last-msg before doing so, in
case this module's insert hooks run by way of the process filter.
With REPAIRP, destructively fill gaps and re-merge speakers.
Source Code
;; Defined in /usr/src/emacs/lisp/erc/erc-fill.el.gz
(defun erc-fill--wrap-rejigger-region (start finish on-next repairp)
"Recalculate `line-prefix' from START to FINISH.
After refilling each message, call ON-NEXT with no args. But
stash and restore `erc-fill--wrap-last-msg' before doing so, in
case this module's insert hooks run by way of the process filter.
With REPAIRP, destructively fill gaps and re-merge speakers."
(goto-char start)
(setq erc-fill--wrap-merge-indicator-pre nil)
(let ((erc-fill--wrap-rejigger-last-message
erc-fill--wrap-rejigger-last-message))
(while-let
(((< (point) finish))
(beg (if (get-text-property (point) 'line-prefix)
(point)
(next-single-property-change (point) 'line-prefix)))
(val (get-text-property beg 'line-prefix))
(end (text-property-not-all beg finish 'line-prefix val)))
;; If this is a left-side stamp on its own line.
(remove-text-properties beg (1+ end) '(line-prefix nil wrap-prefix nil))
(when-let ((repairp)
(dbeg (text-property-not-all beg end
'erc-fill--wrap-merge nil))
((get-text-property (1+ dbeg) 'erc--speaker))
(dval (get-text-property dbeg 'erc-fill--wrap-merge)))
(remove-list-of-text-properties
dbeg (text-property-not-all dbeg end 'erc-fill--wrap-merge dval)
'(display erc-fill--wrap-merge)))
;; This "should" work w/o `front-sticky' and `rear-nonsticky'.
(let* ((pos (if-let (((eq 'erc-timestamp (field-at-pos beg)))
(b (field-beginning beg))
((eq 'datestamp (get-text-property b 'erc--msg))))
b
beg))
(erc--msg-props (map-into (text-properties-at pos) 'hash-table))
(erc-stamp--current-time (gethash 'erc--ts erc--msg-props)))
(save-restriction
(narrow-to-region beg (1+ end))
(let ((erc-fill--wrap-last-msg erc-fill--wrap-rejigger-last-message))
(erc-fill-wrap)
(setq erc-fill--wrap-rejigger-last-message
erc-fill--wrap-last-msg))))
(when on-next
(funcall on-next))
;; Skip to end of message upon encountering accidental gaps
;; introduced by third parties (or bugs).
(if-let (((/= ?\n (char-after end)))
(next (erc--get-inserted-msg-end beg)))
(progn
(cl-assert (= ?\n (char-after next)))
(when repairp ; eol <= next
(put-text-property end (pos-eol) 'line-prefix val))
(goto-char next))
(goto-char end)))))