1 hour ago · Tech · 0 comments

The Lisp Machine Listener had an electric close parenthesis. When the user typed a close parenthesis, and this was the close parenthesis that finished the complete form at top level, the form would be sent to the REPL right away with no need to press enter. Here's how to get this behavior with SLY: (defun my-sly-mrepl-electric-close-paren () "Insert ')' and auto-send ONLY if we are closing a top-level Lisp form." (interactive) (let ((state (syntax-ppss))) (insert ")") ;; Safety checks: ;; 1. We were at depth 1 (so we are now at depth 0) ;; 2. We aren't in a string or comment ;; 3. The input actually starts with a paren (it's a form, not a sentence) (when (and (= (car state) 1) (not (nth 3 state)) (not (nth 4 state)) (string-match-p "^\\s-*(" (buffer-substring-no-properties (sly-mrepl--mark) (point)))) (sly-mrepl-return)))) Another cool hack is to get the REPL to do double duty as a command line to the LLM chatbot. When you type RET in the REPL, it will check if the input is a complete…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.