Mon 05 Jun 2017 — Thu 18 Jan 2018

Got to 3 Numbers..

Emacs Lisp

C-x C-e reads and evaluates some emacs lisp.

It's somehow important that read and evaluate are separate stages.

Comments are ;


nil means (), FALSE or nil


There is eq for reference equals, equal for testing equality of values, and equal-including-properties, which also accounts for text properties.

Variables and Standard Types

'thing is a variable

Variables are (mostly) untyped, but values are typed. This is dynamic type.

There are type predicates for checking types, like symbolp, listp and so on.

  • Integer (signed, width depends on machine)
  • floating-point (signed double)
  • character - prepend with ? in source code, e.g. '?Q'.
    • may need escaping with '\'
    • ?\UNNNN for a unicode character
    • ?\C-g or ?\g represents ctrl + g
    • ?\M-g represents alt + g (actually meta, but whatever)
    • ?§-g represents shift + g
    • You can combine the modifiers ?\C-M-S-g
  • string is an array of characters
    • it can hold ASCII control characters, but not other control characters (C-char)
  • symbol is a type of interned string used to name things
    • distinct upper and lower case
    • keyword is a symbol starting with :
    • empty string symbol prints as ##
  • linked lists made of cons cells
    • empty list () is always equal to nil
    • an atom is anything other than a cons cell
    • car means first and cdr means rest (really pointer to rest)
    • you can represent cons as (a . b), which can be useful if b is not itself list
  • association lists or alist is a list of lists with keys and values
    • ((key1 value1) (key2 value2))
  • arrays (fixed-length, one-dimensional)
    • char tables are indexed by character
    • A vector can contain mixed types
    • a bool vector contains true or nil
  • hash tables are faster than alists

Arrays and lists both fit into the sequence abstraction.

Elisp doesn't expose pointers.


  • isnan
  • frexp breaks down a floating point number into significand and exponent. X = S * 2**E.
  • natnump or wholenump is the natural number predicate
  • zerop
  • use = to compare numbers, since sometimes floating point and integer should be equal

Write NaN as 0.0e+NaN and infinity as 1.0e+INF or -1.0e+INF.

There aren't any builtin bigints.

There are separate rounding functions for returning an integer or a floating point number.


A function is a list.

If it isn't compiled, the first item in the list is the symbol lambda

You can call functions with funcall and apply.

Primitive Functions

These are C functions.

Don't redefine them, it'll end badly.

Use (symbol-function 'builtin-function) to get a handle to them.

Use (subrp (symbol-functuin 'builtin-function)) to test if a function is primitive.

Byte Code

Compiling a function makes a byte-code function.

They look like #[some stuff] in the output.


A list which starts with autoload will go and get the function from a file on demand.

Use autoload to make these.


Don't evaluate their arguments.

They are a list with the symbol macro at the front.

They return a function.

Make them with defmacro.

Editing Types

These are special types for Emacs, which aren't in normal LISPs.

Buffers are string-like with nice editing properties and some extra bits:

  • syntax table
  • keymap
  • local variables
  • overlays apply a property list to a range of the buffer
  • text properties

Indirect buffers are a view onto some other buffer.


Windows, one of which is the selected window. Windows are grouped into frames, which are grouped into terminals.

A frame also has a window configuration to describe the layout of windows inside it.

There is one frame configuration, which is a list beginning with the word frame-configuration. It describes all the window configurations for everything.

Processes are objects which describe actual subprocesses made by Emacs.

Streams are a source or sink of characters. Nil used as a stream means either standard-input or standard-output. t used as a stream means the minibuffer.

Fonts. There are also font specs and font entities.

Reading Types with Cycles

#1= assigns the thing after = to be 1.

#1# uses 12

This is also useful is you want to reuse exactly the same object in two places, instead of two different-but-equal objects.

Text Properties

You can write text properties inside strings to tag them with display information.

This can happen automatically.


Has lexical scope per-file.

lexical-binding variable controls this.