Subject: [clisp-list] clisp command history

From: Elvin Peterson <[email-masked]>
Date: Mon Jun 28 06:15:00 2004

Hello,
  clisp does not create a history file by default like
the .bash_history file.  How can I turn that on?  I
would like to have a command history that spans
different invocations of clisp.  A google search did
not turn up anything.  Any help is appreciated.
TIA.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com

---

From: Pascal J.Bourguignon <[email-masked]>
Date: Mon Jun 28 07:19:05 2004

> not turn up anything.  Any help is appreciated.

You could use clisp from emacs, either ilisp or slime, and save the
buffer before quitting emacs.

An alternative would be to write your own REPL.

A naive definition could be:

(defun repl ()
  (loop (princ "> ") 
        (let (sexp result error)
          (handler-case
              (setq sexp (read)  result (eval sexp))
            (error (err) (setq error (format nil "~A~%" err))))
          (if error
            (format t "ERROR: ~A~%" error)
            (format t "~S~%" result))
          (with-open-file (hist (merge-pathnames
                                 (make-pathname :name "clisp-history")
                                 (user-homedir-pathname))
                                :direction :output
                                :if-does-not-exist :create
                                :if-exists :append)
            (if error
            (format hist "~S~%ERROR: ~A~2%" sexp error)
            (format hist "~S~%~S~2%" sexp result))))))

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

There is no worse tyranny than to force a man to pay for what he does not
want merely because you think it would be good for him. -- Robert Heinlein

---

From: Sam Steingold <[email-masked]>
Date: Mon Jun 28 07:43:01 2004

> * Elvin Peterson <[email-masked]> [2004-06-28 06:14:01 -0700]:
>
> clisp does not create a history file by default like the
> .bash_history file.

indeed.  <readline/history.h> offers a rich API for history saving,
and most of it, IIRC, is exported in bash via variables.
We can also offer CUSTOM:*HISTORY-FILE*, CUSTOM:*HISTORY-FILE-TRUNCATE*,
EXT:READ-HISTORY, EXT:WRITE-HISTORY.
Would you like to implement that?

> How can I turn that on?

there is no way at this time.

> I would like to have a command history that spans different
> invocations of clisp.

I always turn it off for bash.

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.honestreporting.com>
You think Oedipus had a problem -- Adam was Eve's mother.

---

From: Elvin Peterson <[email-masked]>
Date: Mon Jun 28 08:02:03 2004

> A naive definition could be:

As I understand it, both the methods will give me a
file with the history of interaction with clisp. 
Isn't that the same as that obtained with the dribble
command?  What would be great is if I can access the
commands executed in the previous clisp session with
up-arrow or M-p.

Thanks.

__________________________________
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
http://promotions.yahoo.com/new_mail

---

From: Sam Steingold <[email-masked]>
Date: Mon Jun 28 09:08:02 2004

> * Elvin Peterson <[email-masked]> [2004-06-28 08:00:30 -0700]:
>
> What would be great is if I can access the commands executed in the
> previous clisp session with up-arrow or M-p.

note that when CLISP is running under Emacs, readline is not used.
if you want to remember CLISP commands when CLISP is run in a shell,
you need to modify CLISP to call write_history() and read_history().
if you want to do it in Emacs, you need to add some
comint-add-to-input-history calls to inferior-list-mode-hook and also
write the commands when you leave Emacs.

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.honestreporting.com>
Winners never quit; quitters never win; idiots neither win nor quit.

---

From: Pascal J.Bourguignon <[email-masked]>
Date: Mon Jun 28 09:09:02 2004

> commands executed in the previous clisp session with

As Sam wrote, the source of clisp should be edited to add this feature
at the readline level.  One problem of this, is that we often have
several bash or clisp sessions running at the same time, and the
history saving overwrites all but the last saved history.

Otherwise, if you're using clisp thru emacs, history is actually
implemented by emacs.  With ilisp, when I wanted to restart clisp but
still running the same sexp over and over, I would run (ext:quit),
without closing the buffer, and relaunch clisp with M-x clisp-hs RET.
Then emacs would have kept the buffer history and I could fetch back
sexps from previous sessions.

---

From: Elvin Peterson <[email-masked]>
Date: Mon Jun 28 10:10:02 2004

> history saving overwrites all but the last saved

At least in bash, the history is only saved when it
exits, so I don't see why overwriting would be
problem.

> sexps from previous sessions.

Indeed--I have noted this behavior when using emacs,
but as was mentioned in another mail, modifications
would be required for saving state across multiple
emacs sessions.

---

From: Elvin Peterson <[email-masked]>
Date: Sun Jul 11 09:43:00 2004

> > * Elvin Peterson <[email-masked]>

The readline library _is_ used when running under
SLIME in Emacs, which is what I am using now.  Adding
the history calls looks like a straightforward job,
but I can't figure out the file it is defined in
(stream.d, written in some mixed language).

		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail