jacob
jacob

Reputation: 2424

Creating a closure around a private function in elisp

In elisp I have the following

(setq lexical-binding t)



 (fset 'boom (cl-flet*
               ((tickle ()
                        (message "hi"))
                (pickle ()
                        (tickle)))
             (lambda ()
               (pickle))))
(boom)

When I run the boom function I get the error

Symbol's value as variable is void: --cl-pickle--

What's going on here?

My intent is I would like to wrap private/helper functions and variables in a closure so I can better organize my code than everything being global.

Upvotes: 3

Views: 324

Answers (1)

Stefan
Stefan

Reputation: 28541

Don't (setq lexical-binding t). You don't want to execute a command that sets this variable. Instead you want to describe to Emacs that the code you write uses lexical binding, and for that you need to add:

-*- lexical-binding:t -*-

somewhere on the first line of the file.

Upvotes: 4

Related Questions