user2548343
user2548343

Reputation: 789

"Symbol's function definition is void: cl-defstruct" error for my emacs script

I am trying to write an emacs script to call from the command line in the following way:

emacs --script script.el

I am running into issues when I try to include either a cl-defstruct or a defstruct in said script. For example, the following works just fine when I run it in emacs using M-x eval-buffer but fails when run as a script:

(cl-defstruct test slot)
(setq myTest (make-test))
(setf (test-slot myTest) "hello")
(message (test-slot myTest))

The above should only spit out the the message "hello" but when run as a script, I see the following error:

Loading 00debian-vars...
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading debian-ispell...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...
Loading /etc/emacs/site-start.d/50python-docutils.el (source)...
Symbol's function definition is void: cl-defstruct

The last line is particularly surprising. Any ideas why the cl-defstruct macro would not be recognized in this setting? Thanks!

Upvotes: 1

Views: 1083

Answers (1)

rimero
rimero

Reputation: 2383

Try adding (require 'cl-lib) at the top of your script.

Upvotes: 2

Related Questions