Step 1

make-toggle-func returns a anonymous function ...

(defun make-toggle-func (book-name repl-name code-file)
  `(function (lambda (x)

           (setq book-name ,book-name
             repl-name ,repl-name
             code-file ,code-file)



  (fset 'el-toggle (make-toggle-func  "eintr.pdf"

Step: 3

(funcall (symbol-function 'el-toggle))

Error: I'm getting the following error. Please help?

*** Eval error ***  Invalid function: (function (lambda (x) (interactive) (setq book-name "eintr.pdf" repl-name "*ielm*" code-file "ch01-02.el")))
  • (function ...) is a special form, like (quote ...) - you don't need to quote it. – wvxvw Oct 30 '16 at 16:25

You have apparently not yet learned how to define a function using defun. Why would you be fiddling with fset?

See the Elisp manual, node Defining Functions, for how to define an Elisp function.

It's hard to help you further, as the aim of your code is unclear -- what you are trying to do; what you expect your function to do; how you expect to call it.

But what @wvxvw suggested in a comment might be a start: A lambda form is self-evaluating. And fset expects a function as its second argument, not just a list whose first element is function.

Maybe something like this will help.

(defun make-toggle-func (book-name repl-name code-file)
  (lambda () (toggle-between-book-and-code)))

(fset 'el-toggle (make-toggle-func  "eintr.pdf" "*ielm*"  "ch01-02.el"))

(funcall 'el-toggle)

If you call el-toggle with no arguments then it must be able to be so called. So the lambda must not require an argument. Alternatively, if the lambda has an arg then you must provide a second arg to funcall.

But the command makes no use of its arguments, and its definition is the same as this:

(defun make-toggle-func (book-name repl-name code-file)

I'd say it looks like you need to start over, and figure out just what you are trying to do. Follow up with a specific question here, if you have trouble after trying at that point.

  • thanks for your answer, tho' sultry, was saner... 1) I'm learning ELisp (and Lisp of course). 2) My concepts are not strong. 3) I tried to bite more than I could chew (as I always do) 4) that code had bugs. I posted buggy code and I apologise a) that x was not supposed to be there b) and the function form. 5) I had been staring at this piece of code for so long that I'd nearly become lost. Hence I sought help... Please find below the code listing of what I was doing... it works now... thanks for your answer again... – user13822 Oct 30 '16 at 18:44
  • also user13822 & obyz are both my display names... don't know how to fix that mess... I'll figure it out later I guess... – user13822 Oct 30 '16 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.