From: yaru22
Subject: Viewing the code of a function
Date: 
Message-ID: <1168887162.949202.210810@a75g2000cwd.googlegroups.com>
Hi. I'm a beginner Common Lisp user.

I'm using emacs with slime. I'm just wondering if there is a command to
view the code of a function that I wrote.

Because sometimes I write a function on the REPL and have to modify it
later, but it's a hassle to scroll up and find the function that I
wrote.

Thank you.

From: Matthias Benkard
Subject: Re: Viewing the code of a function
Date: 
Message-ID: <1168889153.225014.287070@v45g2000cwv.googlegroups.com>
Hi,

You shouldn't be writing a lot of functions on the REPL. SLIME makes it
really easy to interact with Lisp from within editor buffers!

For starters, try creating a Lisp file, typing a function definition
into it, putting the cursor inside or just behind it and typing C-c C-c
(that is, Control-C twice). Now jump to the REPL and you should be able
to use the function. Whenever you want to edit it, do just that and
send its definition to the REPL via C-c C-c again.

That's one of the simplest of the large bunch of features that make
SLIME so cool, after all.

Have fun :)

Matthias
From: Ken Tilton
Subject: Re: Viewing the code of a function
Date: 
Message-ID: <fZQqh.45$tZ2.29@newsfe11.lga>
Matthias Benkard wrote:
> Hi,
> 
> You shouldn't be writing a lot of functions on the REPL. SLIME makes it
> really easy to interact with Lisp from within editor buffers!

um, I think it is more important to warn the poor noob that the repl 
history will not get saved.

Before he exits the session he has open now. :)

kt

-- 
The Dalai Lama gets the same crap all the time.
   -- Kenny Tilton on c.l.l when accused of immodesty
From: Zach Beane
Subject: Re: Viewing the code of a function
Date: 
Message-ID: <m3d55g3uy5.fsf@unnamed.xach.com>
Ken Tilton <·········@gmail.com> writes:

> Matthias Benkard wrote:
> > Hi,
> > You shouldn't be writing a lot of functions on the REPL. SLIME makes
> > it
> > really easy to interact with Lisp from within editor buffers!
> 
> um, I think it is more important to warn the poor noob that the repl
> history will not get saved.

Sure it will, in ~/.slime-history.eld. The variable
slime-repl-history-size determines how much of your history is saved;
the default value is 200.

Zach
From: Ken Tilton
Subject: Re: Viewing the code of a function
Date: 
Message-ID: <hvRqh.65$W63.21@newsfe08.lga>
Zach Beane wrote:
> Ken Tilton <·········@gmail.com> writes:
> 
> 
>>Matthias Benkard wrote:
>>
>>>Hi,
>>>You shouldn't be writing a lot of functions on the REPL. SLIME makes
>>>it
>>>really easy to interact with Lisp from within editor buffers!
>>
>>um, I think it is more important to warn the poor noob that the repl
>>history will not get saved.
> 
> 
> Sure it will, in ~/.slime-history.eld. The variable
> slime-repl-history-size determines how much of your history is saved;
> the default value is 200.

Quick! Call the noob! 200 ain't much.

kt

-- 
The Dalai Lama gets the same crap all the time.
   -- Kenny Tilton on c.l.l when accused of immodesty
From: yaru22
Subject: Re: Viewing the code of a function
Date: 
Message-ID: <1168894797.320119.327260@s34g2000cwa.googlegroups.com>
Thanks a lot guys.

That's how you use Slime! :D
From: Pascal Bourguignon
Subject: Re: Viewing the code of a function
Date: 
Message-ID: <87r6tw12ur.fsf@thalassa.informatimago.com>
"Matthias Benkard" <··········@gmail.com> writes:

> Hi,
>
> You shouldn't be writing a lot of functions on the REPL. SLIME makes it
> really easy to interact with Lisp from within editor buffers!
>
> For starters, try creating a Lisp file, typing a function definition
> into it, putting the cursor inside or just behind it and typing C-c C-c
> (that is, Control-C twice). Now jump to the REPL and you should be able
> to use the function. Whenever you want to edit it, do just that and
> send its definition to the REPL via C-c C-c again.

Too complex!


Create a lisp file (C-x C-f my-pgm.lisp RET)
type a function definition:

           (defun f (x) (if (zerop x) 1 (* x (f (1- x)))))

and type:  C-x C-e

Then type next your test cases: 
     
           (f 1) C-x C-e
           (f 4) C-x C-e
           (loop :for i :from 0 :to 10 :do (print `(,i ,(f i)))) C-x C-e


There is no need to go to the REPL, because every lisp buffer in emacs
is a REPL!

> That's one of the simplest of the large bunch of features that make
> SLIME so cool, after all.
>
> Have fun :)

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

"This machine is a piece of GAGH!  I need dual Opteron 850
processors if I am to do battle with this code!"
From: ·······@gmail.com
Subject: Re: Viewing the code of a function
Date: 
Message-ID: <1168889292.666247.313770@51g2000cwl.googlegroups.com>
yaru22 wrote:
> Hi. I'm a beginner Common Lisp user.
>
> I'm using emacs with slime. I'm just wondering if there is a command to
> view the code of a function that I wrote.
>
> Because sometimes I write a function on the REPL and have to modify it
> later, but it's a hassle to scroll up and find the function that I
> wrote.

You shouldn't define or modify functions in the REPL, you should write
the definitions in a file and then compile or evaluate them with
something like C-c C-c (slime-compile-defun) or C-M-x
(slime-eval-defun).

If you've done that, you can use M-. (slime-edit-definition) to find
the source.

HTH,
Edi.
From: Matthias Benkard
Subject: Re: Viewing the code of a function
Date: 
Message-ID: <1168889449.770945.309240@v45g2000cwv.googlegroups.com>
Oh, by the way,

I forgot to mention that it's possible to use M-p and M-n (i.e. Alt-P
and Alt-N on your keyboard, probably) to recall prior inputs in the
REPL, which comes in handy at times, too.

Matthias
From: Alex Mizrahi
Subject: Re: Viewing the code of a function
Date: 
Message-ID: <45abdf99$0$49201$14726298@news.sunsite.dk>
(message (Hello 'yaru22)
(you :wrote  :on '(15 Jan 2007 10:52:43 -0800))
(

 y> Because sometimes I write a function on the REPL and have to modify it
 y> later, but it's a hassle to scroll up and find the function that I
 y> wrote.

there's slime-scratch buffer, if you have some temporary function you don't 
want to save into a file..

)
(With-best-regards '(Alex Mizrahi) :aka 'killer_storm)
"People who lust for the Feel of keys on their fingertips (c) Inity")