[racket] Indentation

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Sun Oct 13 08:25:15 EDT 2013

There is (bare-bones) support for adding keybindings based on the #lang
line that you can use to connect your indenter to DrRacket. See the first
paragraph of section 6.2 here:

http://plt.eecs.northwestern.edu/snapshots/current/doc/tools/Editor_Modes.html

A mode:surrogate-text<%> implementation can add and remove a chained keymap
that contains your indenter mapped to tab.

The Racket-mode implements the indenter by using the color-text% code --
there is a lexer for Racket in there that supports a smart notion of
"re-lexing" (ie it doesn't have to process the entire buffer on each
change) and then the indenter queries that to find out near by tokens to
figure out what the indentation level is supposed to be. Not counting that
information, you're really working at the level of a text% object, tho. If
you need a different colorer/lexer you can also add one via the mode, but
you'd be implementing it.

Let me know if you run into any other questions!

Robby



On Sun, Oct 13, 2013 at 12:48 AM, Joe Gibbs Politz <joe at cs.brown.edu> wrote:

> Hi!
>
> I want to try and get auto-indentation for Pyret working in DrRacket.
> What APIs should I be looking at for doing this?  It seems like a
> color-lexer is about the limit of what I can do via the get-info of a
> #lang, right?  Do I need to implement a drracket:language:language<%>?
>  A mode?
>
> I'm a little confused about what my options are for getting a handle
> on the stream of definitions text, and what interface I'll have when I
> do.
>
> I think just some pointers to existing approaches (didn't ProfessorJ
> have an indenter at some point?) would be helpful.
>
> Thanks!
> Joe
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20131013/b5bdced0/attachment.html>

Posted on the users mailing list.