unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: pjb@informatimago.com (Pascal J. Bourguignon)
To: help-gnu-emacs@gnu.org
Subject: Re: Sending code to *scheme* buffer and reading the result
Date: Mon, 10 Aug 2009 19:43:33 +0200	[thread overview]
Message-ID: <871vnj5zui.fsf@galatea.local> (raw)
In-Reply-To: f1803a20-53aa-4861-be8e-4c46d9b56a4b@f10g2000vbf.googlegroups.com

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	other threads:[~2009-08-10 17:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-10  3:36 Sending code to *scheme* buffer and reading the result Eduardo Cavazos
2009-08-10 17:43 ` Pascal J. Bourguignon [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871vnj5zui.fsf@galatea.local \
    --to=pjb@informatimago.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).