[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

repl with history recall

Eduardo Costa

6/7/2015 10:24:00 PM

I need a repl with a history ring. I tried to use linedit, but it relies on a c library, that often fails when I use it in remote machines. To make a long story short, I want the functionality of linedit without dependencies on c libraries. By the way, I tried rlwrap, but it suffers from the same problem as linedit. By the way, I often use lisp in machines where I cannot install libraries.

I have seen an repl like the one I discribed above, but I cannot remember where. I believe it uses ansi terminal control code to navigate on the line. It was modal, like vim.
5 Answers

Pascal J. Bourguignon

6/7/2015 11:54:00 PM

0

Eduardo Costa <edu500ac@gmail.com> writes:

> I need a repl with a history ring. I tried to use linedit, but it
> relies on a c library, that often fails when I use it in remote
> machines. To make a long story short, I want the functionality of
> linedit without dependencies on c libraries. By the way, I tried
> rlwrap, but it suffers from the same problem as linedit. By the way, I
> often use lisp in machines where I cannot install libraries.
>
> I have seen an repl like the one I discribed above, but I cannot
> remember where. I believe it uses ansi terminal control code to
> navigate on the line. It was modal, like vim.

The REPL already has a history ring!!!

cf. *, ** and ***.

A history ring of size 3.

--
__Pascal Bourguignon__ http://www.informat...
â??The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.� -- Carl Bass CEO Autodesk

Kaz Kylheku

6/8/2015 1:25:00 AM

0

On 2015-06-07, Eduardo Costa <edu500ac@gmail.com> wrote:
> I need a repl with a history ring.

CLISP, again: integrates GNU Readline.

Pascal J. Bourguignon

6/8/2015 1:34:00 AM

0

Eduardo Costa <edu500ac@gmail.com> writes:

> I need a repl with a history ring. I tried to use linedit, but it
> relies on a c library, that often fails when I use it in remote
> machines. To make a long story short, I want the functionality of
> linedit without dependencies on c libraries. By the way, I tried
> rlwrap, but it suffers from the same problem as linedit. By the way, I
> often use lisp in machines where I cannot install libraries.
>
> I have seen an repl like the one I discribed above, but I cannot
> remember where. I believe it uses ansi terminal control code to
> navigate on the line. It was modal, like vim.

You may use (com.informatimago.common-lisp.interactive.interactive:repl)
which now includes a history. (Get it from gitlab/github or wait next
month for quicklisp).


cl-user> (repl)

COMMON-LISP-USER[1]> (+ 1 2)

--> 3

COMMON-LISP-USER[2]> !!

--> 3

COMMON-LISP-USER[3]> (* 4 !!)

--> 12

COMMON-LISP-USER[4]> '!-2

--> (+ 1 2)

COMMON-LISP-USER[5]> '!3

--> (* 4 (+ 1 2))

COMMON-LISP-USER[6]> '!!

--> '(* 4 (+ 1 2))

COMMON-LISP-USER[7]> (repl-exit 'done)

done
cl-user>



If you don't want to reset the history, you may call repl as:
(repl :reset-history nil).


cl-user> (repl)

COMMON-LISP-USER[1]> (concatenate 'string "abc" "def")

--> "abcdef"

COMMON-LISP-USER[2]> (+ 1 2)

--> 3

COMMON-LISP-USER[3]> (* 4 !!)

--> 12

COMMON-LISP-USER[4]> (+ !! (length !1))

--> 18

COMMON-LISP-USER[5]> (print 'hello)

hello
--> hello

COMMON-LISP-USER[6]> !!

hello
--> hello

COMMON-LISP-USER[7]> (list !! !!)

hello
hello
--> (hello hello)

COMMON-LISP-USER[8]> (apropos "repl-exit")
repl-exit, Def: function
-->

COMMON-LISP-USER[9]> (repl-exit 'done)

done
cl-user> (repl-history-size)
9
cl-user> (repl :reset-history nil)

COMMON-LISP-USER[9]> (repl-history-size)

--> 10

COMMON-LISP-USER[10]> '(!1 !2 !3 !4 !5 !6 !7 !8 !9 !10)

--> ((concatenate 'string "abc" "def")
(+ 1 2)
(* 4 (+ 1 2))
(+ (* 4 (+ 1 2)) (length (concatenate 'string "abc" "def")))
(print 'hello)
(print 'hello)
(list (print 'hello) (print 'hello))
(apropos "repl-exit")
(repl-exit 'done)
(repl-history-size))

COMMON-LISP-USER[11]> (repl-exit)

nil
cl-user>

--
__Pascal Bourguignon__ http://www.informat...
â??The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.� -- Carl Bass CEO Autodesk

Eduardo Costa

6/8/2015 5:12:00 AM

0

On Sunday, June 7, 2015 at 10:33:57 PM UTC-3, informatimago wrote:
> Eduardo Costa <edu500ac@gmail.com> writes:
>
> > I need a repl with a history ring. I tried to use linedit, but it
> > relies on a c library, that often fails when I use it in remote
> > machines. To make a long story short, I want the functionality of
> > linedit without dependencies on c libraries. By the way, I tried
> > rlwrap, but it suffers from the same problem as linedit. By the way, I
> > often use lisp in machines where I cannot install libraries.
> >
> > I have seen an repl like the one I discribed above, but I cannot
> > remember where. I believe it uses ansi terminal control code to
> > navigate on the line. It was modal, like vim.
>
> You may use (com.informatimago.common-lisp.interactive.interactive:repl)
> which now includes a history. (Get it from gitlab/github or wait next
> month for quicklisp).
>
>
> cl-user> (repl)
>
> COMMON-LISP-USER[1]> (+ 1 2)
>
> --> 3
>
> COMMON-LISP-USER[2]> !!
>
> --> 3
>
> COMMON-LISP-USER[3]> (* 4 !!)
>
> --> 12
>
> COMMON-LISP-USER[4]> '!-2
>
> --> (+ 1 2)
>
> COMMON-LISP-USER[5]> '!3
>
> --> (* 4 (+ 1 2))
>
> COMMON-LISP-USER[6]> '!!
>
> --> '(* 4 (+ 1 2))
>
> COMMON-LISP-USER[7]> (repl-exit 'done)
>
> done
> cl-user>
>
>
>
> If you don't want to reset the history, you may call repl as:
> (repl :reset-history nil).
>
>
> cl-user> (repl)
>
> COMMON-LISP-USER[1]> (concatenate 'string "abc" "def")
>
> --> "abcdef"
>
> COMMON-LISP-USER[2]> (+ 1 2)
>
> --> 3
>
> COMMON-LISP-USER[3]> (* 4 !!)
>
> --> 12
>
> COMMON-LISP-USER[4]> (+ !! (length !1))
>
> --> 18
>
> COMMON-LISP-USER[5]> (print 'hello)
>
> hello
> --> hello
>
> COMMON-LISP-USER[6]> !!
>
> hello
> --> hello
>
> COMMON-LISP-USER[7]> (list !! !!)
>
> hello
> hello
> --> (hello hello)
>
> COMMON-LISP-USER[8]> (apropos "repl-exit")
> repl-exit, Def: function
> -->
>
> COMMON-LISP-USER[9]> (repl-exit 'done)
>
> done
> cl-user> (repl-history-size)
> 9
> cl-user> (repl :reset-history nil)
>
> COMMON-LISP-USER[9]> (repl-history-size)
>
> --> 10
>
> COMMON-LISP-USER[10]> '(!1 !2 !3 !4 !5 !6 !7 !8 !9 !10)
>
> --> ((concatenate 'string "abc" "def")
> (+ 1 2)
> (* 4 (+ 1 2))
> (+ (* 4 (+ 1 2)) (length (concatenate 'string "abc" "def")))
> (print 'hello)
> (print 'hello)
> (list (print 'hello) (print 'hello))
> (apropos "repl-exit")
> (repl-exit 'done)
> (repl-history-size))
>
> COMMON-LISP-USER[11]> (repl-exit)
>
> nil
> cl-user>
>
> --
> __Pascal Bourguignon__ http://www.informat...
> "The factory of the future will have only two employees, a man and a
> dog. The man will be there to feed the dog. The dog will be there to
> keep the man from touching the equipment." -- Carl Bass CEO Autodesk

That is exactly what I need. I cloned it thus:

git clone http://git.informatimago.com/p... com/informatimago

Since I don't know very well how to work with packages, I put every thing needed inside a ~/psc/ folder. A also added a shorter nickname to the package, and compiled it.

CL-USER(1): (pushnew "~/psc/" asdf:*central-registry*)

("~/psc/" #P"/Users/edu500ac/quicklisp/quicklisp/")
CL-USER(3): (asdf:operate 'asdf:load-op :com.informatimago.common-lisp.interactive)

CL-USER(3): (nn::repl)

COMMON-LISP-USER[1]> (* 3 4 5)

--> 60

COMMON-LISP-USER[2]> '!1


--> (* 3 4 5)

COMMON-LISP-USER[3]> _

I have noticed that the package comes with other goodies, that I will explore tomorrow.

Pascal J. Bourguignon

6/8/2015 9:29:00 AM

0

Eduardo Costa <edu500ac@gmail.com> writes:

> That is exactly what I need. I cloned it thus:
>
> git clone http://git.informatimago.com/p... com/informatimago
>
> Since I don't know very well how to work with packages, I put every
> thing needed inside a ~/psc/ folder. A also added a shorter nickname
> to the package, and compiled it.

You could clone it in ~/quicklisp/local-projects/
so that you may use

(ql:quickload :com.informatimago.common-lisp.interactive)

Then, next month, you can remove the copy in ~/quicklisp/local-projects/
and rely on quicklisp to download the current version.


You may add the nickname after the fact with:

(ql:quickload :com.informatimago.common-lisp.cesarum)

(com.informatimago.common-lisp.cesarum.package:add-nickname
:com.informatimago.common-lisp.interactive.interactive
:i)

(i:repl)


> I have noticed that the package comes with other goodies, that I will
> explore tomorrow.


--
__Pascal Bourguignon__ http://www.informat...
â??The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.� -- Carl Bass CEO Autodesk