The part of the
condition-case expression that is evaluated in
the expectation that all goes well has a
when. The code uses
when to determine whether the
string variable points to
text that exists.
when expression is simply a programmers' convenience. It is
if without the possibility of an else clause. In your mind,
you can replace
if and understand what goes
on. That is what the Lisp interpreter does.
when is a Lisp macro. A Lisp macro
enables you to define new control constructs and other language
features. It tells the interpreter how to compute another Lisp
expression which will in turn compute the value. In this case, the
`other expression' is an
kill-region function definition also has an
macro; it is the converse of
unless macro is
if without a then clause
For more about Lisp macros, see Macros. The C programming language also provides macros. These are different, but also useful.
when macro, in the
expression, when the string has content, then another conditional
expression is executed. This is an
if with both a then-part
and an else-part.
(if (eq last-command 'kill-region) (kill-append string (< end beg) yank-handler) (kill-new string nil yank-handler))
The then-part is evaluated if the previous command was another call to
kill-region; if not, the else-part is evaluated.
yank-handler is an optional argument to
kill-new functions how deal
with properties added to the text, such as `bold' or `italics'.
last-command is a variable that comes with Emacs that we have
not seen before. Normally, whenever a function is executed, Emacs
sets the value of
last-command to the previous command.
In this segment of the definition, the
if expression checks
whether the previous command was
kill-region. If it was,
(kill-append string (< end beg) yank-handler)
concatenates a copy of the newly clipped text to the just previously clipped text in the kill ring.