Last active
July 10, 2024 17:52
-
-
Save daedsidog/8c325271f970f6d78773af945e0fce02 to your computer and use it in GitHub Desktop.
Create & connect to a Windows host inferior Lisp process from Emacs on WSL with SLIME
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun wsl-host-slime (&optional command) | |
"Start a Windows inferior Lisp process in WSL and connect to it with SLIME. | |
COMMAND is the external Lisp process, defaulting to SBCL. | |
Function assumes the target Lisp process has been configured to load | |
Quicklisp on startup." | |
(interactive) | |
(let ((buffer (ansi-term (getenv "SHELL") "wsl-host-inferior-lisp")) | |
(cmd (concat (or command "sbcl") ".exe"))) | |
(with-current-buffer buffer | |
(term-send-raw-string (format "%s" cmd)) | |
(term-send-raw-string (kbd "RET")) | |
(while (not (string-match-p (upcase cmd) (buffer-string))) | |
(sit-for 1)) | |
(term-send-raw-string (concat " | |
(ql:quickload :swank) | |
(let ((swank::*loopback-interface* (uiop:hostname))) | |
(swank:create-server :port 4006 :dont-close t))" | |
(kbd "RET"))) | |
(while (not (string-match-p "Swank started at port" (buffer-string))) | |
(sit-for 1)) | |
(let* ((netstat-output (shell-command-to-string "netstat.exe -ano")) | |
(ip (when (string-match (rx (zero-or-more blank) | |
(group (one-or-more (or digit "."))) | |
":4006" (or word-end blank)) | |
netstat-output) | |
(match-string 1 netstat-output)))) | |
(slime-connect ip 4006))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment