From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Navy Cheng Newsgroups: gmane.emacs.help Subject: Re: How to use a symbol and its value to create alist? Date: Wed, 12 Aug 2015 09:46:23 +0800 Message-ID: <20150812014623.GB22098@debian> References: <20150811135254.GA20200@debian> <20150811151533.17219.21BE0C0D@ahiker.mooo.com> Reply-To: Navy Cheng NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1439344015 6586 80.91.229.3 (12 Aug 2015 01:46:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 12 Aug 2015 01:46:55 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Aug 12 03:46:46 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZPL7u-0006sk-MW for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Aug 2015 03:46:46 +0200 Original-Received: from localhost ([::1]:36350 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPL7t-00046X-U6 for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Aug 2015 21:46:45 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:32851) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPL7j-00044h-9o for help-gnu-emacs@gnu.org; Tue, 11 Aug 2015 21:46:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZPL7f-0002QL-9V for help-gnu-emacs@gnu.org; Tue, 11 Aug 2015 21:46:35 -0400 Original-Received: from m15-113.126.com ([220.181.15.113]:52182) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPL7b-0002NU-Cc for help-gnu-emacs@gnu.org; Tue, 11 Aug 2015 21:46:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=Date:From:Subject:Message-ID:MIME-Version; bh=GGgVg 10ZDPzfYbaNSuxbh6f/fIo2KVOjTBThEkcscg0=; b=dv7CpK6mNxVPC/Ow9u2qG JoDsnXCogvmaSKSm/IfBT4HWM64CJVBSdj1Ia+xNnPbsJiIK+BX6n/ZCwDfq68hG 7x7Uuu476WT+8lc8pvATOd/c6zDvGY+VZaOHGKZNu+hD6moxapoaggNW3+PjdQ39 nN9psTseqbOU45DOq7IgUQ= Original-Received: from localhost (unknown [140.207.196.4]) by smtp3 (Coremail) with SMTP id DcmowACHGSxvpcpV1FUdAA--.13119S3; Wed, 12 Aug 2015 09:46:23 +0800 (CST) Content-Disposition: inline In-Reply-To: <20150811151533.17219.21BE0C0D@ahiker.mooo.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-CM-TRANSID: DcmowACHGSxvpcpV1FUdAA--.13119S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrKr4DZw45uFW8tryrurW3Wrg_yoWfArbEq3 4fCryfuw15Zr4jkr1rJ3WDtwn8t395uws7J3y5trZFy3Wjva1fGr9rKFyI9w13AFnxAr1a va9IyryjgrnFvjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU0jjg5UUUUU== X-Originating-IP: [140.207.196.4] X-CM-SenderInfo: 5qdy5ubk6rjloofrz/1tbicw9UDVUwzHiZ1QAAs4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 220.181.15.113 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:106483 Archived-At: On Tue, Aug 11, 2015 at 08:21:53AM -0700, Ian Zimmerman wrote: > On 2015-08-11 21:52 +0800, Navy Cheng wrote: > > > (setq a 1) > > (setq b 2) > > (setq c 3) > > > > How can I a alist, like: > > ((a . 1) (b . 2) (c .3)) > > > > The value of a, b and c may change, so don't do this like > > (setq tree ((a . 1) (b . 2) (c .3))) > > That's a strange question. Why would you want such a list, how would > it be useful? To look up the value a a symbol, you just use it, for > example: I need to push some global variable to a "stack" and pop them later. If I don't do like this, the global variables will be changed by program > (setq a 1) > > ... > > (message "a=%d" a) > > => a=1 > > In some special situations where a symbol is not evaluated (such as when > playing with macros) you may need to use symbol-value. But I'm guessing > you're not at that point. > My question has been solved. What I want is (setq trees `((a . ,a) (b . ,b) (c . ,c))) Thanks any way.