From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Joe Corneli Newsgroups: gmane.emacs.help Subject: sharing list structure Date: Thu, 24 Mar 2005 17:48:57 -0600 Message-ID: NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1111708896 6191 80.91.229.2 (25 Mar 2005 00:01:36 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 25 Mar 2005 00:01:36 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Mar 25 01:01:35 2005 Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DEcF6-000642-Ed for geh-help-gnu-emacs@m.gmane.org; Fri, 25 Mar 2005 01:00:05 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DEcUQ-0003LZ-Ql for geh-help-gnu-emacs@m.gmane.org; Thu, 24 Mar 2005 19:15:51 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DEcOb-0001bF-Ry for help-gnu-emacs@gnu.org; Thu, 24 Mar 2005 19:09:50 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DEcOJ-0001S1-OW for help-gnu-emacs@gnu.org; Thu, 24 Mar 2005 19:09:36 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DEcOH-0001Qm-0R for help-gnu-emacs@gnu.org; Thu, 24 Mar 2005 19:09:29 -0500 Original-Received: from [146.6.139.124] (helo=dell3.ma.utexas.edu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DEc4Q-0006t4-Cg for help-gnu-emacs@gnu.org; Thu, 24 Mar 2005 18:48:58 -0500 Original-Received: from lab45.ma.utexas.edu (mail@lab45.ma.utexas.edu [128.83.133.159]) by dell3.ma.utexas.edu (8.11.0.Beta3/8.10.2) with ESMTP id j2ONmvC09064; Thu, 24 Mar 2005 17:48:57 -0600 Original-Received: from jcorneli by lab45.ma.utexas.edu with local (Exim 3.36 #1 (Debian)) id 1DEc4P-0002bS-00; Thu, 24 Mar 2005 17:48:57 -0600 Original-To: help-gnu-emacs 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 X-MailScanner-To: geh-help-gnu-emacs@m.gmane.org Xref: news.gmane.org gmane.emacs.help:25125 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:25125 I'm not sure how to do the following: I have a list A, that grows, shrinks, and changes. I want to have a list B that includes list A within its list structure, along with other things, and that automatically keeps the "A" part of itself in synch with A. If this was C, I think what I guess what I would say I want is a "pointer to A". But the elisp manual says -- A note to C programmers: in Lisp, we do not distinguish between "holding" a value and "pointing to" the value, because pointers in Lisp are implicit. So I guess what I want is an "implicit pointer" to A. Looking at the box diagrams in the manual, it seemed to me that everything would be taken care of if I used "setcdr" to build the list B. But that didn't quite work: (progn (setq A '(1 2 3)) (setq B (list 'foo)) (setcdr B A) (setq A (append A (list 4))) B) ;=> (foo 1 2 3) If I handle A with kid gloves, then B comes out right: (progn (setq A '(1 2 3)) (setq B (list 'foo)) (setcdr B A) (setcdr (nthcdr 2 A) (list 4)) B) ;=>(foo 1 2 3 4) But is this the only way to go? If it was possible, I would like to set things up so that I could do anything I wanted to do to A, and have B simply reflect that value at the end. Is there a way to accomplish this? And if it can't be done with list structure alone, what other suggestions can you make?