www.delorie.com/gnu/docs/emacs-lisp-intro/emacs-lisp-intro_260.html   search  
 
Buy the book!


Programming in Emacs Lisp

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

B.1.1 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 1.8.5 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.

Digression about the word `error'  How to mislead humans, but not computers.
The else-part of the if expression  
The % remainder function  The remainder, %, function.
Using % in rotate-yank-pointer  
Pointing to the last element  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003