Fork me on GitHub

ok, I really get paredit and never deleting parenthesis, but sometimes when the buffer gets scrambled (because I use evil and sometimes some commands do the wrong thing), I would just like to be able to edit normally to get back to a proper state. What is your workflow for doing that?


I just undo when that happens

Roman Rudakov12:01:57

In smartparens-mode (and probably in paredit-mode as well) any symbol prefixed with C-q will be inserted as is, even it it produce unbalanced expression.

Roman Rudakov12:01:44

I don't use evil, so you probably should check keybinding for quoted-insert command


Disable it temporarily, make the change, then re-enable it? Paredit is a minor mode, right? It should have an interactive command called paredit-mode to toggle it on or off.


yeah M-x paredit-mode or this defun which I bind to shift+backspace:

(defun vemv/force-backspace ()
  "Performs a deletion, overriding paredit safeguards"
  (if (region-active-p)
      (progn (call-interactively 'kill-region))
    (delete-region (dec (point)) (point))))


Fellow borrowers of the above defun will want:

(defmacro dec (n)
  `(- ,n 1))
I like the idea of binding S-<backspace> better than toggling smartparens-strict-mode which is what I was doing till now - thanks for the tip @U45T93RA6

🍻 1
Linus Ericsson14:01:52

paredit don't know about cut with C-w, and paste with C-y, which might come handy.

Linus Ericsson15:01:17

So when these things happens i usually mark the superflous parenthesis and cuts it with C-w. If a parenthesis is missing - i copy one of the kind that is missing and paste one where it is missing.


There are Emacs packages to configure Evil to respect Clojure structure, such as This helps minimise the issue occurring when using vim-style editing. Otherwise I would toggle the mode (I use smartparens in Spacemacs and toggle is SPC t p ) I like the idea of using C-q as a shortcut, as its usually just one paren. Also useful for copy paste fixes which easily have the same potential issue.


I also “cheat” with C-w/`C-y` if it’s just a matter of a single errant or missing paren. If it’s more generally scrambled I disable paredit temporarily with M-x paredit-mode.

☝️ 1

I use evil and smartparens, so when I'm in a state with unbalanced parens (usually only happens for me when fixing merge conflicts), I toggle smartparens-strict-mode with turn-{off,on}-smartparens-strict-mode

🙌 1