6
(let (lineStr (thing-at-point 'line t))
   (body-form......))

throws the error,

call-interactively: `let' bindings can have only one value-form: thing-at-point, (quote line), t [2 times]

Can't a let variable take a elisp form, and eval the form, get its value assigned?

2 Answers 2

14

Read the documentation: C-hf let RET

let is a special form in `C source code'.

(let VARLIST BODY...)

Bind variables according to VARLIST then eval BODY.
The value of the last form in BODY is returned.
Each element of VARLIST is a symbol (which is bound to nil)
or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of VALUEFORM).
All the VALUEFORMs are evalled before any symbols are bound.

So VARLIST is a list:

(let (...)
  BODY)

And elements which bind values are also lists:

(let ((SYMBOL VALUEFORM)
      (SYMBOL VALUEFORM))
  BODY)
9

You're missing a necessary set of parentheses around the VARLIST. Your code should look like this:

(let ((lineStr (thing-at-point 'line t))) (body-form......))

(See the documentation for 'let' at 'C-h f let'.) The purpose of the VARLIST being a list is to allow multiple variables to be bound within a single 'let'. The extra parentheses separate the VARLIST from the BODY.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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