all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Sending code to *scheme* buffer and reading the result
@ 2009-08-10  3:36 Eduardo Cavazos
  2009-08-10 17:43 ` Pascal J. Bourguignon
  0 siblings, 1 reply; 2+ messages in thread
From: Eduardo Cavazos @ 2009-08-10  3:36 UTC (permalink / raw)
  To: help-gnu-emacs

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.

Thanks!

Ed


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Sending code to *scheme* buffer and reading the result
  2009-08-10  3:36 Sending code to *scheme* buffer and reading the result Eduardo Cavazos
@ 2009-08-10 17:43 ` Pascal J. Bourguignon
  0 siblings, 0 replies; 2+ messages in thread
From: Pascal J. Bourguignon @ 2009-08-10 17:43 UTC (permalink / raw)
  To: help-gnu-emacs

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__


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-08-10 17:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-10  3:36 Sending code to *scheme* buffer and reading the result Eduardo Cavazos
2009-08-10 17:43 ` Pascal J. Bourguignon

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.