Customizing Lisp REPLs

https://news.ycombinator.com/rss Hits: 6
Summary

Customizing Lisp REPLs By Artyom Bologov Oh, I see you disabled JavaScript. Keep up the good work, my fellow cleanweb person! I am a portability freak. If something can be done with an existing tool, I’ll go for it. If the program can be portable across systems, then it should be. If I can get rid of a tool or a whole class of tools, then off with its head! Sometimes that costs me, but that’s what I am. You can already see why I might dislike custom/wrapper/proxy REPLs. They are a new layer of tools reinventing what’s already there in the underlying REPL, and doing so in an ad-hoc incompatible way. A nightmare, albeit sometimes a comfy one. Still, we don’t have to live with the horrors of proxy REPLs! We can have existing REPLs incrementally improved for lasting and universal benefit. So let’s do just that. SBCL SBCL SBCL For some reason, default REPL in SBCL is extremely simple and has no extension points. Some of the customizations below won’t work, unless you enable, say, sb-aclrepl extension: (require "sb-aclrepl") Getting an Allegro-like REPL in SBCL Welcoming Prompt # The first thing you see when you launch a Common Lisp REPL is the prompt. Sometimes ugly, sometimes not so. But always open for improvement. That improvement is what my Trivial Toplevel Prompt library does. Allowing one to define regular, debug, inspector, and otherwise special REPL prompts. All in a portable way, because, apparently, most implementations allow customizing the prompt. (Except for maybe SBCL, because customizing REPL there requires redefining a bunch of functions or using sb-aclrepl.) Details varying between implementations, prompts can include: Process/thread name Evaluation package Command number Debug level Stepping and inspection indicators All of these are portably supported by Trivial Toplevel Prompt. Without the need for any REPL preprocessing or function redefinition! Here’s the prompt I ended up with for my personal use: (trivial-toplevel-prompt:set-toplevel-prompt "~*~a~...

First seen: 2025-08-20 10:11

Last seen: 2025-08-20 15:19