A cons cell explorer.
M-x pair-tree
is a learning tool for visualizing Emacs Lisp lists. It builds an explorable box‑and‑pointer diagram for cons cells.
If you're baffled by cons
and confused by cdaadr
you might want to give it a spin.
M-x pair-tree '((2 . (turtle doves)) (3 french hens) 4 (calling . birds) partridge)
You will need Emacs 27.1 and svg support. Needless to say, this won't work on a terminal.
- Use the MELPA package repository
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
-
Refresh your packages
M-x package-refresh-contents
-
Install
pair-tree
M-x package-install pair-tree
Clone this repository and add pair-tree.el
to your load path:
(add-to-list load-path "/path/to/repo/pair-tree.el")
Call M-x pair-tree
and type the list you want to visualise.
You can navigate the tree with the arrow keys. The minibuffer shows the most concise accessor for the focused section.
If you're learning about lists, be sure to read the GNU Emacs manual. You may want to check out dash.el, the excellent list library used in this package.
Racket is an excellent programming language to learn in. If you're using it, take a look at the Sdraw cons cell visualizer instead.
If you're keen to dive deeply into box‑and‑pointer diagrams, have a read through Structure and Interpretation of Computer Programs by Ableson and Sussman.
Thanks to the following people for helping pair-tree grow.
- Nicholas Vollmer (@progfolio) #4
- Daniel Nicolai (@dalanicolai) #8