4
(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?

12

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)
| improve this answer | |
8

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.

| improve this answer | |

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.