GNU bug report logs - #9261
`let' behavior is strange

Previous Next

Package: emacs;

Reported by: 小江沈 <xiaojiang <at> siteshen.com>

Date: Mon, 8 Aug 2011 15:46:02 UTC

Severity: normal

Tags: notabug

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 9261 in the body.
You can then email your comments to 9261 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9261; Package emacs. (Mon, 08 Aug 2011 15:46:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to 小江沈 <xiaojiang <at> siteshen.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 08 Aug 2011 15:46:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: 小江沈 <xiaojiang <at> siteshen.com>
To: bug-gnu-emacs <at> gnu.org
Subject: `let' behavior is strange
Date: Mon, 8 Aug 2011 15:49:04 +0800
[Message part 1 (text/plain, inline)]
(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

I thought it should be:
old: (x out).
old: (x out).
nil

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

Thank you.



In GNU Emacs 23.3.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.4)
 of 2011-04-11 on brahms, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.11002000
configured using `configure  '--build' 'x86_64-linux-gnu' '--build'
'x86_64-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib'
'--libexecdir=/usr/lib' '--localstatedir=/var/lib'
'--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes'
'--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.3/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.3/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/23.3/leim'
'--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars'
'build_alias=x86_64-linux-gnu' 'CFLAGS=-DDEBIAN -g -O2' 'LDFLAGS=-g'
'CPPFLAGS=''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.utf8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
M-x r e p o <tab> r <tab> <return>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Making completion list...

Load-path shadows:
/usr/share/emacs/23.3/site-lisp/debian-startup hides
/usr/share/emacs/site-lisp/debian-startup
/usr/share/emacs/23.3/site-lisp/dictionaries-common/flyspell hides
/usr/share/emacs/23.3/lisp/textmodes/flyspell
/usr/share/emacs/23.3/site-lisp/dictionaries-common/ispell hides
/usr/share/emacs/23.3/lisp/textmodes/ispell

Features:
(shadow sort mail-extr message sendmail regexp-opt ecomplete rfc822 mml
mml-sec password-cache mm-decode mm-bodies mm-encode mailcap mail-parse
rfc2231 rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util
netrc time-date mm-util mail-prsvr gmm-utils wid-edit mailheader canlock
sha1 hex-util hashcash mail-utils emacsbug help-mode easymenu view
tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd
font-setting tool-bar dnd fontset image fringe lisp-mode register page
menu-bar rfn-eshadow timer select scroll-bar mldrag mouse jit-lock
font-lock syntax facemenu font-core frame cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew
greek romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button
minibuffer faces cus-face files text-properties overlay md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process dbusbind system-font-setting
font-render-setting gtk x-toolkit x multi-tty emacs)
[Message part 2 (text/html, inline)]

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9261; Package emacs. (Mon, 08 Aug 2011 17:18:01 GMT) Full text and rfc822 format available.

Message #8 received at 9261 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: 小江沈 <xiaojiang <at> siteshen.com>
Cc: 9261 <at> debbugs.gnu.org
Subject: Re: bug#9261: `let' behavior is strange
Date: Mon, 08 Aug 2011 19:15:53 +0200
小江沈 <xiaojiang <at> siteshen.com> 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 <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9261; Package emacs. (Tue, 09 Aug 2011 02:46:02 GMT) Full text and rfc822 format available.

Message #11 received at 9261 <at> debbugs.gnu.org (full text, mbox):

From: 小江沈 <xiaojiang <at> siteshen.com>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: 9261 <at> debbugs.gnu.org
Subject: Re: bug#9261: `let' behavior is strange
Date: Tue, 9 Aug 2011 10:44:20 +0800
[Message part 1 (text/plain, inline)]
Thanks, `plist-get' does work.


2011/8/9 Andreas Schwab <schwab <at> linux-m68k.org>

> 小江沈 <xiaojiang <at> siteshen.com> 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 <at> linux-m68k.org
> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
> "And now for something completely different."
>
[Message part 2 (text/html, inline)]

Added tag(s) notabug. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 10 Aug 2011 06:39:04 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 9261 <at> debbugs.gnu.org and 小江沈 <xiaojiang <at> siteshen.com> Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 10 Aug 2011 06:39:06 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 07 Sep 2011 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 13 years and 289 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.