Go to the previous, next section.

The Body of  rotate-yank-pointer

The body of  rotate-yank-pointer is a  let expression and the body of the  let expression is an  if expression.

The purpose of the  if expression is to find out whether there is anything in the kill ring. If the kill ring is empty, the  error function stops evaluation of the function and prints a message in the echo area. On the other hand, if the kill ring has something in it, the work of the function is done.

Here is the if-part and then-part of the  if expression:

(if (zerop length)                      ; if-part
    (error "Kill ring is empty")        ; then-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  if expression uses the function  zerop which returns true if the value it is testing is zero. When  zerop tests 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 (see section 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. In this case, this means that the rest of the function will not be evaluated if the length of the kill ring is zero.

(In my opinion, it is slightly misleading, at least to humans, to use the term `error' as the name of this function. A better term would be `cancel'. Strictly speaking, of course, you cannot point to, much less rotate a pointer to a list that has no length, so from the point of view of the computer, the word `error' is correct. But a human expects to attempt this sort of thing, if only to find out whether the kill ring is full or empty. This is an act of exploration.

(From the human point of view, the act of exploration and discovery is not necessarily an error, and therefore should not be labeled as one, even in the bowels of a computer. As it is, the code in Emacs implies that a human who is acting virtuously, by exploring his or her environment, is making an error. This is bad. Even though the computer takes the same steps as it does when there is an `error', a term such as `cancel' would have a clearer connotation.)

Go to the previous, next section.