I do remember I had to use an awful hack to make it work. Comint expects data from a pipe, but eLisp output is internal to Emacs. The details are hazy now, I but I think I pushed the eval result as stdin to a ‘cat’ process for Comint to ingest the output. I wonder if that ever got cleaned up…
And of course now I have a persistent history of all commands.
Thank you!
Looking at ielm.el, it appears it now defaults to hexl, which is part of the Emacs distribution, as cat might not exist on non-Unix platforms. That's wrapped in a condition-case call though, and will still call cat if that fails.
Such a useful tool even if elisp has limited debugging capabilities :)
I feel it’s pretty essential to using emacs.
* Lisp Interaction mode (like in your `scratch` buffer). Press `C-j` to eval the expression to left of the point, and insert the result in your buffer. Then you can leave the result there, edit it into a new code, undo to hide it, etc.
* Emacs Lisp mode (like when you're editing any `.el` file) can also do a lot of things that people normally do in a REPL. Say, you're working on some code in the file, and it's running, and you want to change one of the functions. Just edit the function in the file, and hit `M-C-x` to evaluate the `defun` that the point is in, and see the value in the echo area. Or evaluate a region, or the entire file. (At one point, I also had a pretty-printer hooked up, so that it could do better transient display of values.) You can also selectively instrument functions for Edebug from here.
This seems simple today, but it used to blow away the development languages and tools most people were using.
could be the emacs manual title (or any large system tbh)
https://www.masteringemacs.org/article/evaluating-elisp-emac...
It is somewhere there because undo knows it. Typical example is that you fumble something splendid/stupid with fat fingers and then cant figure out what you just did.
* Eshell (launched with M-x eshell) is a shell in Emacs which uses a language that has elements from elisp. In particular, expressions in parentheses are evaluated as elisp forms [1]. Eshell is a shell (like e.g. bash), so it also has syntax to conveniently evaluate external commands, though it lacks some common shell functionality such as job control [2] and some types of redirection [3].
* Org Babel elisp source blocks [4,5]: In Org mode, use "#+begin_src elisp" and "#+end_src" to delimit lines with elisp and evaluate using C-c C-c, which will, by default, insert the result of the evaluation below the source block. This can be useful, if you want to keep a more organized record of the evaluated commands and their results in comparison to a REPL.
[1] https://www.gnu.org/software/emacs/manual/html_mono/eshell.h...
[2] https://www.gnu.org/software/emacs/manual/html_mono/eshell.h...
[3] https://www.gnu.org/software/emacs/manual/html_mono/eshell.h...
[4] https://orgmode.org/manual/Working-with-Source-Code.html
[5] https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-...
Why did not I know that?
-- Because (view-lossage) is weird name for this.
I asked chat gpt about it, and what it said seemed to match what I found when I googled it:
> In Emacs, “Lossage” refers to a section in the GNU Emacs Manual that describes how to recognize and deal with situations in which Emacs does not work as expected1. For example, it covers issues such as keyboard code mixups, garbled displays, running out of memory, and crashes and hangs1.
> There is also a command called view-lossage that displays the last 300 input keystrokes2. You can use open-dribble-file to record all your input on a file2.