Re: lisp newbie help (semi long)



On Fri, 2003-10-10 at 13:00, John Harper wrote:
> On Oct 9, 2003, at 1:37 PM, Bret Hughes wrote:
> > What I want to do first is find a window that has a certain string in
> > the title, and do something, say print its name.
> 
> (get-window-by-name "NAME")
> 
> will find the first window called NAME. If you want to do substring 
> searching you need to use get-window-by-name-re, which searches using a 
> regular expression rather than just a string
> 
> > what I can't do is figure out the sytnax to iterate through the list 
> > and
> > print the names (something that seemed a reasonable starting point.)
> 
> there are a number of ways to iterate over a list in rep, mapc/mapcar, 
> while, let, do
> 
> (mapc (lambda (x) (do-something-with x)) my-list)
> 
> (let ((x my-list))
>    (while x
>      (do-something-with (car x))
>      (setq x (cdr x)))
> 
> (let loop ((rest my-list))
>    (when rest
>      (do-something-with (car rest))
>      (loop (cdr rest)))
> 
> (do ((rest my-list (cdr rest))
>      ((null rest))
>    (do-something-with (car rest)))
> 
> stylistically the first is probably the cleanest when there are no side 
> effects, but they all have their uses..
> 
> for printing strings in sawfish you can use the display-message 
> function, it creates a small window and puts some text in it, e.g. 
> (display-message "hello, world")
> 
> 	John

Outstanding help, thanks.  Now that I finally have some of the rudiments
down, I might be getting dangerous.

While I am thinking about it is there some way to propogate an error
condition back through sawfish-client -f or some variant like in the
condition the name lookup failed?



Bret






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]