append-to-buffer
The body of the append-to-buffer
function begins with let
.
As we have seen before (see section let
), the purpose of a
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..." (interactive "BAppend to buffer: \nr") (let ((variable value)) body...)
The let
expression has three elements:
let
;
(variable value)
;
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 a circumscribing set of parentheses.
The line looks like this:
(let ((oldbuf (current-buffer))) ... )
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 first, previous, next, last section, table of contents.