Lisp HUG Maillist Archive

lispworks - best practices..

Hi there,

so I am entering commands directly in a Listener window, and I have entered a few
def-fun functions etc..  How do I save them, so that I don't need to type in again?  I
tried to do a save, but that seems to just save the console output...  Similarly, if I
load up a file containing lisp, and it has one of my older functions that I want to change,
what is the best way of doing that?  Is there somehow to load up that function in an
editable way in lispworks??

Thanks, Alex.

Re: lispworks - best practices..

Unable to parse email body. Email id is 9916

Re: lispworks - best practices..

My noobish solution is to work back and forth between a file and the
REPL.  If you have the Lispworks emulation set to Emacs (see Tools
menu, "Preferences", and "Environment" for the setting) then it's
ctrl-x ctrl-f (two keystrokes) and then type the name of the file (I
use jnk.lisp, or something like that).  Note that if the file exists,
it is loaded.  If it doesn't exist, it's created as an empty file.

Then scribble your code into that file, and use ctrl-shift-B whenever
you want to compile the file (there are also commands to compile a
form, or a highlighted region, etc.)

For working on something interactively, I find it easier to use
ctrl-tab to go back to the REPL, tweak the form that I'm working on (a
defun, defmacro, etc.) and then when I get it working the way I like,
I copy/paste it back into the text file.  Then you can start work on
the next part of your problem.

When you want to resume your work, just load that file and continue on.

As Paul said, it's worth reading the editor and IDE guides to get a
sense of the features available.  It starts to make sense eventually,
but it sure seems weird if you're coming from an edit/compile/run
environment.

Kev

On Sat, Feb 6, 2010 at 3:47 PM, Aleksandar Matijaca <amatijaca@gmail.com> wrote:
> Hi there,
>
> so I am entering commands directly in a Listener window, and I have entered
> a few
> def-fun functions etc..  How do I save them, so that I don't need to type in
> again?  I
> tried to do a save, but that seems to just save the console output...
> Similarly, if I
> load up a file containing lisp, and it has one of my older functions that I
> want to change,
> what is the best way of doing that?  Is there somehow to load up that
> function in an
> editable way in lispworks??
>
> Thanks, Alex.
>
>


Re: lispworks - best practices..


Being a not-fully reformed DOS & C developer, I edit the code in emacs
or whatever, alt-tab over to the listener and use "(compile-system
'<whatever> :load t)", then run it via some function in the file.

Its probably tacky, but I like to know that the source corresponds to
the running code and I've never found the "Lisp-y" integration of editor
and listener comfortable to use or obviously more efficient than the
edit/compile-system/run cycle.  But that probably has a lot to do with
the kinds of stuff I use Lisp for.

OTOH the edit/compile/run cycle is particularly handy when using CAPI,
where a mistake in how the interface works can wedge the entire image,
forcing you to sigkill the whole thing and start over.  If all the
runtime code is compiled from source then you can get back to where you
were easily.

Greg



Kevin Clifton writes:
 > 
 > My noobish solution is to work back and forth between a file and the
 > REPL.  If you have the Lispworks emulation set to Emacs (see Tools
 > menu, "Preferences", and "Environment" for the setting) then it's
 > ctrl-x ctrl-f (two keystrokes) and then type the name of the file (I
 > use jnk.lisp, or something like that).  Note that if the file exists,
 > it is loaded.  If it doesn't exist, it's created as an empty file.
 > 
 > Then scribble your code into that file, and use ctrl-shift-B whenever
 > you want to compile the file (there are also commands to compile a
 > form, or a highlighted region, etc.)
 > 
 > For working on something interactively, I find it easier to use
 > ctrl-tab to go back to the REPL, tweak the form that I'm working on (a
 > defun, defmacro, etc.) and then when I get it working the way I like,
 > I copy/paste it back into the text file.  Then you can start work on
 > the next part of your problem.
 > 
 > When you want to resume your work, just load that file and continue on.
 > 
 > As Paul said, it's worth reading the editor and IDE guides to get a
 > sense of the features available.  It starts to make sense eventually,
 > but it sure seems weird if you're coming from an edit/compile/run
 > environment.
 > 
 > Kev
 > 
 > On Sat, Feb 6, 2010 at 3:47 PM, Aleksandar Matijaca <amatijaca@gmail..com> wrote:
 > > Hi there,
 > >
 > > so I am entering commands directly in a Listener window, and I have entered
 > > a few
 > > def-fun functions etc..  How do I save them, so that I don't need to type in
 > > again?  I
 > > tried to do a save, but that seems to just save the console output....
 > > Similarly, if I
 > > load up a file containing lisp, and it has one of my older functions that I
 > > want to change,
 > > what is the best way of doing that?  Is there somehow to load up that
 > > function in an
 > > editable way in lispworks??
 > >
 > > Thanks, Alex.
 > >
 > >
 > 


