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

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

Re: How to evaluating expressions in *inferior-lisp* buffer programatic


From: budu
Subject: Re: How to evaluating expressions in *inferior-lisp* buffer programatically?
Date: Sat, 14 Mar 2009 12:15:27 -0700 (PDT)
User-agent: G2/1.0

On Mar 14, 12:24 pm, address@hidden (Pascal J. Bourguignon)
wrote:
> budu <address@hidden> 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__

Great! This will be much cleaner. Thanks


reply via email to

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