From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?Q?=E5=B0=8F=E6=B1=9F=E6=B2=88?= Newsgroups: gmane.emacs.bugs Subject: bug#9261: `let' behavior is strange Date: Tue, 9 Aug 2011 10:44:20 +0800 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=90e6ba1efd266638cb04aa098a3f X-Trace: dough.gmane.org 1312857912 2290 80.91.229.12 (9 Aug 2011 02:45:12 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 9 Aug 2011 02:45:12 +0000 (UTC) Cc: 9261@debbugs.gnu.org To: Andreas Schwab Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Aug 09 04:45:08 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QqcJY-0003zV-0j for geb-bug-gnu-emacs@m.gmane.org; Tue, 09 Aug 2011 04:45:08 +0200 Original-Received: from localhost ([::1]:39670 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QqcJX-0005qZ-0e for geb-bug-gnu-emacs@m.gmane.org; Mon, 08 Aug 2011 22:45:07 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:40017) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QqcJR-0005p7-UN for bug-gnu-emacs@gnu.org; Mon, 08 Aug 2011 22:45:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QqcJO-0000CE-4P for bug-gnu-emacs@gnu.org; Mon, 08 Aug 2011 22:45:01 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:33958) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QqcJN-0000C6-UY for bug-gnu-emacs@gnu.org; Mon, 08 Aug 2011 22:44:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QqcKQ-0007QI-P3; Mon, 08 Aug 2011 22:46:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?=E5=B0=8F=E6=B1=9F=E6=B2=88?= Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 09 Aug 2011 02:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 9261 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 9261-submit@debbugs.gnu.org id=B9261.131285793228495 (code B ref 9261); Tue, 09 Aug 2011 02:46:02 +0000 Original-Received: (at 9261) by debbugs.gnu.org; 9 Aug 2011 02:45:32 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QqcJv-0007PY-MT for submit@debbugs.gnu.org; Mon, 08 Aug 2011 22:45:31 -0400 Original-Received: from mail-iy0-f182.google.com ([209.85.210.182]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QqcJq-0007PO-7w for 9261@debbugs.gnu.org; Mon, 08 Aug 2011 22:45:27 -0400 Original-Received: by iye1 with SMTP id 1so10362981iye.13 for <9261@debbugs.gnu.org>; Mon, 08 Aug 2011 19:44:20 -0700 (PDT) Original-Received: by 10.42.147.198 with SMTP id o6mr6716942icv.181.1312857860225; Mon, 08 Aug 2011 19:44:20 -0700 (PDT) Original-Received: by 10.42.170.197 with HTTP; Mon, 8 Aug 2011 19:44:20 -0700 (PDT) X-Originating-IP: [173.230.145.92] In-Reply-To: X-Google-Sender-Auth: 1ctcu7njs_90S4wJH2MZX4YSHrM X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 08 Aug 2011 22:46:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:49960 Archived-At: --90e6ba1efd266638cb04aa098a3f Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Thanks, `plist-get' does work. 2011/8/9 Andreas Schwab > =E5=B0=8F=E6=B1=9F=E6=B2=88 writes: > > > (progn (put 'defun 'x "out") > > (let ((old (plist-member (symbol-plist 'defun) 'x))) > > (message "old: %s." old) > > (put 'defun 'x "in") > > (message "old: %s." old) > > nil)) > > > > When I eval this form, I get something like this in *message* buffer: > > old: (x out). > > old: (x in). > > nil > > This has nothing to do with let. plist-member returns a tail of the > property list, and when the value of an existing property is changed > only the cdr of the cons cell is overwritten by put, so the reference to > the cons cell in `old' will follow the change. > > > If it is not a bug, how can I save the prev symbol property? > > Use plist-get or get to extract the property value, or make a copy. > > Andreas. > > -- > Andreas Schwab, schwab@linux-m68k.org > GPG Key fingerprint =3D 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED= 5 > "And now for something completely different." > --90e6ba1efd266638cb04aa098a3f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Thanks, `plist-get' does work.


2011/8/9 Andreas Schwab <schwab@linux-m68k.org>
=E5=B0=8F=E6=B1=9F=E6=B2=88 <x= iaojiang@siteshen.com> writes:

> (progn (put 'defun 'x "out")
> =C2=A0 =C2=A0 =C2=A0 =C2=A0(let ((old (plist-member (symbol-plist '= ;defun) 'x)))
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(message "old: %s." old) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(put 'defun 'x "in"= ;)
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(message "old: %s." old) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0nil))
>
> When I eval this form, I get something like this in *message* buffer:<= br> > old: (x out).
> old: (x in).
> nil

This has nothing to do with let. =C2=A0plist-member returns a tail of the property list, and when the value of an existing property is changed
only the cdr of the cons cell is overwritten by put, so the reference to the cons cell in `old' will follow the change.

> If it is not a bug, how can I save the prev symbol property?

Use plist-get or get to extract the property value, or make a copy.

Andreas.

--
Andreas Schwab, schwab@linux-m68k.= org
GPG Key fingerprint =3D 58CA 54C7 6D53 942B 1756 =C2=A001D3 44D5 214B 8276 = 4ED5
"And now for something completely different."

--90e6ba1efd266638cb04aa098a3f--