* bug#22840: 25.0.91; eieio clone creates objects with wrong name
@ 2016-02-28 19:14 Vitalie Spinu
2016-02-28 19:26 ` Vitalie Spinu
0 siblings, 1 reply; 2+ messages in thread
From: Vitalie Spinu @ 2016-02-28 19:14 UTC (permalink / raw)
To: 22840
Hi,
With new "named" class I encounter the following problem:
(defclass AA (eieio-instance-inheritor eieio-named) ()
"Soeme class")
(setq aa (AA "namedA"))
(eieio-object-name aa)
;"#<AA namedA>"
(eieio-object-name (clone aa "namedB"))
;"#<AA namedA>"
(eieio-object-name (clone aa "namedC"))
;"#<AA namedB>"
In other words clone memorises a name from the previous clone and uses
that during the object creation.
Vitalie
In GNU Emacs 25.0.91.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.16.7)
of 2016-02-28 built on galago
Repository revision: 52f64cc2e74ab83752c8f2d37ef0fc6df5ef8b30
Windowing system distributor 'The X.Org Foundation', version 11.0.11702000
System Description: Ubuntu 15.10
^ permalink raw reply [flat|nested] 2+ messages in thread
* bug#22840: 25.0.91; eieio clone creates objects with wrong name
2016-02-28 19:14 bug#22840: 25.0.91; eieio clone creates objects with wrong name Vitalie Spinu
@ 2016-02-28 19:26 ` Vitalie Spinu
0 siblings, 0 replies; 2+ messages in thread
From: Vitalie Spinu @ 2016-02-28 19:26 UTC (permalink / raw)
To: 22840
The problem seems to be because of the typo in clone for named objects. It
should be setting name to "nobj" but instead it sets to the prototype "obj":
╭──────── #475 ─ /lisp/emacs-lisp/eieio-base.el ──
│
│ (cl-defmethod clone ((obj eieio-named) &rest params)
│ "Clone OBJ, initializing `:parent' to OBJ.
│ All slots are unbound, except those initialized with PARAMS."
│ (let* ((newname (and (stringp (car params)) (pop params)))
│ (nobj (apply #'cl-call-next-method obj params))
│ (nm (slot-value obj 'object-name)))
│ (eieio-oset obj 'object-name
│ (or newname
│ (save-match-data
│ (if (and nm (string-match "-\\([0-9]+\\)" nm))
│ (let ((num (1+ (string-to-number
│ (match-string 1 nm)))))
│ (concat (substring nm 0 (match-beginning 0))
│ "-" (int-to-string num)))
│ (concat nm "-1")))))
│ nobj))
╰──────── #491 ─
Vitalie
>> On Sun, Feb 28 2016 20:14, Vitalie Spinu wrote:
> Hi,
> With new "named" class I encounter the following problem:
> (defclass AA (eieio-instance-inheritor eieio-named) ()
> "Soeme class")
> (setq aa (AA "namedA"))
> (eieio-object-name aa)
> ;"#<AA namedA>"
> (eieio-object-name (clone aa "namedB"))
> ;"#<AA namedA>"
> (eieio-object-name (clone aa "namedC"))
> ;"#<AA namedB>"
> In other words clone memorises a name from the previous clone and uses
> that during the object creation.
> Vitalie
> In GNU Emacs 25.0.91.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.16.7)
> of 2016-02-28 built on galago
> Repository revision: 52f64cc2e74ab83752c8f2d37ef0fc6df5ef8b30
> Windowing system distributor 'The X.Org Foundation', version 11.0.11702000
> System Description: Ubuntu 15.10
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-02-28 19:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-28 19:14 bug#22840: 25.0.91; eieio clone creates objects with wrong name Vitalie Spinu
2016-02-28 19:26 ` Vitalie Spinu
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).