Re: lispworks - best practices..


On 2010/02/06, at 23:47 , Aleksandar Matijaca wrote:
> so I am entering commands directly in a Listener window, and I have  
> entered a few
> def-fun functions etc..  How do I save them, so that I don't need to  
> type in again?  I
> tried to do a save, but that seems to just save the console  
> output...  Similarly, if I
> load up a file containing lisp, and it has one of my older functions  
> that I want to change,
> what is the best way of doing that?  Is there somehow to load up  
> that function in an
> editable way in lispworks??


As indicated, the reasonable way is to use the surrounding operating  
system (editors and file systems) to ensure persistance of your lisp  
sources.

However, you could "save" your interactions with the REPL, on the  
condition of setting things up before.

The standard API is the DRIBBLE function.  You give it a pathname, and  
it will save to that file all the following REPL interactions (until  
you call it with no arguments).  The file format is implementation  
dependant, but hopefully, you should be able to retrieve in it the  
source of the functions you defined at the REPL, to copy them to a  
source file.

An alternative would be to use something similar to my IBCL package,  
where the defining macros are redefined to add book-keeping, so that  
you can retrieve and save the current definitions.
http://www.informatimago.com/develop/lisp/small-cl-pgms/ibcl/

But in both cases, you must activate the feature first (you can do  
that easily in the startup file).



Also, you may use the standard function FUNCTION-LAMBDA-EXPRESSION to  
retrieve the source form of a function, (but it may also return NIL,  
so you cannot count on it in all circumstances).



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




Re: lispworks - best practices..


Am 06.02.2010 um 23:47 schrieb Aleksandar Matijaca:

> Hi there,
> 
> so I am entering commands directly in a Listener window, and I have entered a few
> def-fun functions etc..  How do I save them, so that I don't need to type in again?  I
> tried to do a save, but that seems to just save the console output...  Similarly, if I
> load up a file containing lisp, and it has one of my older functions that I want to change,
> what is the best way of doing that?  Is there somehow to load up that function in an 
> editable way in lispworks??
> 
> Thanks, Alex.
> 


Some time ago, using an older version of LispWorks, I recorded a simple interaction with LispWorks.
I tried to solve a simple problem using Lisp and I was using LispWorks in a very basic way:
using the editor to write the code and using the listener to try out the code with some
example data.

http://lispm.dyndns.org/news?ID=NEWS-2005-07-08-1

See the video at:

http://lispm.dyndns.org/mov/dsl-in-lisp.mov

It will not answer all your questions, but sometimes it might be useful to see a video of some basic interaction.

Regards,

Rainer Joswig


Rainer Joswig, Hamburg, Germany
http://lispm.dyndns.org/
mailto:joswig@lisp.de




Re: lispworks - best practices..

You can work with the Editor (menu : window/tools/editor) and simply save
the buffer on your disk (save, save as, etc). For evaluate or compile the
forms in this buffer, put your cursor at the end of the form (or inside it)
and push the ³evaluate definition² on the toolbar. To compile a function do
the same but press the ³compile definition² button. When you open the file
you can compile all the forms by pressing the "compile buffer" button.
You can also open several buffers and navigate thru them with the ³Buffers²
tab of the Editor. To load a buffer inside the Editor, double-click on the
file, or use the "open" menu item.

Best 

Denis

Le 6/02/10 23:47, « [NOM] » <[ADRESSE]> a écrit :

> Hi there,
> 
> so I am entering commands directly in a Listener window, and I have entered a
> few
> def-fun functions etc..  How do I save them, so that I don't need to type in
> again?  I
> tried to do a save, but that seems to just save the console output... 
> Similarly, if I
> load up a file containing lisp, and it has one of my older functions that I
> want to change,
> what is the best way of doing that?  Is there somehow to load up that function
> in an 
> editable way in lispworks??
> 
> Thanks, Alex.
> 
> 


-------------------------------------------------------
Denis Pousseur
70 rue de Wansijn
1180 Bruxelles, Belgique

Tel : 32 (0)2 219 31 09
Mail :  denis.pousseur@gmail.com
-------------------------------------------------------



Re: lispworks - best practices..


On Feb 7, 2010, at 5:52 AM, Rainer Joswig wrote:

