help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: print hash table to disk and reread in hash table


From: Niels Giesen
Subject: Re: print hash table to disk and reread in hash table
Date: Thu, 28 Aug 2008 10:36:51 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

Xah <xahlee@gmail.com> writes:

> if i have a hash table in elisp, is there a way to save it to disk and
> reread in when starting emacs?
>
> Thanks.
>
>   Xah
>http://xahlee.org/
>
>

You might use this code (I use it in gimp-mode):

(defmacro gimp-hash-to-list (hash-table)
  (let ((nl (gensym)))
    `(let (,nl)
       (maphash (lambda (k v)
                  (push (list k v) ,nl)) ,hash-table)
       ,nl)))

(defmacro gimp-list-to-hash (list)
  (let ((ht (gensym)))
    `(let ((,ht (make-hash-table)))
       (mapc (lambda (item)
               (puthash (car item) (cadr item) ,ht)) ,list)
       ,ht)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]