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

Fred syntax awareness

[Side note: Funny that my original message didn't show up in the
 newsgroup (yet?) but your reply did.]

   Date: Thu, 22 Oct 1992 18:44:32 -0500
   From: Steve Strassmann <straz@cambridge.apple.com>

   >Date: Thu, 22 Oct 92 13:31:48 -0700
   >From: "Carl L. Gay" <cgay@skinner.cs.uoregon.edu>

   >How is Fred "syntax-aware"?  I've wanted some syntax support from Fred
   >for quite a while for some Fred extensions I've written, but I
   >couldn't find anything useful.  I need a function that when given a
   >buffer position will return the syntax at that location.  e.g.,
   >string, code, comment, etc.  Essentially the equivalent of
   >zwei:shift-lock-cached-syntactic-context (if I remember the name
   >correctly) and friends on Symbolics's.  Does anything like this exist
   >in MCL, or has anyone hacked it up?

   Since lisp syntax is so trivial, it doesn't take much to be 
   syntax-aware: blinking parentheses and indentation takes care 
   of most of it.

Tongue firmly implanted in cheek, I hope.

   You can look at the CAR of the current s-expression and
   find out for yourself whether it's a macro, function, or
   whatnot. Maybe there's much more that people have hacked up,
   but this is what you can start with if you want to roll your own.

I should have been more specific.  For example, one of the things I've
done is write code that automatically puts different parts of my code
in different fonts as I type.  (definition names in bold, comments in
italics, code in plain, etc) Right now I'm using very simplistic
heuristics to decide when the user is typing a comment, code, string,
whatever, but it is easily confused.  e.g.,

(format t ";; this~@
           ;; is not a comment")

(defun foo ()

Most of the time the heuristics work but I can never be 100% sure of
the current context unless I go back and parse the file from the
begining.  It could be one long string, or one long comment surrounded
by #| |#.  

One way to solve this would be to parse files into some appropriate
data structure when they're read in, then keep them up to date as the
user types, and killing and yanking would have to be handled.  Given a
buffer position you could look up its sytactic context in the data
structure.  (I assume this is a well known problem...)  

Because of the "syntax-aware" claim I was just wondering if there was
something like this in Fred that I hadn't found yet.