Skip to content

Add paredit setup for edn-mode#700

Open
grzm wants to merge 1 commit intoclojure-emacs:masterfrom
grzm:grzm/edn-paredit-setup
Open

Add paredit setup for edn-mode#700
grzm wants to merge 1 commit intoclojure-emacs:masterfrom
grzm:grzm/edn-paredit-setup

Conversation

@grzm
Copy link

@grzm grzm commented Mar 17, 2026

Like clojure-mode, edn-mode needs to coax paredit to auto-pair curly braces.

I've replicated the minimum set of features from the existing clojure-paredit-setup to edn-paredit-setup to allow auto-pair functionality for curly braces ({)

I tried to a test to confirm the behavior, but my emacs/buttercup testing skills aren't currently up to the task. Here's what I (naïvely) tried (added to edn-mode-indentation-test.el for experimentation).

(require 'paredit)

(describe "edn-mode paredit support"
          (describe "auto-pairs curly braces"
                    (it "should add a closing brace with an opening brace is inserted"
                        (with-edn-buffer ""
                                         (paredit-mode)
                                         (insert "{")
                                         (expect (buffer-string) :to-equal "{}")))))

Before submitting a PR mark the checkboxes for the items you've done (if you
think a checkbox does not apply, then leave it unchecked):

  • The commits are consistent with our contribution guidelines.
  • [-] You've added tests (if possible) to cover your change(s). Bugfix, indentation, and font-lock tests are extremely important!
  • You've run M-x checkdoc and fixed any warnings in the code you've written.
  • You've updated the changelog (if adding/changing user-visible functionality).
  • [n/a] You've updated the readme (if adding/changing user-visible functionality).

Thanks!

Like clojure-mode, edn-mode needs to coax paredit to auto-pair curly braces.
Copy link
Member

@bbatsov bbatsov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! The problem diagnosis is correct — edn-mode-map has prog-mode-map as parent, not clojure-mode-map, so the paredit {/} bindings from clojure-paredit-setup don't reach EDN buffers.

However, I think we can fix this without duplicating the setup function. The root cause is that clojure-paredit-setup defaults to clojure-mode-map when no keymap is passed. If we change it to default to (current-local-map) instead, the existing paredit-mode-hook (which edn-mode already inherits from clojure-mode) will just work for all derived modes automatically.

Something like:

(let ((keymap (or keymap (current-local-map))))

That single-line change should fix EDN mode (and any future derived modes) without needing edn-paredit-setup at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants