Fork me on GitHub

I wonder what it would look like to have a function rescan the buffer every time you insert or remove a paren, and alert you if that action caused an imbalance.


It seems like the problem is often phrased as having a buffer with an imbalance and finding the paren that caused it, but the use case is “I took an action that imbalanced my parens, but didn’t know it.”


if you use paredit & co you simply can't have an imbalance


(depending on how you configure it I guess, but still they have your back most of the times)


kill-region will let you clobber parens. there are ways around paredit unfortunately


yeah, I had to learn that C-q ) will let you force in a closing paren when I have somehow done something that even confuses paredit.


Yeah, I’ve had plenty of times where it’s gotten unbalanced. So the problem remains.


Try M-x check-parens – you could always add this to a hook to run it automatically, e.g. after-save-hook or after-change-functions


so can I ask paredit questions here? So in this function I left out a closing paren after cnt in the second to last line:

(defn count-heads-pairs [coll]
  (loop [cnt 0 coll coll]
    (if (empty? coll)
      (recur (if (= :h (first coll) (second coll))
               (inc cnt)
               (rest coll))))))
What is the paredit way of getting that in there?


With point at the end of that line, C-} (`paredit-forward-barf-sexp`)


perfect! oh man, that was probably just basic stuff right there but I can see the power in really learning these tools. those old school names tho...


so forward-barf-sexp because it brought cnt into the if s-expression. so it was like the if exp brought it into the fold?


I’d say the other way around – it “barfs” the (rest coll) forward out of the if


ahh! See yeah, i'm missing the conceptual reasoning in the names. that makes more sense


i just had that open! I was looking for how to slow down those gifs


i think i was confusing myself by thinking slurp-forward should be the same as barf-backward so why have both


So, I’m curious. People have been editing Lisp-like things since the 60s or something. What’s the brief history of lisp editing? There must have been an editing winter of say 40 years when no ideas were had?


can't help you there but I have just started watching the old SICP lecture videos and it was fun to see that even back then the editor (edwin?) would highlight that you closed a paren and Hal Abelson mentioned how awesomely useful that is for lisp editing. Maybe a fun topic for #off-topic


@mattias504 there is a nice investigation here in the section on Editors


Hah. Of course there is. Thanks! Just recently listened to Shaun on one of the Clojure podcasts, very good and informative. 😀


And he had a fun talk a little why back.


Parinfer intrigues me but I'm just not a fan of modal editing. I think they have created a smart mode though that might take the modal part away. I'm not sure and don't think that update has made it to emacs yet.


That history thing was amazing. Had to read all of it. Even sad there are parts missing. Lots of cool stuff there 🙂