elisp

Emacs ext: https://alphapapa.github.io/emacs-package-dev-handbook/

car - the first element in a list cdr - the rest of the list

Equality

  • eq Check pointer
  • equal Check Value

Cons

(setcar cons-name 2)

;; Append lists
(append '(1 2 3) 4)

Alists

Alists are a list of cons cells - i.e. a HashMap

(setq some-alist '((one . 1)
           (two . 2)
           (three . 3)))

(alist-get 'one some-alist) ;; 1

(map-put some-alist 'four 4)

Lists

;; Set idx 5 of the list
(setf (alist) 5)

(alist-get 'one some-alist)

Plists

Key/Value pairs with a flat list

(plist-get '(one 1 two 2) 'one)

Plist vs. Alist

Debugger

M-x debug on entry M-x toggle-debug-on-error

place (debug) in your code to go into debug mode - good for viewing locals

  • v - expand local vars from that stack frame
  • n, p - navigate stack frames
  • + - pretty print

Edebug

SPC - step through edebug-goto-here Continue to here Kill the \*backtrace\* buffer - it can stop the debugger from running

  • i - step in
  • n - step
  • H - goto here
  • c - continue
  • d - view locals
  • e - eval

Backtrace Buffer

  • d - step through

Logic

  • cl-loop is the most efficient
  • unless - runs if the var is nil
  • (progn) - run a sequence of functions and return the last

Lispy

  • Barf - < - send the paren forward
  • w - move up (swap with paren above it)
  • d - goto pair
  • s - move down
  • c - clone
  • e - eval
  • xf - lambda to defun
  • xl - defun to lambda
  • q - avy-paren
  • Q - avy-char
  • a - avy-symbol
  • H - ace-symbol-replace