Copyright (C) 2000-2012 |
GNU Info (emacs-lisp-intro.info)defvarInitializing a Variable with `defvar' ===================================== Unlike the `delete-and-extract-region' function, the `copy-region-as-kill' function is written in Emacs Lisp. Two functions within it, `kill-append' and `kill-new', copy a region in a buffer and save it in a variable called the `kill-ring'. This section describes how the `kill-ring' variable is created and initialized using the `defvar' special form. (Again we note that the term `kill-ring' is a misnomer. The text that is clipped out of the buffer can be brought back; it is not a ring of corpses, but a ring of resurrectable text.) In Emacs Lisp, a variable such as the `kill-ring' is created and given an initial value by using the `defvar' special form. The name comes from "define variable". The `defvar' special form is similar to `setq' in that it sets the value of a variable. It is unlike `setq' in two ways: first, it only sets the value of the variable if the variable does not already have a value. If the variable already has a value, `defvar' does not override the existing value. Second, `defvar' has a documentation string. (Another special form, `defcustom', is designed for variables that people customize. It has more features than `defvar'. (Note: Setting Variables with `defcustom'.)
automatically generated by info2www version 1.2.2.9 |