The question pretty much says it all: I have a string containing the source code for a valid Elisp expression, and I would like to evaluate it.
@xameer it’s funny, because the answer to this question for Emacs Lisp is the same as most other Lisp dialects, and as far as I know, has been the same answer since 1958:
(eval (read "..."))To take it a step further and make a read-eval-print loop, it is simply:
(while (not (eq :quit (prin1 (eval (read))))))Or equivalently:
(defalias 'print 'prin1) (defmacro loop (expr) `(while (not (eq :quit ,expr)))) (loop (print (eval (read)))) ;; enter ":quit" to quit the loopHence the name “REPL”.