Next: search Exercises, Previous: defvar, Up: Cutting & Storing Text [Contents][Index]
Here is a brief summary of some recently introduced functions.
carcdrcar returns the first element of a list; cdr returns the
second and subsequent elements of a list.
For example:
(car '(1 2 3 4 5 6 7))
⇒ 1
(cdr '(1 2 3 4 5 6 7))
⇒ (2 3 4 5 6 7)
conscons constructs a list by prepending its first argument to its second
argument.
For example:
(cons 1 '(2 3 4))
⇒ (1 2 3 4)
funcallfuncall evaluates its first argument as a function. It passes its
remaining arguments to its first argument.
nthcdrReturn the result of taking CDR n times on a list. The “rest of the rest”, as it were.
For example:
(nthcdr 3 '(1 2 3 4 5 6 7))
⇒ (4 5 6 7)
setcarsetcdrsetcar changes the first element of a list; setcdr changes the
second and subsequent elements of a list.
For example:
(setq triple (list 1 2 3))
(setcar triple '37)
triple
⇒ (37 2 3)
(setcdr triple '("foo" "bar"))
triple
⇒ (37 "foo" "bar")
prognEvaluate each argument in sequence and then return the value of the last.
For example:
(progn 1 2 3 4)
⇒ 4
save-restrictionRecord whatever narrowing is in effect in the current buffer, if any, and restore that narrowing after evaluating the arguments.
search-forwardSearch for a string, and if the string is found, move point. With a regular
expression, use the similar re-search-forward. (See Regular Expression Searches, for an explanation of regular expression
patterns and searches.)
search-forward and re-search-forward take four arguments:
nil or an error
message.
kill-regiondelete-and-extract-regioncopy-region-as-killkill-region cuts the text between point and mark from the buffer and
stores that text in the kill ring, so you can get it back by yanking.
copy-region-as-kill copies the text between point and mark into the
kill ring, from which you can get it by yanking. The function does not cut
or remove the text from the buffer.
delete-and-extract-region removes the text between point and mark
from the buffer and throws it away. You cannot get it back. (This is not
an interactive command.)
Next: search Exercises, Previous: defvar, Up: Cutting & Storing Text [Contents][Index]