From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ishi soichi Newsgroups: gmane.emacs.help Subject: Re: loading hash-table from a file? Date: Thu, 5 Jan 2012 18:13:15 +0900 Message-ID: References: <87mxa2o6o3.fsf@imladris.arda> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=e89a8f3ba75fa56ace04b5c4573e X-Trace: dough.gmane.org 1325754817 12113 80.91.229.12 (5 Jan 2012 09:13:37 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 5 Jan 2012 09:13:37 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Teemu Likonen Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jan 05 10:13:32 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RijO8-0000Do-9V for geh-help-gnu-emacs@m.gmane.org; Thu, 05 Jan 2012 10:13:32 +0100 Original-Received: from localhost ([::1]:50615 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RijO2-0003cP-Kh for geh-help-gnu-emacs@m.gmane.org; Thu, 05 Jan 2012 04:13:26 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:37341) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RijNy-0003cG-CJ for help-gnu-emacs@gnu.org; Thu, 05 Jan 2012 04:13:23 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RijNs-00050v-KQ for help-gnu-emacs@gnu.org; Thu, 05 Jan 2012 04:13:22 -0500 Original-Received: from mail-iy0-f169.google.com ([209.85.210.169]:55365) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RijNs-0004zh-HQ for help-gnu-emacs@gnu.org; Thu, 05 Jan 2012 04:13:16 -0500 Original-Received: by mail-iy0-f169.google.com with SMTP id b35so762303iac.0 for ; Thu, 05 Jan 2012 01:13:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=EXTKJJKMuDReG8nuGigy44rpWuIVnycu/GeiP1+l3/A=; b=esCVb2T77VlQU+u7DGOxec6IFukQhgdq36SlZ4nVRwOAVpFdW3eJqPq0iB0dSYq8kT rb9BGH7fChaJLQr5jZQZ8ksoQB6q3lFLb8pLWdMm2AA9s1BqlD6wK4wfcN6VNVu+a3CX 47zHw+3npgPX4gevWITRFi1HD70n45Nbl7how= Original-Received: by 10.50.89.197 with SMTP id bq5mr1410183igb.24.1325754795518; Thu, 05 Jan 2012 01:13:15 -0800 (PST) Original-Received: by 10.43.131.138 with HTTP; Thu, 5 Jan 2012 01:13:15 -0800 (PST) In-Reply-To: <87mxa2o6o3.fsf@imladris.arda> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.210.169 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:83348 Archived-At: --e89a8f3ba75fa56ace04b5c4573e Content-Type: text/plain; charset=ISO-8859-1 Thanks everyone. I think I works well! soichi 2012/1/5 Teemu Likonen > * 2012-01-05T10:35:18+02:00 * Valentin Baciu wrote: > > > In my Emacs 24, I can read back a printed (simple) hash table. I am > > not sure weather using more complex data types as values will also > > work. > > > > ;; Writing the hash table to a "database" file > > > > (with-current-buffer (find-file-noselect "/tmp/x") > > (let ((h (make-hash-table))) > > (puthash 'a 0 h) > > (puthash 'b 1 h) > > (insert (format "%s" h)) > > (save-buffer))) > > Use the %S format character to print objects in machine-readable (i.e., > READ) format. > --e89a8f3ba75fa56ace04b5c4573e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Thanks everyone. I think I works well!

soichi

2012/1/5 Teemu Likonen <tlikonen@iki.fi>
* 2012-01-05T10:35:18+02:00 * Valentin Baciu wrote:

> In my Emacs 24, I can read back a printed (simple) hash table. I am > not sure weather using more complex data types as values will also
> work.
>
> ;; Writing the hash table to a "database" file
>
> (with-current-buffer (find-file-noselect "/tmp/x")
> =A0 (let ((h (make-hash-table)))
> =A0 =A0 (puthash 'a 0 h)
> =A0 =A0 (puthash 'b 1 h)
> =A0 =A0 (insert (format "%s" h))
> =A0 =A0 (save-buffer)))

Use the %S format character to print objects in machine-readable (i.e= .,
READ) format.

--e89a8f3ba75fa56ace04b5c4573e--