Closed LeifAndersen closed 8 years ago
DrRacket already has support for indenting @-exp languages, although it could be buggy. The rules we came up with when we built it was a kind of C-like thing, where you get N space of indentation on a line that is in text mode (i.e. inside {}
), where N is the number of open {
s you are inside. If you are in "racket" mode (i.e., inside []
) then you should get normal Racket-style indentation. You can tell what mode you are in by the coloring that DrRacket does.
For your examples, this is the behavior I see in my DrRacket, which seems consistent with the intended rules. I do not see what you see for the third example.
#lang scribble/base
@emph{
Here is
some text}
#lang scribble/base
@emph{Here is
some text}
#lang scribble/base
@myfunc[#:arg1 val1
#:arg2 val2]{
Here is
Some text}
Odd. When I automatically indent the following file, I get this:
#lang scribble/lncs
@emph{
foo
bar}
AH!!! okay, when I switch the lang from scribble/lncs
to scribble/base
it works, odd that the #lang
makes that much of a difference.
The indentation strategy is based on the #lang line. Probably scribble/lncs needs to declare it uses the @ indenter, not the regular racket one.
Maybe open an issue there (or move this one?)
Ah, I see.
Well in that case there's a lot of languages that are missing, such as:
scribble/html at-exp etc.
Can you tell me where a #lang declares what indentation it is supposed to use?
Thanks.
I guess these are the docs you want? http://docs.racket-lang.org/tools/adding-languages.html?q=indent#%28part.__lang-based_.Languages_in_.Dr.Racket%29
Thanks for looking into this!
Ah, yes, that does look like what I want. Thank you.
As a side note, it's kind of sad that the indentation can only be set in with the #lang line, and not with other things such as #reader. But oh well. That's a different issue entirely.
Thanks again.
Okay, I'm re-opening this issue because I've found another issue. It turns out that it DOES indent correctly, but only after you hit tab when there's already text there.
For example:
Type:
@list{
hit enter, and start typing, and the text should appear on the next line after the {
. So you get something like this:
@list{
foo}
Now if you hit tab on that new line, it will indent to the right place, but only because there is now text on it.
Yeah, I've noticed that too. If would be great to get that fixed.
But this is still the wrong repo.
Here's the code: https://github.com/racket/gui/blob/master/gui-lib/scribble/private/indentation.rkt
Ah, fair point. I'll move this issue to that repo.
Thanks.
Thanks!
At the moment, the indentation for @-Expressions in Racket is very unusual, and I would expect them to automatically indent similar to S-Expressions.
For example, if I have text on the same line, I would expect it to automatically indent like this:
Or, if I don't put text on the first line, it should probably indent by some fixed number of spaces, such as:
(For reference, it currently seems to put it at the end of the
{
like so:Which has the negative side effect of making the code go significantly more to the right than it needs to, and doesn't match how regular S-expressions indent, which is:
)
I'm a little less clear on what a good idea is if the argument uses arguments in
[]
brackets, but I would expect the{}
parts to follow the same rule. So I could do something like this:How hard would it be to make DrRacket do this?