git clone 'git://'

Table of Contents generated with autotoc


The missing hash table library for Emacs.

MELPA Build Status


Return a hash table

Accessing the hash table

Mutating the hash table

Iterating over the hash table


Converting from a hash table

Converting to a hash table


Returning a hash table

Iterating over the hash table (anaphoric)


Creating a hash table and accessing it:

(require 'ht)

(defun say-hello (name)
  (let ((greetings (ht ("Bob" "Hey bob!")
                       ("Chris" "Hi Chris!"))))
    (ht-get greetings name "Hello stranger!")))

This could be alternatively written as:

(require 'ht)

(defun say-hello (name)
  (let ((greetings (ht-create)))
    (ht-set! greetings "Bob" "Hey Bob!")
    (ht-set! greetings "Chris" "Hi Chris!")
    (ht-get greetings name "Hello stranger!")))


Libraries like s.el (strings) and dash.el (lists) have shown how much nicer Emacs lisp programming can be with good libraries. ht.el aims to similarly simplify working with hash tables.

Common operations with hash tables (e.g. enumerate the keys) are too difficult in Emacs lisp.

ht.el offers:

Similar libraries


ht.el is availabe on MELPA and Marmalade.

Add a package archive to your .emacs.d/init.el:

(require 'package)
(add-to-list 'package-archives '("melpa" . "") t)

then run M-x package-install <RET> ht <RET>


ht.el uses semantic versioning, so an incompatible API change will result in the major version increasing. See for a history of all changes.

Running tests

M-x ht-run-tests

What's an alist/plist?

An alist is an association list, which is a list of pairs. It looks like this:

((key1 . value1)
 (key2 . value2)
 (key3 . value3))

An alist can also look like this:

((key1 . value1)
 (key2 . value2)
 (key1 . oldvalue))

A plist is a property list, which is a flat list with an even number of items. It looks like this:

(key1 value1
 key2 value2
 key3 value3)

Both of these are slow. ht.el provides ht<-alist and ht<-plist to help you convert to hash tables. If you need to work with an alist or plist, use the functions ht->alist and ht->plist to convert an hash table to those formats.