I'm not sure about the suitable configuration: that should probably
happen via the #lang line and shouldn't be configured "from the
outside" (we're not quite there yet, but that's where we should be
heading, IMO).
But for point 2, here's a script. It depends on the GUI library.
Removing that dependency is possible, but probably a lot of work.
Robby
#lang racket/base
(require racket/gui/base
racket/port
racket/class
framework)
(define (indented-properly? port)
(define-values (out1 in1) (make-pipe))
(define-values (out2 in2) (make-pipe))
(thread (λ ()
(copy-port port in1 in2)
(close-output-port in1)
(close-output-port in2)))
(define (insert-it port chan)
(thread
(λ ()
(define t (new racket:text%))
(send t insert-port port)
(channel-put chan t))))
(define c1 (make-channel))
(define c2 (make-channel))
(insert-it out1 c1)
(insert-it out2 c2)
(define t1 (channel-get c1))
(define t2 (channel-get c2))
;; this is the important line
(send t1 tabify-all)
;; this should really compare snips, not characters
(and (= (send t1 last-position)
(send t2 last-position))
(for/and ([x (in-range (send t1 last-position))])
(equal? (send t1 get-character x)
(send t2 get-character x)))))
(define illindented-candidate
(string-append
"#lang racket\n"
"(define (f x)\n"
"x)"))
(define well-indented-candidate
(string-append
"#lang racket\n"
"(define (f x)\n"
" x)"))
(indented-properly? (open-input-string illindented-candidate))
(indented-properly? (open-input-string well-indented-candidate))
On Thu, Aug 25, 2016 at 3:52 PM, David Christiansen
<[email protected]> wrote:
> Hi all,
>
> As far as I know, the standard for indentation in Racket is "Do like
> DrRacket", after DrRacket has been suitably configured for new syntax
> introduced by the application in question.
>
> I'd like to arrange for this to be enforced by Travis. As far as I can
> see, my building blocks for this are the following:
>
> 1. A way to represent indentation specifications for new syntactic forms
>
> 2. A way to invoke automatic indentation on a file without running a
> GUI, using these specifications in addition to the default rules
>
> Is there a canonical way to achieve these things?
>
> Thanks!
>
> /David
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.