| www.delorie.com/gnu/docs/emacs-lisp-intro/emacs-lisp-intro_70.html | search |
![]() Buy the book! | |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
In the last few chapters we have introduced a fair number of functions and special forms. Here they are described in brief, along with a few similar functions that have not been mentioned yet.
eval-last-sexp
defun
For example:
(defun back-to-indentation () "Move point to first visible character on line." (interactive) (beginning-of-line 1) (skip-chars-forward " \t")) |
interactive
Common code characters are:
b
f
p
r
See section `Code Characters for `interactive'' in The GNU Emacs Lisp Reference Manual, for a complete list of code characters.
let
let and give them an initial value, either nil or a
specified value; then evaluate the rest of the expressions in the body
of the let and return the value of the last one. Inside the
body of the let, the Lisp interpreter does not see the values of
the variables of the same names that are bound outside of the
let.
For example,
(let ((foo (buffer-name))
(bar (buffer-size)))
(message
"This buffer is %s and has %d characters."
foo bar))
|
save-excursion
For example,
(message "We are %d characters into this buffer."
(- (point)
(save-excursion
(goto-char (point-min)) (point))))
|
if
The if special form is called a conditional. There are
other conditionals in Emacs Lisp, but if is perhaps the most
commonly used.
For example,
(if (string-equal
(number-to-string 21)
(substring (emacs-version) 10 12))
(message "This is version 21 Emacs")
(message "This is not version 21 Emacs"))
|
equal
eq
equal uses one meaning
of the word `same' and eq uses another: equal returns
true if the two objects have a similar structure and contents, such as
two copies of the same book. On the other hand, eq, returns
true if both arguments are actually the same object.
<
>
<=
>=
< function tests whether its first argument is smaller than
its second argument. A corresponding function, >, tests whether
the first argument is greater than the second. Likewise, <=
tests whether the first argument is less than or equal to the second and
>= tests whether the first argument is greater than or equal to
the second. In all cases, both arguments must be numbers or markers
(markers indicate positions in buffers).
string<
string-lessp
string=
string-equal
string-lessp function tests whether its first argument is
smaller than the second argument. A shorter, alternative name for the
same function (a defalias) is string<.
The arguments to string-lessp must be strings or symbols; the
ordering is lexicographic, so case is significant. The print names of
symbols are used instead of the symbols themselves.
An empty string, `""', a string with no characters in it, is smaller than any string of characters.
string-equal provides the corresponding test for equality. Its
shorter, alternative name is string=. There are no string test
functions that correspond to >, >=, or <=.
message
setq
set
setq function sets the value of its first argument to the
value of the second argument. The first argument is automatically
quoted by setq. It does the same for succeeding pairs of
arguments. Another function, set, takes only two arguments and
evaluates both of them before setting the value returned by its first
argument to the value returned by its second argument.
buffer-name
buffer-file-name
current-buffer
other-buffer
other-buffer as an argument and other than the current
buffer).
switch-to-buffer
set-buffer
buffer-size
point
point-min
point-max
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| webmaster donations bookstore | delorie software privacy |
| Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |