Next: , Previous: , Up: Utilities   [Contents][Index]


16.2 Ring Functions

There are various purposes in an editor for which a ring of values can be used, so Hemlock provides a general ring buffer type. It is used for maintaining a ring of killed regions (see section kill-ring), a ring of marks (see section mark-stack), or a ring of command strings which various modes and commands maintain as a history mechanism.

Function: make-ring length &optional delete-function

Makes an empty ring object capable of holding up to length Lisp objects. Delete-function is a function that each object is passed to before it falls off the end. Length must be greater than zero.

Function: ringp ring

Returns t if ring is a ring object, otherwise nil.

Function: ring-length ring

Returns as multiple-values the number of elements which ring currently holds and the maximum number of elements which it may hold.

Function: ring-ref ring index

Returns the index’th item in the ring, where zero is the index of the most recently pushed. This may be set with setf.

Function: ring-push object ring

Pushes object into ring, possibly causing the oldest item to go away.

Function: ring-pop ring

Removes the most recently pushed object from ring and returns it. If the ring contains no elements then an error is signalled.

Function: rotate-ring ring offset

With a positive offset, rotates ring forward that many times. In a forward rotation the index of each element is reduced by one, except the one which initially had a zero index, which is made the last element. A negative offset rotates the ring the other way.


Next: Undoing commands, Previous: String-table Functions, Up: Utilities   [Contents][Index]