* bug#9261: `let' behavior is strange
@ 2011-08-08 7:49 小江沈
2011-08-08 17:15 ` Andreas Schwab
0 siblings, 1 reply; 3+ messages in thread
From: 小江沈 @ 2011-08-08 7:49 UTC (permalink / raw)
To: 9261
[-- Attachment #1: Type: text/plain, Size: 3489 bytes --]
(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)
[-- Attachment #2: Type: text/html, Size: 4745 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#9261: `let' behavior is strange
2011-08-08 7:49 bug#9261: `let' behavior is strange 小江沈
@ 2011-08-08 17:15 ` Andreas Schwab
2011-08-09 2:44 ` 小江沈
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2011-08-08 17:15 UTC (permalink / raw)
To: 小江沈; +Cc: 9261
小江沈 <xiaojiang@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@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#9261: `let' behavior is strange
2011-08-08 17:15 ` Andreas Schwab
@ 2011-08-09 2:44 ` 小江沈
0 siblings, 0 replies; 3+ messages in thread
From: 小江沈 @ 2011-08-09 2:44 UTC (permalink / raw)
To: Andreas Schwab; +Cc: 9261
[-- Attachment #1: Type: text/plain, Size: 1103 bytes --]
Thanks, `plist-get' does work.
2011/8/9 Andreas Schwab <schwab@linux-m68k.org>
> 小江沈 <xiaojiang@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@linux-m68k.org
> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
> "And now for something completely different."
>
[-- Attachment #2: Type: text/html, Size: 1681 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-08-09 2:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-08 7:49 bug#9261: `let' behavior is strange 小江沈
2011-08-08 17:15 ` Andreas Schwab
2011-08-09 2:44 ` 小江沈
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).