Emacs LISP (5) – List


1、 Reference

Emacs series article directory – updating

An Introduction to Programming in Emacs Lisp


2.1 liststructure


(1) Single quotation marks indicate the beginning of a list

(2) Elements in the list are directly separated by spaces

(3) The elements in the list are contained in()in

Emacs LISP (5) - List

2.2 list with number / sub list

Emacs LISP (5) - List

2.3 with"String list for

Emacs LISP (5) - List

" "The contained string is treated as a list element

2.4 operation list

functionevalThree possible situations after the procedure:

(1) Returns a list directly

(2) Produceerror message

(3) Parse the first element in the list into an execution command to execute the list

Add before a list', you can make the runtime not parse the specific expression, but output the original string of the expression

Emacs LISP (5) - List

2.5 other types

In addition to the most common list structures, there are the following types

(1) Variable

Variable not required'and()

(2) Macro

(3) Nested list

Nested list, first execute the innermost expression, and then execute the outer layer in turn

2.6 Bytecode vs LISP code

name lispcode Bytecode
file extension .el .elc
Speed comparison It needs to be interpreted as bytecode before execution PrecompiledlispCode, faster execution

Emacs LISP (5) - List

2.7 execution sequence

First, execute the internal expression, then take the result as the parameter of the outer expression, and evaluate the external expression again

Emacs LISP (5) - List

As above, first calculate(+ 3 3), the calculation result is6, as an argument to the outer function, i.e(+ 2 6), the final calculation result is8