michaelm@bcsaic.UUCP (michael b maxwell) (08/09/85)
I've been working with LISP on a SUN for several months, and I'm both happy about the tools UNIX gives me, and disappointed. Happy, because they are so useful for keeping track of large systems (e.g. grep), and disappointed, because they aren't more specific to LISP (naturally). For instance, I have a file that contains a lot of lines with the keyword "features", followed by a list of features. I would like to get a list of the unique features. It seems like I ought to be able to use awk to do this, but how do you tell awk to look for something bounded by parens which comes after the word "features"? I'm sure you can do it (or at least you can capture most of the cases), but I'm also not sure I want to spend the time to do it... (For the simple cases, assume that all the list elements are atoms, and that the entire list is on the same line as the word "feature." For a more difficult case, what happens if some of the list elements are themselves lists? What if the list begins or ends on the next line? Maybe in the latter case you could just put out a message to the user; at least that would be better than nothing! What if the thing following "feature" is a comment, or (which would be an error in my case--and one that I would like to know about) if the thing following is an atom? Well, you get the idea. Probably most people that have hacked on LISP on UNIX have made their own utilities to do things like this. Would you be interested in sharing? As a starter, I offer below a routine that I cooked up this AM to look at the suffix on a file (all my LISP files end in ".l"), and set lisp and ai if the file is LISP, and set nolisp and noai if it is not. There are probably better ways of doing this (e.g. if you give it a list of files, it only looks at the first file and assumes the others are the same), but it sure is nice not to have vi constantly treating a parenthesized phrase in a text file as a LISP function... I use it by aliasing "vi" to the name of this file in my .cshrc. If you have a better way of doing it, please post! (Short of using emacs instead of vi...) --------------------set options in vi based on file suffix--------------- #Set vi appropriately to show match, autoindent etc. iff the file is lisp #(i.e. if the first file of a possible list of files has a .l suffix) test $1 = `basename $1 .l` if $status then setenv EXINIT 'set ai' vi -l $* #note that vi -l sets showmatch and lets you use =% to "justify" code else setenv EXINIT 'set noai' vi $* endif -- Mike Maxwell