Add paredit setup for edn-mode#700
Conversation
bbatsov
left a comment
There was a problem hiding this comment.
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.
09f018e to
e18ec2e
Compare
|
That's the knowledge your years of emacs-lisp experience provides :) Thanks for explaining. I've updated the patch as suggested. (And thanks for your patience!) |
CHANGELOG.md
Outdated
|
|
||
| ## master (unreleased) | ||
|
|
||
| * Update current-local-map during clojure-paredit-setup to work with edn-mode |
There was a problem hiding this comment.
You should also add a "Bugs Fixed" heading for this entry.
| replacement for `cljr-expand-let`." | ||
| (when (>= paredit-version 21) | ||
| (let ((keymap (or keymap clojure-mode-map))) | ||
| (let ((keymap (or keymap (current-local-map)))) |
There was a problem hiding this comment.
Don't forget to update the docstring above as well. (it still mentions clojure-mode-map as the default)
Using current-local-map instead of clojure-mode-map allows the edn-mode-map to be updated in edn-mode (and, of course, the clojure-mode-map to be updated in clojure-mode). Using clojure-mode-map directly prevented edn-mode from inheriting the benefits of clojure-paredit-setup, such as auto-pairing curly braces.
e18ec2e to
12cc356
Compare
|
It's not clear to me why the windows-latest and ubuntu-latest/snapshot CI checks are failing when the others are still passing and the error messages are inscrutable to my naïve eyes. Any hints as to what might be going on? |
|
Don't worry, that's not related to your changes. Thanks! |
|
Thanks! |
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-setuptoedn-paredit-setupto 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).
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):
M-x checkdocand fixed any warnings in the code you've written.Thanks!