From: "achambers.home@googlemail.com" <achambers.home@googlemail.com>
To: help-gnu-emacs@gnu.org
Subject: Effective use of destructive functions
Date: 11 Apr 2007 16:42:42 -0700 [thread overview]
Message-ID: <1176334962.373893.13990@w1g2000hsg.googlegroups.com> (raw)
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
next reply other threads:[~2007-04-11 23:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-11 23:42 achambers.home [this message]
2007-04-12 7:31 ` Effective use of destructive functions Pascal Bourguignon
2007-04-12 15:27 ` achambers.home
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1176334962.373893.13990@w1g2000hsg.googlegroups.com \
--to=achambers.home@googlemail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.