Skip to content

Inconsistent paredit selection between ignore form and other readers #2764

Open
@gaelrech

Description

@gaelrech

Disclaimer: This seems rather similar to #2164, but since I was experimenting a bit with it too I thought on adding to it. If you feel like centralizing there, it's fine by me.


Going a bit into the story first, I've tried using the joyride example script for ignore form trigger button, but it had a different approach to what I wanted. What I wanted was something that would get the current form I'm at (not the Up form, which I think is what it does in the example script.

I was able to make it work with joyride, but doing this logic for the ignore form is considerably trickier than doing for a regular clojure reader because the behavior to which the Paredit Expand Selection works on ignore forms is considerably differente than on regular clojure readers.

To show some of the testings:

; Where: 
; - `|` means the current placement of the cursor

; Generic reader
(do foo #foobar b|ar) => #foobar bar
(do foo #foobar |bar) => #foobar bar
(do foo #foo|bar bar) => #foobar bar
(do foo |#foobar bar) => #foobar bar
(+ 1 #foobar |(- 1 3)) => #foobar (- 1 3)
(+ 1 #foo|bar (- 1 3)) => #foobar (- 1 3)
(+ 1 |#foobar (- 1 3)) => #foobar (- 1 3)
; if the reader is glued to the fn call, it remains consistent
(+ 1 #foo|bar(- 1 3))=> #foobar(- 1 3)

; Ignore form
(do foo #_b|ar) => bar
(do foo #_|bar) => bar
(do foo #|_bar) => foo
(do foo |#_bar) => foo
(+ 1 #_|(- 1 3)) => #_
(+ 1 #|_(- 1 3)) => 1
(+ 1 |#_(- 1 3)) => 1

Like I said, I got it to work via a joyride script by treating different cursor placements and moving around according to each situation, so its not blocking me in any way. Regardless, it caught my attention because I'm not sure if this is the expected behavior for the ignore form, and my script became considerably more complex than one for a triggerable generic clojure reader (I have another script for adding/removing a hashp tag which ended up considerably simpler).

So just wanted to share my findings here in case this may be relevant for any debuggings of the ignore form behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpareditParedit and structural editingstructural editorToken Cursor, Lexer, et al

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions