Function: s-splice

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

Signature

(s-splice NEEDLE N S)

Documentation

Splice NEEDLE into S at position N.

0 is the beginning of the string, -1 is the end.

Source Code

;; Defined in ~/.emacs.d/elpa/s-20220902.1511/s.el
(defun s-splice (needle n s)
  "Splice NEEDLE into S at position N.
0 is the beginning of the string, -1 is the end."
  (if (< n 0)
      (let ((left (substring s 0 (+ 1 n (length s))))
            (right (s-right (- -1 n) s)))
        (concat left needle right))
    (let ((left (s-left n s))
          (right (substring s n (length s))))
        (concat left needle right))))