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: How to evaluating expressions in *inferior-lisp* buffer programatically?
Date: Sat, 14 Mar 2009 17:24:01 +0100	[thread overview]
Message-ID: <87ljr8t6n2.fsf@galatea.local> (raw)
In-Reply-To: 1c955ff2-b6a2-4ab5-bd8a-a08d0ffc97c3@13g2000yql.googlegroups.com

budu <nbuduroi@gmail.com> writes:

> Hi, I've been using Emacs for a few year, but I'm just starting to
> customize it more deeply. I wonder what is the recommended way of
> evaluating expressions in the current *inferior-lisp* buffer
> programatically? I know macros would certainly be OK for such a simple
> task, yet I tried with elisp and come up with this:
>
>     (save-current-buffer
>       (set-buffer "*inferior-lisp*")
>       (insert "(use '(foo [bar]))")
>       (lisp-eval-last-sexp)
>       (let ((s (point)))
>         (backward-sexp)
>         (delete-region s (point))))
>
> Do you know of a more straightforward way of doing this? And do you
> know of any good tutorial on basic elisp? Thanks

(defun eval-in-inferior-lisp (expression-string)
  (comint-send-string (inferior-lisp-proc) (format " %s\n" expression-string))
  (switch-to-lisp t))

(eval-in-inferior-lisp "(- 22/7 cl:pi)")



-- 
__Pascal Bourguignon__


  reply	other threads:[~2009-03-14 16:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-14 16:07 How to evaluating expressions in *inferior-lisp* buffer programatically? budu
2009-03-14 16:24 ` Pascal J. Bourguignon [this message]
2009-03-14 19:15   ` budu
2009-03-14 19:54     ` Pascal J. Bourguignon

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=87ljr8t6n2.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).