Go to the previous, next section.

The Body of  append-to-buffer

The body of the  append-to-buffer function begins with  let .

As we have seen before (see section  let expression is to create and give initial values to one or more variables that will only be used within the body of the  let . This means that such a variable will not be confused with any variable of the same name outside the  let expression.

We can see how the  let expression fits into the function as a whole by showing a template for  append-to-buffer with the  let expression in outline:

(defun append-to-buffer (buffer start end)
  "documentation@dots{}"
  (interactive "BAppend to buffer: \nr")
  (let ((variable value))
        body@dots{})

The  let expression has three elements:

  1. The symbol  let ;

  2. A varlist containing, in this case, a single two-element list,  (variable value) ;

  3. The body of the  let expression.

In the  append-to-buffer function, the varlist looks like this:

(oldbuf (current-buffer))

In this part of the  let expression, the one variable,  oldbuf , is bound to the value returned by the  (current-buffer) expression. The variable,  oldbuf , is used to keep track of the buffer in which you are working.

The element or elements of a varlist are surrounded by a set of parentheses so the Lisp interpreter can distinguish the varlist from the body of the  let . As a consequence, the two-element list within the varlist is surrounded by circumscribing set of parentheses. The line looks like this:

(let ((oldbuf (current-buffer)))
  @dots{} )

The two parentheses before  oldbuf might surprise you if you did not realize that the first parenthesis before  oldbuf marks the boundary of the varlist and the second parenthesis marks the beginning of the two-element list,  (oldbuf (current-buffer)) .

Go to the previous, next section.