> Some time ago, using an older version of LispWorks, I recorded a simple interaction with LispWorks.
> I tried to solve a simple problem using Lisp and I was using LispWorks in a very basic way:
> using the editor to write the code and using the listener to try out the code with some
> example data.
> 
> http://lispm.dyndns.org/news?ID=NEWS-2005-07-08-1
> 
> See the video at:
> 
> http://lispm.dyndns.org/mov/dsl-in-lisp.mov
> 
> It will not answer all your questions, but sometimes it might be useful to see a video of some basic interaction.

Rainer is being modest here. I can't recommend his video highly enough. It shows you how someone completely fluent in common lisp, with decades of experience, uses both the listener and the editor to iteratively develop a very lispy solution to a typical programming task. I have since tried to model my use of LispWorks on Rainer's video, and it has made using lisp even faster and more enjoyable.

The only other recommendation I would have is to download and use Edi Weitz's lw-add-ons:
<http://weitz.de/lw-add-ons/>

I don't know if Edi has released a new version for LW 6. If not, updating it is just a simple matter of editing the vars to point to the correct index pages in the revised html documentation.

warmest regards,

Ralph


Raffael Cavallaro
raffaelcavallaro@me.com






Re: lispworks - best practices..

On Sun, Feb 7, 2010 at 4:07 PM, Raffael Cavallaro
<raffaelcavallaro@mac.com> wrote:

> The only other recommendation I would have is to download and use Edi Weitz's lw-add-ons:
> <http://weitz.de/lw-add-ons/>
>
> I don't know if Edi has released a new version for LW 6. If not, updating it is just a simple matter of editing the vars to point to the correct index pages in the revised html documentation.

Unfortunately, I haven't found the time yet to do it, i.e. LW-ADD-ONS
will only work with LW 5 or earlier.  No need to change the index page
links, though.  That's part of LW-DOC which /has/ been updated for LW
6.

Edi.


Re: lispworks - best practices..

Edi Weitz <edi@agharta.de> writes:

> On Sun, Feb 7, 2010 at 4:07 PM, Raffael Cavallaro
> <raffaelcavallaro@mac.com> wrote:
>
>> The only other recommendation I would have is to download and use Edi Weitz's lw-add-ons:
>> <http://weitz.de/lw-add-ons/>
>>
>> I don't know if Edi has released a new version for LW 6. If not, updating it is just a simple matter of editing the vars to point to the correct index pages in the revised html documentation.
>
> Unfortunately, I haven't found the time yet to do it, i.e. LW-ADD-ONS
> will only work with LW 5 or earlier.  No need to change the index page
> links, though.  That's part of LW-DOC which /has/ been updated for LW
> 6.
>
> Edi.

I have been using LW-ADD-ONS with LispWorks 6 (beta and release) for
almost a year now with the minor patch below.

Nico


$ diff -u misc.lisp~ misc.lisp
--- misc.lisp~  2008-05-26 09:55:02.000000000 +0200
+++ misc.lisp   2009-03-23 12:01:31.000000000 +0200
@@ -41,7 +41,7 @@
   ;; workaround because older versions of LispWorks's HWEB:BROWSE
   ;; function swallow the fragment part of the URI - based on an
   ;; idea by Nick Levine
-  #-:lispworks5
+  #-(or :lispworks5 :lispworks6)
   (let ((temp-file (make-temp-file nil "html")))
     (push temp-file *temp-files*)
     (with-open-file (out temp-file
@@ -50,7 +50,7 @@
       (format out "<html><head><meta http-equiv=refresh content=\"0;url=~A\"></head></html>"
               uri))
     (hweb:browse (namestring temp-file)))
-  #+:lispworks5
+  #+(or :lispworks5 :lispworks6)
   (hweb:browse uri))

 (defun start-swank-server ()


Re: lispworks - best practices..


Nico de Jager <ndj@bitart.cc> writes:

> Edi Weitz <edi@agharta.de> writes:
>
>> On Sun, Feb 7, 2010 at 4:07 PM, Raffael Cavallaro
>> <raffaelcavallaro@mac.com> wrote:
>>
>>> The only other recommendation I would have is to download and use Edi Weitz's lw-add-ons:
>>> <http://weitz.de/lw-add-ons/>
>>>
>>> I don't know if Edi has released a new version for LW 6. If not, updating it is just a simple matter of editing the vars to point to the correct index pages in the revised html documentation.
>>
>> Unfortunately, I haven't found the time yet to do it, i.e. LW-ADD-ONS
>> will only work with LW 5 or earlier.  No need to change the index page
>> links, though.  That's part of LW-DOC which /has/ been updated for LW
>> 6.
>>
>> Edi.
>
> I have been using LW-ADD-ONS with LispWorks 6 (beta and release) for
> almost a year now with the minor patch below.

As Edi pointed out to me, the patch I posted earlier is incomplete. The
patch below works with LispWorks 6.0 while maintaining backward
compatibility with at least LispWorks 5.1.2.

Nico


$ diff -ru lw-add-ons-0.8.7 lw-add-ons-0.8.7_patched/
diff -ru lw-add-ons-0.8.7/editor.lisp lw-add-ons-0.8.7_patched/editor.lisp
--- lw-add-ons-0.8.7/editor.lisp        2008-05-26 09:55:02.000000000 +0200
+++ lw-add-ons-0.8.7_patched/editor.lisp        2010-02-09 00:35:36.805116168 +0200
@@ -176,7 +176,7 @@
 (defmacro recording-for-undo-locking (point1 point2 &body body)
   "Like RECORDING-FOR-UNDO, but with lock.  See source code for LW editor."
   (lw:rebinding (point1)
-    `(editor::with-locked-buffer (point-buffer ,point1)
+    `(with-buffer-locked ((point-buffer ,point1))
        (recording-for-undo ,point1 ,point2 ,@body))))

 #+:editor-has-dont-undo
@@ -462,6 +462,7 @@
           :complete-func 'complete-shortcut)))
     (find-full-name input)))

