unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Effective use of destructive functions
@ 2007-04-11 23:42 achambers.home
  2007-04-12  7:31 ` Pascal Bourguignon
  0 siblings, 1 reply; 3+ messages in thread
From: achambers.home @ 2007-04-11 23:42 UTC (permalink / raw)
  To: help-gnu-emacs

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-04-12 15:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-11 23:42 Effective use of destructive functions achambers.home
2007-04-12  7:31 ` Pascal Bourguignon
2007-04-12 15:27   ` achambers.home

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).