I’ve got this snippet of code:
(define-key lisp-interaction-mode-map (kbd "C-c C-e")
(lambda ()
(let ((result (eval (read (buffer-substring
(point-at-bol) (point-at-eol)))))
(goto-char (point-at-eol))))
(insert (format " ; => %s" result))))
but it doesn’t work, as in
Wrong type argument: commandp, (lambda nil (let ((result (eval (read (buffer-substring (point-at-bol) (point-at-eol))))) (goto-char (point-at-eol)))) (insert (format " ; => %s" result)))
This command shouldn’t function on a per-line basis. Move point by sexp instead.
Here is a library I made that does basically this, but works with mult-line
results, and is reentrant. So you can change some stuff, and re-run the
command to update results.
EDIT: correct link to package mentioned.