The body of the function definition is a
let expression, which
itself has a body as well as a varlist.
let expression declares a variable that will be only usable
within the bounds of this function. This variable is called
interprogram-paste and is for copying to another program. It
is not for copying within this instance of GNU Emacs. Most window
systems provide a facility for interprogram pasting. Sadly, that
facility usually provides only for the last element. Most windowing
systems have not adopted a ring of many possibilities, even though
Emacs has provided it for decades.
if expression has two parts, one if there exists
interprogram-paste and one if not.
Let us consider the `if not' or else-part of the
function. (The then-part uses the
kill-new function, which
we have already described. See The
(or kill-ring (error "Kill ring is empty")) (let ((ARGth-kill-element (nthcdr (mod (- n (length kill-ring-yank-pointer)) (length kill-ring)) kill-ring))) (or do-not-move (setq kill-ring-yank-pointer ARGth-kill-element)) (car ARGth-kill-element))
The code first checks whether the kill ring has content; otherwise it signals an error.
Note that the
or expression is very similar to testing length
(if (zerop (length kill-ring)) ; if-part (error "Kill ring is empty")) ; then-part ;; No else-part
If there is not anything in the kill ring, its length must be zero and
an error message sent to the user: ‘Kill ring is empty’. The
current-kill function uses an
or expression which is
simpler. But an
if expression reminds us what goes on.
if expression uses the function
zerop which returns
true if the value it is testing is zero. When
true, the then-part of the
if is evaluated. The then-part is a
list starting with the function
error, which is a function that
is similar to the
message Function) in that
it prints a one-line message in the echo area. However, in addition
to printing a message,
error also stops evaluation of the
function within which it is embedded. This means that the rest of the
function will not be evaluated if the length of the kill ring is zero.
current-kill function selects the element to return.
The selection depends on the number of places that
rotates and on where
Next, either the optional
do-not-move argument is true or the
current value of
kill-ring-yank-pointer is set to point to the
list. Finally, another expression returns the first element of the
list even if the
do-not-move argument is true.