help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sending code to *scheme* buffer and reading the result


From: Pascal J. Bourguignon
Subject: Re: Sending code to *scheme* buffer and reading the result
Date: Mon, 10 Aug 2009 19:43:33 +0200
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.3 (darwin)

Eduardo  Cavazos <wayo.cavazos@gmail.com> writes:

> Hello,
>
> Emacs' scheme-mode has code for sending a sexp to the *scheme* buffer.
> But, I need to code to send an sexp, and return the result, as an
> sexp. I'm sure somebody has done this before and I'd like to borrow
> that code if possible. I know about Jao's awesome Geiser mode and I
> could factor out the relevant parts. Just wondering about other
> possibilities.

The problem is that the emacs lisp reader cannot understand scheme syntax:

(condition-case err (read-from-string "#f")
   (error  (format "%S" err)))
--> "(invalid-read-syntax \"#\")"

So you will need to write a scheme reader function in emacs lisp.

In addition, the comint-sent-* functions that are used to communicate
with the scheme inferior process deal with strings, not sexps, so you
will have to write a scheme print function, to convert some kind of
emacs lisp sexp into strings readable by scheme.

(scheme-read-from-string "#f") --> (scheme-boolean nil)
(scheme-prin1-to-string '(scheme-boolean nil)) -> "#f"

Using these functions it will be trivial to wrap the comint functions
(and process filter output) to get a sexp-based FFI between emacs lisp
and scheme.

-- 
__Pascal Bourguignon__


reply via email to

[Prev in Thread] Current Thread [Next in Thread]