From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "achambers.home@googlemail.com" Newsgroups: gmane.emacs.help Subject: Effective use of destructive functions Date: 11 Apr 2007 16:42:42 -0700 Organization: http://groups.google.com Message-ID: <1176334962.373893.13990@w1g2000hsg.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: sea.gmane.org 1176338187 15958 80.91.229.12 (12 Apr 2007 00:36:27 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 12 Apr 2007 00:36:27 +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 Apr 12 02:36:19 2007 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 1HbnIR-0000JT-Jy for geh-help-gnu-emacs@m.gmane.org; Thu, 12 Apr 2007 02:36:19 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HbnMX-0008Rg-Mg for geh-help-gnu-emacs@m.gmane.org; Wed, 11 Apr 2007 20:40:33 -0400 Original-Path: shelby.stanford.edu!newshub.stanford.edu!postnews.google.com!w1g2000hsg.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 28 Original-NNTP-Posting-Host: 86.1.196.236 Original-X-Trace: posting.google.com 1176334963 14868 127.0.0.1 (11 Apr 2007 23:42:43 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 11 Apr 2007 23:42:43 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.9) Gecko/20061205 (Debian-1.8.0.9-1) Epiphany/2.14 Firefox/1.5.0.7,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: w1g2000hsg.googlegroups.com; posting-host=86.1.196.236; posting-account=OOX4TQ0AAADlkVZCWJTQRIpMj0KSWHiw Original-Xref: shelby.stanford.edu gnu.emacs.help:146994 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:42598 Archived-At: Here's some code.... (setq doc '(root (child 1 2) (child 3 4))) (setq editable-child (car (cdr doc))) ;; (setq editable-child (mapcan (lambda (x) ;; (cons x nil)) editable-child)) (setcdr editable-child '(10 11)) editable-child doc It seems that in the commented sexp, altering the symbol editable-child using setcdr has no effect on doc because the contents of editable-child is a copy of the contents of doc rather than a direct reference to a particular `place' in doc. This is a stripped down version of my real problem which is to creating a number of widgets out of the data in doc. I want to make a :notify function for each widget that updates doc when an element of the tree is edited. My question is...How can you run the contents of editable-child through a mapping function, and keep the structure so that any changes to the return value carry on up to doc? Many Thanks, Andy Chambers