Skip to content

Commit

Permalink
Add indent magic for redex 3+ hyphens; fixes #521
Browse files Browse the repository at this point in the history
  • Loading branch information
greghendershott committed Feb 24, 2021
1 parent e3f916f commit 75ea8f6
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
7 changes: 6 additions & 1 deletion racket-indent.el
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ the `racket-indent-function` property."
(let ((body-indent (+ (current-column) lisp-body-indent)))
(forward-char 1)
(if (or (racket--hash-literal-or-keyword-p)
(racket--data-sequence-p))
(racket--data-sequence-p)
(racket--all-hyphens-p))
(progn (backward-prefix-chars) (current-column))
(let* ((head (buffer-substring (point) (progn (forward-sexp 1) (point))))
(method (racket--get-indent-function-method head)))
Expand Down Expand Up @@ -228,6 +229,10 @@ Returns nil for #% identifiers like #%app."
(looking-at (rx ?\# (or ?\:
(not (any ?\%))))))

(defun racket--all-hyphens-p ()
"Magic for redex like what DrRacket does."
(looking-at (rx (>= 3 ?-) (and (not (syntax word)) (not (syntax symbol))))))

(defun racket--data-sequence-p ()
"Looking at \"data\" sequences where we align under head item?
Expand Down
15 changes: 15 additions & 0 deletions racket/example/indent.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,18 @@
[b : Number])
: Number
10)

;; Issue #521
(define-judgment-form L
#:mode (⇓ I I O O)
#:contract (⇓ Γ e Δ v)

[----------- Value
(⇓ Γ v Γ v)]


[(⇓ Γ e Δ (λ (y) e_*))
(⇓ Δ (subst e_* y x) Θ v)
------------------------- Application
(⇓ Γ (e x) Θ v)])

15 changes: 15 additions & 0 deletions racket/example/indent.rkt.faceup
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,18 @@
[b «b::» «t:Number»])
«b::» «t:Number»
«:racket-selfeval-face:10»)

«m:;; »«x:Issue #521
»(define-judgment-form «v:L»
«:racket-keyword-argument-face:#:mode» (⇓ I I O O)
«:racket-keyword-argument-face:#:contract» (⇓ Γ e Δ v)

[----------- Value
(⇓ Γ v Γ v)]


[(⇓ Γ e Δ («k:λ» (y) e_*))
(⇓ Δ (subst e_* y x) Θ v)
------------------------- Application
(⇓ Γ (e x) Θ v)])

0 comments on commit 75ea8f6

Please sign in to comment.