Language Specifications
Table of Contents
set
, setq
, setq-default
reference
is equivalent to:
(defvar xxx ...) ;; declare xxx with global scope
(make-local-variable 'xxx) ;; make xxx local in this buffer only
If a variable is buffer-local:
setq
sets its local value in the current buffersetq-default
sets the global default value.
?<character>
reference
- Prefix
?
before a character.
?Q ⇒ 81 ?q ⇒ 113
?\a ⇒ 7 ; control-g, C-g
?\b ⇒ 8 ; backspace, BS, C-h
?\t ⇒ 9 ; tab, TAB, C-i
?\n ⇒ 10 ; newline, C-j
?\v ⇒ 11 ; vertical tab, C-k
?\f ⇒ 12 ; formfeed character, C-l
?\r ⇒ 13 ; carriage return, RET, C-m
?\e ⇒ 27 ; escape character, ESC, C-[
?\s ⇒ 32 ; space character, SPC
?\\ ⇒ 92 ; backslash character, \
?\d ⇒ 127 ; delete character, DEL
?Q
81
let
reference
- Use
let
for local variables
(setq y 2)
⇒ 2
(let ((y 1)
(z y)) ; 'z' is bound to the old value of 'y'
(list y z))
⇒ (1 2)
(let* ((y 1)
(z y)) ; Use the just-established value of y.
(list y z))
⇒ (1 1)
(interactive)
reference
Argument-List(&optional
, &rest
) discussion
- Binds
a
andb
to the first two actual arguments, which are required. - If one or two more arguments are provided,
c
andd
are bound to them respectively; - Any arguments after the first four are collected into a list and
e
is bound to that list.
(funcall (lambda (n) (1+ n)) ; One required:
1) ; requires exactly one argument.
⇒ 2
(funcall (lambda (n &optional n1) ; One required and one optional:
(if n1 (+ n n1) (1+ n))) ; 1 or 2 arguments.
1 2)
⇒ 3
(funcall (lambda (n &rest ns) ; One required and one rest:
(+ n (apply '+ ns))) ; 1 or more arguments.
1 2 3 4 5)
⇒ 15