10.2 The kill-ring-yank-pointer Variable

kill-ring-yank-pointer is a variable, just as kill-ring is a variable. It points to something by being bound to the value of what it points to, like any other Lisp variable.

Thus, if the value of the kill ring is:

("some text" "a different piece of text" "yet more text")

and the kill-ring-yank-pointer points to the second clause, the value of kill-ring-yank-pointer is:

("a different piece of text" "yet more text")

As explained in the previous chapter (see How Lists are Implemented), the computer does not keep two different copies of the text being pointed to by both the kill-ring and the kill-ring-yank-pointer. The words “a different piece of text” and “yet more text” are not duplicated. Instead, the two Lisp variables point to the same pieces of text. Here is a diagram:

kill-ring     kill-ring-yank-pointer
    |               |
    |      ___ ___  |     ___ ___      ___ ___
     ---> |   |   |  --> |   |   |    |   |   |
          |___|___|----> |___|___|--> |___|___|--> nil
            |              |            |
            |              |            |
            |              |             --> "yet more text"
            |              |
            |               --> "a different piece of text"
             --> "some text"

Both the variable kill-ring and the variable kill-ring-yank-pointer are pointers. But the kill ring itself is usually described as if it were actually what it is composed of. The kill-ring is spoken of as if it were the list rather than that it points to the list. Conversely, the kill-ring-yank-pointer is spoken of as pointing to a list.

These two ways of talking about the same thing sound confusing at first but make sense on reflection. The kill ring is generally thought of as the complete structure of data that holds the information of what has recently been cut out of the Emacs buffers. The kill-ring-yank-pointer on the other hand, serves to indicate—that is, to point to—that part of the kill ring of which the first element (the CAR) will be inserted.