Skip to content

Paredit and (maybe) indentation breaks in REPL when prior output contains unbalanced parentheses #3102

@dsedivec

Description

@dsedivec

Expected behavior

REPL indent works when output contains unbalanced parentheses

Actual behavior

REPL indent raises an error when output contains unbalanced parentheses:

(wrong-type-argument wholenump -3)

Steps to reproduce the problem

  1. Open a Clojure REPL
  2. Eval (print ")))))")
  3. M-x indent-sexp RET

This seems contrived, but that's just for reproduction. TL;DR I think this error may be very common:

I actually ran into this in a shadow-cljs REPL, where the warnings have excerpts from my code. When a warning is, say, at the end of one of a defn form, the warning excerpt contains a bunch of close parentheses. Per CIDER's suggestion, I have Paredit turned on in my REPLs. After a CLJS warning with ...)) is printed, typing any open parenthesis yields an error because ( is bound to paredit-open-round, which calls indent-sexp.

ielm exhibits this same problem, BTW. I think SLY gets around this by assigning comment syntax to output, but I couldn't fully figure out how that works.

Environment & Version information

CIDER version information

;; CIDER 1.2.0snapshot, nREPL 0.9.0-beta5
;; Clojure 1.10.3, Java 17.0.1

Emacs version

Emacs 27.2 NeXTStep port from MacPorts (but also reproducible in my daily-driver master build, currently master from yesterday)

Operating system

macOS 11.6.1

Thank you hard-working CIDER developers, it's really awesome and so are you :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions