Function: kfill:replace-string
kfill:replace-string is a byte-compiled function defined in kfill.el.
Signature
(kfill:replace-string FILL-STR-PREV FILL-STR &optional SUFFIX START END)
Documentation
Replace whitespace separated FILL-STR-PREV with FILL-STR.
Optional SUFFIX non-nil means replace at ends of lines, default is beginnings. Optional arguments START and END specify the replace region, default is the current region.
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/kotl/kfill.el
(defun kfill:replace-string (fill-str-prev fill-str &optional suffix start end)
"Replace whitespace separated FILL-STR-PREV with FILL-STR.
Optional SUFFIX non-nil means replace at ends of lines, default is beginnings.
Optional arguments START and END specify the replace region, default is the
current region."
(when fill-str-prev
(if start
(let ((s (min start end)))
(setq end (max start end)
start s))
(setq start (region-beginning)
end (region-end)))
(unless fill-str (setq fill-str ""))
(save-excursion
(save-restriction
(narrow-to-region start end)
(goto-char (point-min))
(let ((prefix
(concat
(unless suffix "^")
"[ \t]*"
(regexp-quote
;; Get non-whitespace separated fill-str-prev
(substring
fill-str-prev
(or (string-match "[^ \t]" fill-str-prev) 0)
(when (string-match
"[ \t]*\\(.*[^ \t]\\)[ \t]*$"
fill-str-prev)
(match-end 1))))
"[ \t]*"
(when suffix "$"))))
(while (re-search-forward prefix nil t)
(replace-match fill-str nil t)))))))