+#-:lispworks6.0
 (defmacro with-input-from-region ((var start end) &body body &environment env)
   "During the evaluation of BODY, VAR is bound to a stream which
 returns input from the region denoted by START and END."
diff -ru lw-add-ons-0.8.7/misc.lisp lw-add-ons-0.8.7_patched/misc.lisp
--- lw-add-ons-0.8.7/misc.lisp  2008-05-26 09:55:02.000000000 +0200
+++ lw-add-ons-0.8.7_patched/misc.lisp  2010-02-09 00:09:37.845369811 +0200
@@ -41,7 +41,7 @@
   ;; workaround because older versions of LispWorks's HWEB:BROWSE
   ;; function swallow the fragment part of the URI - based on an
   ;; idea by Nick Levine
-  #-:lispworks5
+  #-(or :lispworks5 :lispworks6)
   (let ((temp-file (make-temp-file nil "html")))
     (push temp-file *temp-files*)
     (with-open-file (out temp-file
@@ -50,7 +50,7 @@
       (format out "<html><head><meta http-equiv=refresh content=\"0;url=~A\"></head></html>"
               uri))
     (hweb:browse (namestring temp-file)))
-  #+:lispworks5
+  #+(or :lispworks5 :lispworks6)
   (hweb:browse uri))

 (defun start-swank-server ()


Re: lispworks - best practices..

On Tue, Feb 9, 2010 at 12:29 AM, Nico de Jager <ndj@bitart.cc> wrote:

> As Edi pointed out to me, the patch I posted earlier is incomplete. The
> patch below works with LispWorks 6.0 while maintaining backward
> compatibility with at least LispWorks 5.1.2.

For those of you who use LW-ADD-ONS I've now made a new release
(0.8.8) which includes Nico's patch and a bit more.  It's available
from http://weitz.de/ as usual.

This should not be considered the "definitive" release of LW-ADD-ONS
for LW6 and I'm sure there are some glitches in there, but I don't
have the time to investigate them right now.  But it should at least
compile and behave somewhat reasonably.

Thanks,
Edi.


Re: lispworks - best practices..

Unable to parse email body. Email id is 9969

Re: lispworks - best practices..

Martin Simmons writes:
 > >>>>> On Sat, 6 Feb 2010 19:08:09 -0500, gregm32768 said:
 > > 
 > > OTOH the edit/compile/run cycle is particularly handy when using CAPI,
 > > where a mistake in how the interface works can wedge the entire image,
 > > forcing you to sigkill the whole thing and start over.  If all the
 > > runtime code is compiled from source then you can get back to where you
 > > were easily.
 > 
 > If you find cases where it wedges the whole image then please let us know!

I am using a fairly old Lispworks (4.3), so its likely not
representative of a more modern version.  I am intending to upgrade this
year btw.

But as far as wedging goes, one class of trouble often occurs when a
condition is raised (some runtime error) in the "drawing" events; ie a
resize or redraw.  I find its sometimes impossible to stop CAPI from
continuing to call the faulty code so I can unwind the stack and
recover.  I've worked around it in the past by setting and testing a
flag at the top level of the draw/size code so a call to it immediately
returns unless the previous call to the drawing code has completed.

The other class I run into are errors coming back into CAPI from X,
though this could certainly be due to the age of 4.3 in relation to
motif and Linux.

Greg


Updated at: 2020-12-10 08:39 UTC