Fix auto-insertion of spaces in paredit - #566
Conversation
| (not (memq delim '(?\" ?{ ?\( ))) | ||
| (not (or (derived-mode-p 'clojure-mode) | ||
| (not (memq delim '(?\" ?\{ ?\())) ;; always insert for [ | ||
| (not (or (derived-mode-p 'clojure-mode) ;; FIXME why does this check exist |
There was a problem hiding this comment.
Because without it this code would be applied to any mode where paredit is enabled.
There was a problem hiding this comment.
Ah, I thought it was a mode local variable - will add it back in.
There was a problem hiding this comment.
Actually, wouldn't it make more sense to do (make-local-variable 'paredit-space-for-delimiter-predicates) inside clojure-paredit-setup rather than add global predicates?
There was a problem hiding this comment.
I guess that's an option as well.
| (describe "Interactions with Paredit" | ||
| ;; reuse existing when-refactoring-it macro | ||
| (describe "it should insert a space" | ||
| (when-refactoring-it "before lists" |
There was a problem hiding this comment.
I get the point of using this macro here, but probably we need some alias for it, otherwise the tests read a bit weird. Probably not a big deal, though, as I can't suggest a great name right now - something like with-edits/actions.
There was a problem hiding this comment.
I couldn't think of a name as well, but at least the console output makes sense -
Interactions with Paredit:
it should insert a space
before lists (0.19ms)
before vectors (0.17ms)
before maps (0.16ms)
before strings (0.15ms)
after gensym (0.20ms)
after symbols ending with ' (0.19ms)
it should not insert a space
for anonymous fn syntax (0.19ms)
for hash sets (0.17ms)
for regexes (0.16ms)
for quoted collections (0.17ms)
for reader conditionals (0.17ms)
Consolidate into single predicate, make collection-tag-regexp obsolete
|
I did some more refactoring, realising that the other function
|
|
Also I'm not a Paredit user myself (which is why this issue originally went unnoticed), so it would be great if someone could help test these changes out! |
Agreed.
I guess you're into smartparens or lispy, right? Given the unit tests I'm reasonably confident with your changes, so I'll just merge them and see what feedback we'll get. I'm using paredit, but I guess I don't update my Emacs packages often enough if I didn't notice this myself. :D |
Fixes #565
The first 3 commits should be squashed together, I just found the original function hard to understand and had to refactor it along the way and then remove what seemed like uneccessary checks.
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.