From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Niels Giesen Newsgroups: gmane.emacs.help Subject: Re: print hash table to disk and reread in hash table Date: Thu, 28 Aug 2008 10:36:51 +0200 Organization: A noiseless patient Spider Message-ID: <87ljyh5ye4.fsf@gmail.com> References: <34f9604c-a23b-4ad9-9c84-f45884a6df23@x16g2000prn.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1219913300 30004 80.91.229.12 (28 Aug 2008 08:48:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 28 Aug 2008 08:48:20 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Aug 28 10:49:14 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KYdBn-0001BU-Rk for geh-help-gnu-emacs@m.gmane.org; Thu, 28 Aug 2008 10:49:12 +0200 Original-Received: from localhost ([127.0.0.1]:35174 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KYdAp-0001OP-D4 for geh-help-gnu-emacs@m.gmane.org; Thu, 28 Aug 2008 04:48:11 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!newsfeed.straub-nv.de!news.motzarella.org!motzarella.org!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 28 Original-X-Trace: feeder.motzarella.org U2FsdGVkX18ysZY+wi3BJqk2DLDK8y/+IQ9VNyN0puE7B2AGPwMBSF9Ps8gqaKyZQFANcVAA2pGpkkp5bvTxlCxlhEHESDY/A85v1dIlHaNjQtYkFxqvSh5pb371FCjyvNAznGsHvFE= Original-X-Complaints-To: Please send complaints to abuse@motzarella.org with full headers Original-NNTP-Posting-Date: Thu, 28 Aug 2008 08:36:54 +0000 (UTC) X-Auth-Sender: U2FsdGVkX1+z5kWjSNrYvWA3eGJAP/NU Cancel-Lock: sha1:kC3AiL19f3yirJuzVL4i2i6ZXUU= sha1:wadHw4k/DdfBjJdNjHrn0asVox0= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) Original-Xref: news.stanford.edu gnu.emacs.help:161706 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:57068 Xah 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)))