`pollen/mode' changes indentation in whole document
#124
Closed
opened 7 years ago by leafac
·
5 comments
Loading…
Reference in New Issue
There is no content yet.
Delete Branch '%!s(<nil>)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
CURRENT BEHAVIOR
The indentation for
#lang racket
is the following:Adding
pollen/mode
makes◊
available in Racket code, and is correctly indented according to◊
-indentation rules:The addition of
pollen/mode
changes the indentation of existing code:EXPECTED BEHAVIOR
Adding
pollen/mode
does not change the indentation of non-◊
code.Do you think this makes sense? If so, how can I help turning this idea into code?
As always, thank you for Pollen!
I see your point. But I also think this notation is slightly mischievous:
Because in
racket
,{braces}
count as parentheses. Whereas inpollen/mode
, they mean something else, and thus indent differently. So your notation invites ambiguity. For instance, if I rewrite with parentheses, I get the right indentation:Moreover,
pollen/mode
is based on Racket’s ownat-exp
metalanguage, and the behavior is the same there:So, I grant your point that it would be nice for DrRacket to handle this better. But if the folks who wrote
at-exp
couldn’t figure it out, I doubt I will be able to do better 😱As far as I understand, the meaning of
{braces}
only change on◊
-expressions—e.g.,◊values{Braces with another meaning}
. Elsewhere,pollen/mode
preserves the meaning of{braces}
counting as parentheses. The following program illustrates what I mean:So, DrRacket could indent the two differently as I proposed, it seems to me. But I agree that it is a bit awkward, so I'm closing the issue.
To give a bit of background of how I ended up opening this issue: I'm using
pollen.rkt
to store some data that should be available for the whole site (e.g., the website's name and description)—pollen/mode
comes in handy for that. Also, I'm defining inpollen.rkt
reusable HTML components which should be available for the whole site (e.g., a function to create links)—{braces}
as parentheses make that portion of the code more readable. But then, indentation is awkward.I guess my solution is going to be: extract one of these parts—or maybe both—to separate files, which I
require
andprovide
inpollen.rkt
. These separate files are free to usepollen/mode
where convenient, without messing anything else.If you have a better idea, please let me know.
Yes, that’s what I was getting at (though you have phrased it more precisely).
If I had to guess, I think you’ve found an edge case that the
at-exp
indenter (and therefore, thepollen/mode
indenter) doesn’t handle. Whether that’s deliberate or accidental by theat-exp
authors, I don’t know. I can say at least that using{braces}
as list delimiters inracket
is not idiomatic — for extra readability, typically[brackets]
are used, so maybe theat-exp
authors didn’t consider the possibility below. For instance, the bracketed version of your list indents as it should:Fixing it would require deeper knowledge of the
at-exp
indenter than I have. Perhaps post an issue atscribble
.PS. I won’t call it “better”, but you can use one or more Pollen source files strictly as a store of values, and
require
those into apollen.rkt
. Any variabledefine
d in a Pollen source is automaticallyprovide
d, and of course there’s alwaysdoc
andmetas
.Indeed, but I am creating an embedded DSL to define the HTML components and, in my language,
{braces}
are idiomatic in a few selected parts.I will. Thank you.
UPDATE: I opened the issue https://github.com/racket/scribble/issues/54.
That is a good idea. Maybe I'll do that.
Thank you very much for your time.