From: Nathan Baum
Subject: Access REPL's history in CLISP
Date: 
Message-ID: <1168213662.525078.58710@i15g2000cwa.googlegroups.com>
Can one do this?

I want to preserve the REPL's history between invocations of CLISP.
Obviously, I'll have to be able to access the history in order to do
that, and I'd like it if there was a slightly easier option than
writing my own REPL.

From: Sam Steingold
Subject: Re: Access REPL's history in CLISP
Date: 
Message-ID: <m3slemw86r.fsf@loiso.podval.org>
> * Nathan Baum <···········@ogvagrearg.pbz> [2007-01-07 15:47:42 -0800]:
>
> Can one do this?
>
> I want to preserve the REPL's history between invocations of CLISP.
> Obviously, I'll have to be able to access the history in order to do
> that, and I'd like it if there was a slightly easier option than
> writing my own REPL.

you can use
http://clisp.cons.org/impnotes/readline-mod.html
and the usual readline facilities to save & retrieve REPL history.



-- 
Sam Steingold (http://sds.podval.org/) on Fedora Core release 6 (Zod)
http://ffii.org http://openvotingconsortium.org http://camera.org
http://jihadwatch.org http://thereligionofpeace.com
Don't use force -- get a bigger hammer.
From: Nathan Baum
Subject: Re: Access REPL's history in CLISP
Date: 
Message-ID: <1168228647.918550.163490@51g2000cwl.googlegroups.com>
Sam Steingold wrote:
> > * Nathan Baum <···········@ogvagrearg.pbz> [2007-01-07 15:47:42 -0800]:
> >
> > Can one do this?
> >
> > I want to preserve the REPL's history between invocations of CLISP.
> > Obviously, I'll have to be able to access the history in order to do
> > that, and I'd like it if there was a slightly easier option than
> > writing my own REPL.
>
> you can use
> http://clisp.cons.org/impnotes/readline-mod.html
> and the usual readline facilities to save & retrieve REPL history.

Huh. I assumed that wouldn't use the same history as CLISP.

  ;; .clisprc.lisp
  (readline:read-history "~/.clisp.history")

  (push (lambda () (readline:write-history "~/.clisp.history"))
        *fini-hooks*)

Now I just need to find out how to stop it saying

  ;; Loading file /home/nbaum/.clisprc.lisp ...
  ;; Loaded file /home/nbaum/.clisprc.lisp

CLISP is far too noisy. :-P
From: Nathan Baum
Subject: Re: Access REPL's history in CLISP
Date: 
Message-ID: <1168229449.738188.199940@38g2000cwa.googlegroups.com>
Nathan Baum wrote:
> Sam Steingold wrote:
> > > * Nathan Baum <···········@ogvagrearg.pbz> [2007-01-07 15:47:42 -0800]:
> > >
> > > Can one do this?
> > >
> > > I want to preserve the REPL's history between invocations of CLISP.
> > > Obviously, I'll have to be able to access the history in order to do
> > > that, and I'd like it if there was a slightly easier option than
> > > writing my own REPL.
> >
> > you can use
> > http://clisp.cons.org/impnotes/readline-mod.html
> > and the usual readline facilities to save & retrieve REPL history.
>
> Huh. I assumed that wouldn't use the same history as CLISP.
>
>   ;; .clisprc.lisp
>   (readline:read-history "~/.clisp.history")
>
>   (push (lambda () (readline:write-history "~/.clisp.history"))
>         *fini-hooks*)

Hmm. Those functions don't expand ~. How delightful.

> Now I just need to find out how to stop it saying
>
>   ;; Loading file /home/nbaum/.clisprc.lisp ...
>   ;; Loaded file /home/nbaum/.clisprc.lisp
>
> CLISP is far too noisy. :-P

In fact, this is a deal breaker. If loading the RC generates output,
*lots* of Unix tools will break when I use them with CLISP scripts,
even if CLISP's obnoxious banner is disabled. This is a big
disincentive for using the RC in the first place. Why it can't use
stderr (or, better, not produce all this output when it's running
non-interactively), I can't fathom.

It works when I customize the image to automatically run it at startup,
though. So the problem is solved.
From: Bill Atkins
Subject: Re: Access REPL's history in CLISP
Date: 
Message-ID: <not-a-real-email-86CCD5.00305008012007@host86-26-113-128.not-set-yet.ntli.net>
In article <························@38g2000cwa.googlegroups.com>,
 "Nathan Baum" <···········@btinternet.com> wrote:

> Hmm. Those functions don't expand ~. How delightful.

#P"~/.clisp.history"
From: sds
Subject: Re: Access REPL's history in CLISP
Date: 
Message-ID: <1168289499.455926.293450@s34g2000cwa.googlegroups.com>
Nathan Baum wrote:
> Now I just need to find out how to stop it saying
>
>   ;; Loading file /home/nbaum/.clisprc.lisp ...
>   ;; Loaded file /home/nbaum/.clisprc.lisp
>
> CLISP is far too noisy. :-P

see *load-verbose*
http://www.lisp.org/HyperSpec/Body/fun_load.html
http://clisp.cons.org/impnotes/clisp.html#opt-verbose
http://clisp.cons.org/impnotes/system-dict.html#loadfile

Sam.
From: Novus
Subject: Re: Access REPL's history in CLISP
Date: 
Message-ID: <2007010723383116807-novus@ngoqdeorg>
On 2007-01-07 18:47:42 -0500, "Nathan Baum" <···········@btinternet.com> said:

> Can one do this?
> 
> I want to preserve the REPL's history between invocations of CLISP.
> Obviously, I'll have to be able to access the history in order to do
> that, and I'd like it if there was a slightly easier option than
> writing my own REPL.

Compile clisp without readline support. Then use rlwrap.

Novus
From: Nathan Baum
Subject: Re: Access REPL's history in CLISP
Date: 
Message-ID: <1168233025.563429.51410@42g2000cwt.googlegroups.com>
Novus wrote:
> On 2007-01-07 18:47:42 -0500, "Nathan Baum" <···········@btinternet.com> said:
>
> > Can one do this?
> >
> > I want to preserve the REPL's history between invocations of CLISP.
> > Obviously, I'll have to be able to access the history in order to do
> > that, and I'd like it if there was a slightly easier option than
> > writing my own REPL.
>
> Compile clisp without readline support. Then use rlwrap.

Excellent! I don't need it for CLISP any more, but it seems to work
great with SBCL.

> Novus
From: Pascal Bourguignon
Subject: Re: Access REPL's history in CLISP
Date: 
Message-ID: <873b6m75l1.fsf@thalassa.informatimago.com>
"Nathan Baum" <···········@btinternet.com> writes:

> Can one do this?
>
> I want to preserve the REPL's history between invocations of CLISP.
> Obviously, I'll have to be able to access the history in order to do
> that, and I'd like it if there was a slightly easier option than
> writing my own REPL.

AFAIK, you'll have to patch clisp to have it save and load readline
history.

From lisp, if you only want to keep the history you can use DRIBBLE,
but there's nothing to feed it back into readline history when you
restart clisp.

http://groups.google.com/group/comp.lang.lisp/msg/8b373bc571304a3b


Of course, writting your own REPL would allow you to write one that'd
work equally on all implementations, (but accessing to raw character
for line editing and history navigation like readline does would still
have to be done in an implementation dependant way).

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

HEALTH WARNING: Care should be taken when lifting this product,
since its mass, and thus its weight, is dependent on its velocity
relative to the user.
From: Arne Knut Roev
Subject: Re: Access REPL's history in CLISP
Date: 
Message-ID: <f5idnagTx5XFDjzYRVnyjQA@giganews.com>
Pascal Bourguignon wrote:
> "Nathan Baum" <···········@btinternet.com> writes:
> 
>> Can one do this?
>>
>> I want to preserve the REPL's history between invocations of CLISP.
[snip!]
> 
> AFAIK, you'll have to patch clisp to have it save and load readline
> history.

Wouldn't a possible solution be:

   1. Use CLisp from (a buffer in) Emacs.
   2. Save the contents of the relevant buffer, before quitting CLisp.
?

As for feeding bits and pieces of this history back into the REPL at
a later time, this should be a fairly simple matter of transferring
selected text from the buffer containing the (recorded) history,
to the buffer connected to the REPL.

Hope this helps.

-akr
From: Nathan Baum
Subject: Re: Access REPL's history in CLISP
Date: 
Message-ID: <1168222167.924249.170770@i15g2000cwa.googlegroups.com>
Arne Knut Roev wrote:
> Pascal Bourguignon wrote:
> > "Nathan Baum" <···········@btinternet.com> writes:
> >
> >> Can one do this?
> >>
> >> I want to preserve the REPL's history between invocations of CLISP.
> [snip!]
> >
> > AFAIK, you'll have to patch clisp to have it save and load readline
> > history.
>
> Wouldn't a possible solution be:
>
>    1. Use CLisp from (a buffer in) Emacs.
>    2. Save the contents of the relevant buffer, before quitting CLisp.
> ?

It's a possible solution, but I don't use CLISP in Emacs. For that
matter, I hardly ever use external programs in Emacs; about the only
exceptions are a spell checker and whatever's on the end of SLIME
(usually, SBCL).

> As for feeding bits and pieces of this history back into the REPL at
> a later time, this should be a fairly simple matter of transferring
> selected text from the buffer containing the (recorded) history,
> to the buffer connected to the REPL.

That might work in Emacs, but obviously not outside of it. I could
probably pipe arbitrary input into the REPL, but that'd execute it.
Almost certainly not what I want.* It looks like I shall be making my
own REPL.**

* In this case, at least. I am interested in setting up a CLISP image
where the session is saved to that image at the end, so that it's
automatically persistent. The REPL issue would be solved by itself
there, but I don't want -all- my CLISP sessions to be persistent.

** Later. I don't need my history preserved -that- urgently.

> Hope this helps.
> 
> -akr
From: Pascal Bourguignon
Subject: Re: Access REPL's history in CLISP
Date: 
Message-ID: <87bqla5jyy.fsf@thalassa.informatimago.com>
"Nathan Baum" <···········@btinternet.com> writes:

> * In this case, at least. I am interested in setting up a CLISP image
> where the session is saved to that image at the end, so that it's
> automatically persistent. The REPL issue would be solved by itself
> there, but I don't want -all- my CLISP sessions to be persistent.

This is something else.  Have a look at:
http://www.informatimago.com/develop/lisp/small-cl-pgms/ibcl/
that may be what you're looking for (some assembly required).

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

ADVISORY: There is an extremely small but nonzero chance that,
through a process known as "tunneling," this product may
spontaneously disappear from its present location and reappear at
any random place in the universe, including your neighbor's
domicile. The manufacturer will not be responsible for any damages
or inconveniences that may result.
From: Nathan Baum
Subject: Re: Access REPL's history in CLISP
Date: 
Message-ID: <1168224031.264215.258320@i15g2000cwa.googlegroups.com>
Pascal Bourguignon wrote:
> "Nathan Baum" <···········@btinternet.com> writes:
>
> > * In this case, at least. I am interested in setting up a CLISP image
> > where the session is saved to that image at the end, so that it's
> > automatically persistent. The REPL issue would be solved by itself
> > there, but I don't want -all- my CLISP sessions to be persistent.
>
> This is something else.  Have a look at:
> http://www.informatimago.com/develop/lisp/small-cl-pgms/ibcl/
> that may be what you're looking for (some assembly required).

That looks cool. I hadn't thought about saving the source. Thanks!
From: Pascal Bourguignon
Subject: Re: Access REPL's history in CLISP
Date: 
Message-ID: <87y7oe5oj7.fsf@thalassa.informatimago.com>
Arne Knut Roev <······@runbox.com> writes:

> Pascal Bourguignon wrote:
>> "Nathan Baum" <···········@btinternet.com> writes:
>>
>>> Can one do this?
>>>
>>> I want to preserve the REPL's history between invocations of CLISP.
> [snip!]
>>
>> AFAIK, you'll have to patch clisp to have it save and load readline
>> history.
>
> Wouldn't a possible solution be:
>
>   1. Use CLisp from (a buffer in) Emacs.
>   2. Save the contents of the relevant buffer, before quitting CLisp.
> ?
>
> As for feeding bits and pieces of this history back into the REPL at
> a later time, this should be a fairly simple matter of transferring
> selected text from the buffer containing the (recorded) history,
> to the buffer connected to the REPL.
>
> Hope this helps.

If you don't use readline, but comint, you can of course instead fill
the comint-input-ring, which is what is used, not the contents of the
buffer.  And yes, you'd have to do both, if you want the feature to
work both in the terminal and in emacs inferior-lisp.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

This is a signature virus.  Add me to your signature and help me to live.
From: justinhj
Subject: Re: Access REPL's history in CLISP
Date: 
Message-ID: <1168219183.140032.24690@38g2000cwa.googlegroups.com>
SBCL on win32 seems to do this. It remembers the history between
sessions.

Justin
From: Nathan Baum
Subject: Re: Access REPL's history in CLISP
Date: 
Message-ID: <1168222121.569307.15130@s34g2000cwa.googlegroups.com>
justinhj wrote:
> SBCL on win32 seems to do this. It remembers the history between
> sessions.
> 
> Justin

A minor flaw being that SBCL isn't CLISP.