[editor-hints-devel] Initial checkin.

Tobias C. Rittweiler tcr at freebits.de
Wed Jan 23 10:42:17 UTC 2008


Alright, RPG and me migrated the svn repository from his employer to
common-lisp.net. You can fetch the sources via

  svn checkout svn://common-lisp.net/project/editor-hints/svn

The sources contain so far only an almost complete implementation of
named readtables. Incomplete only in so far that merging of readtables
don't work so far, because it needs introspection into a readtable which
the standard doesn't offer.

I can implement this kind of introspection by shadowing
SET-MACRO-CHARACTER &c. -- although I'd like implementations to provide
this functionality themselves ultimativaly (think CDR.)


Named Readtables provide a package like namespace for readtables. Every
normal .lisp file should start with

   (in-package :foo)     ; where #<PACKAGE "FOO"> uses :EDITOR-HINTS
   (in-readtable :standard)

You can define your own named readtables via DEFREADTABLE:

  (eval-when (:compile-toplevel :load-toplevel :execute)
    (defun semicolon-reader (stream char)
     (declare (ignore char))
     (let ((comment-string (read-line stream nil "" t)))
       `(comment (string-left-trim '(#\; #\Space #\Tab) comment-string)))))

  (defreadtable :preserving-comments
      (:merge :standard)
      (:macro-char #\; #'semicolon-reader nil))

So you can now use

  (in-readtable :preserving-comments)

And `;;; Foo Bar Quux' comments will be READ as (comment "Foo Bar Quux").

More so, other readtable definitions can now take use of this
definition, too:

  (defreadtable :foobar
      (:merge :standard :preserving-comments)
      ...)

[This kind of merging doesn't work currently.]

  -T.





More information about the editor-hints-devel mailing list