The new drracket:grouping-position is documented to allow returning #t to mean "use s-expression grouping".
But that slightly predates the availability of syntax-color/racket-navigation. Given that, a lang that wants sexpr nav could instead:
Supply no grouping-position in its lang-info. The tool will use racket-grouping-position.
Supply racket-grouping-position for that.
Assuming it's some fancy "multi-lang" thing where some regions use sexpr nav but others do not (if that's an intended use case?), the lang's grouping-position could use racket-grouping-position (or not) for various regions, as opposed to returning #t for some regions. In other words it can completely abstract this.
Otherwise users of this (tools) will need to do things like this:
(let loop ([pos pos]
[count count])
(match (with-semaphore tokens-sema
(with-semaphore parens-sema
(match (grouping-position this pos limit dir)
;; Handle case where it returns #t, meaning
;; "use default s-expr grouping". That spec
;; slightly predates the addition of
;; syntax-color/racket-navigation --- the
;; availability of which probably means that
;; this #t value should no longer be returned?
;; In other words, if a lang wants s-expr nav,
;; its lang info should either not supply any
;; drracket:grouping-position at all, or,
;; return racket-grouping-position as that?
[#t
(when (equal? grouping-position racket-grouping-position)
(error 'grouping "racket-grouping-position returned #t"))
(racket-grouping-position this pos limit dir)]
[v v])))
[#f #f]
[(? number? new-pos)
(cond [(< 1 count) (loop new-pos (sub1 count))]
[(= new-pos pos) #f]
[else new-pos])]))
Which seems slightly tricky/weird.
TL;DR: I propose eliminating the #t return value from the contract and documentation, and, adding a mention or link to racket-grouping-position.
The new
drracket:grouping-position
is documented to allow returning#t
to mean "use s-expression grouping".But that slightly predates the availability of
syntax-color/racket-navigation
. Given that, a lang that wants sexpr nav could instead:racket-grouping-position
.racket-grouping-position
for that.racket-grouping-position
(or not) for various regions, as opposed to returning#t
for some regions. In other words it can completely abstract this.Otherwise users of this (tools) will need to do things like this:
Which seems slightly tricky/weird.
TL;DR: I propose eliminating the
#t
return value from the contract and documentation, and, adding a mention or link toracket-grouping-position
.