Function: ring-insert

ring-insert is a byte-compiled function defined in ring.el.gz.

Signature

(ring-insert RING ITEM)

Documentation

Insert onto ring RING the item ITEM, as the newest (last) item.

If the ring is full, dump the oldest item to make room.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/ring.el.gz
(defun ring-insert (ring item)
  "Insert onto ring RING the item ITEM, as the newest (last) item.
If the ring is full, dump the oldest item to make room."
  (let* ((vec (cddr ring))
         (veclen (length vec))
         (hd (car ring))
         (ln (cadr ring)))
    (prog1
        (aset vec (mod (+ hd ln) veclen) item)
      (if (= ln veclen)
          (setcar ring (ring-plus1 hd veclen))
        (setcar (cdr ring) (1+ ln))))))