(string-trim (replace-regexp-in-string blank " " string t t)
blank blank)))
+;;;###autoload
(defun string-fill (string length)
"Try to word-wrap STRING so that no lines are longer than LENGTH.
Wrapping is done where there is whitespace. If there are
(fill-region (point-min) (point-max)))
(buffer-string)))
+;;;###autoload
(defun string-limit (string length &optional end coding-system)
"Return a substring of STRING that is (up to) LENGTH characters long.
If STRING is shorter than or equal to LENGTH characters, return the
(end (substring string (- (length string) length)))
(t (substring string 0 length)))))
+;;;###autoload
(defun string-pad (string length &optional padding start)
"Pad STRING to LENGTH using PADDING.
If PADDING is nil, the space character is used. If not nil, it
(start (concat (make-string pad-length (or padding ?\s)) string))
(t (concat string (make-string pad-length (or padding ?\s)))))))
+;;;###autoload
(defun string-chop-newline (string)
"Remove the final newline (if any) from STRING."
(declare (pure t) (side-effect-free t))