Function: s-center

s-center is a byte-compiled function defined in s.el.

Signature

(s-center LEN S)

Documentation

If S is shorter than LEN, pad it with spaces so it is centered.

Source Code

;; Defined in ~/.emacs.d/elpa/s-20220902.1511/s.el
(defun s-center (len s)
  "If S is shorter than LEN, pad it with spaces so it is centered."
  (declare (pure t) (side-effect-free t))
  (let ((extra (max 0 (- len (length s)))))
    (concat
     (make-string (ceiling extra 2) ?\s)
     s
     (make-string (floor extra 2) ?\s))))