Using Emacs 25.1.50.1
To set the slot of a structure, I believe the elisp manual says to use setq
along with the accessor function for the slot. Though I am having trouble.
The following code results in an error on the fourth line.
(require 'cl)
(cl-defstruct foo name)
(setq bar (make-foo :name 'john))
(setq (foo-name bar) 'jim)
Message:
eval: Wrong type argument: symbolp, (progn "Access slot \"name\" of `foo' struct CL-X." nil (or (progn nil (and (vectorp bar) (>= (length bar) 2) (memq (aref bar 0) cl-struct-foo-tags) t)) (signal (quote wrong-type-argument) (list (quote foo) bar))) (aref bar 1))
Also there is no cl
tag to use for the Emacs Common Lisp Emulation Library... don't know what else to put it under, just going to put it under common-lisp
for someone to help me find the right tag.
setf
instead ofsetq
. – syohex Sep 28 '16 at 00:28