I published a new ulisp-repl
Emacs package. It provides a REPL with syntax highlighting and uses Emacs’s built-in UART support for serial port management. I wrote a blog post, which contains a screencast demonstrating its installation and use:
New Emacs package: ulisp-repl
Hi,
Install ok, i think, but when i try to run i get the following -
'Failed to access directory /dev/serial/by-id/ ; check owner and permissions
Your user – as reported by id – needs access to that directory and to the serial device node therein. Check what this reports:
M-! stat /dev/serial/by-id
For me that directory is world-readable and world-executable (rwxr-xr-x).
Maybe ulisp-repl could offer to change permissions via sudo. Does:
M-! sudo chmod -v o+rx /dev/serial/by-id && sudo chmod -v o+rw /dev/serial/by-id/*
M-x ulisp-repl
work? This assumes your user has sudo permissions.
i have a /dev/serial0 and a /dev/serial1 but no /dev/serial/
Shell command: stat /dev/serial/by-id
stat: cannot statx ‘/dev/serial/by-id’ : No such file or directory
Try:
M-: (setq ulisp-repl-serial-device-path "/dev/serial0")
M-x ulisp-repl
If that does not work, try the same with /dev/serial1. Let me know if it works.
Hi, I’m trying to use ulisp-repl
on Windows 10 with Emacs 31. I’ve added advice around ulisp--select-serial-device
such that M-x ulisp-repl
completes successfully, but as soon as I click in the *ulisp-repl*
buffer my entire Emacs process locks up and I have to terminate it via the Task Manager. If I just use M-x serial-term
it all works fine.
I poked around in the code a bit, added a bunch of (message ...)
calls and it decided to work for me, so I was able to add some functionality and it all looked good. But now having restarted Emacs it’s locking up again.
If any other Windows Emacs uLisp users can suggest anything, that would be great - my online searches haven’t given me any clues as yet. Here’s the code in my setup for uLisp:
;; Cf. https://emacs.stackexchange.com/a/68922/9437
(advice-add 'ulisp--select-serial-device :around #'jdp-select-serial-device)
(defun jdp-select-serial-device (original-function prefix)
(if (or prefix (not ulisp-repl-serial-device-path))
(let ((port-name (read-from-minibuffer "uLisp serial port: ")))
(customize-set-value 'ulisp-repl-serial-device-path port-name)))
ulisp-repl-serial-device-path)
(defun ulisp--extract-marked-object (mark-function &optional args)
(save-excursion
(push-mark)
(apply mark-function args)
(prog1
(buffer-substring-no-properties
(point)
(progn
(exchange-point-and-mark)
(point)))
(pop-mark))))
(defun ulisp--extract-surrounding-sexp ()
(save-excursion
(paredit-forward-up)
(let ((end (point))
(start (progn
(paredit-backward)
(point))))
(buffer-substring-no-properties start end))))
(defun ulisp--eval-text-in-repl (text)
(let ((text (concat (string-trim text) "\n")))
(process-send-string (get-buffer-process "*ulisp-repl*") text)))
(defun ulisp-eval-buffer-in-repl ()
(interactive)
(ulisp--eval-text-in-repl (ulisp--extract-marked-object #'mark-whole-buffer)))
(defun ulisp-eval-defun-in-repl ()
(interactive)
(ulisp--eval-text-in-repl (ulisp--extract-marked-object #'mark-defun)))
(defun ulisp-eval-sexp-in-repl ()
(interactive)
(ulisp--eval-text-in-repl (ulisp--extract-surrounding-sexp)))
(global-set-key (kbd "C-c M-h") 'ulisp-eval-buffer-in-repl)
(global-set-key (kbd "C-c M-e") 'ulisp-eval-defun-in-repl)
(global-set-key (kbd "C-c M-2") 'ulisp-eval-sexp-in-repl)
(Is there any Lisp highlighting set up for code blocks on this Discourse?)
Try running make-serial-process
manually with eval-expression
(M-:
), hard-coding the device path:
(make-serial-process :name "ulisp-serial" :port "<DEVICE-PATH>" :speed 9600 :buffer (get-buffer-create "ulisp-test"))
Does that result in a lock-up? How are you invoking serial-term
such that it works? Can you share the device path? Also ensure that nothing else on the system is accessing the serial port at the same time.
Hi Thomas, thanks for your reply. I tried your make-serial-process
call and that didn’t trigger the lock-up. As I said I was just typing M-x serial-term
and entering COM4
for the port (the buffer name then is \\.\COM4
). serial-term
will fail with an error message when the port is opened by another process so I don’t think that’s the problem.
OK, so testing it again now it seems to be working again? I’ve restarted my Emacs a few times and ulisp-repl
seems happy to start up now. So I guess I’m sorted? Fingers crossed! :)
OK, if it starts locking up again, maybe try with emacs -Q
to make sure no other modes are interfering, and also you could try selectively commenting out the mode-specific startup code to see if one of those lines is causing the hang. Glad to hear it is working for now.