Fork me on GitHub
#emacs
<
2019-02-18
>
futuro16:02:52

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.

futuro16:02:14

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.”

andrea.crotti16:02:46

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

andrea.crotti16:02:28

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

dpsutton16:02:00

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

Chase16:02:21

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.

futuro17:02:33

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

Michael Griffiths17:02:07

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

Chase18:02:48

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)
      cnt
      (recur (if (= :h (first coll) (second coll))
               (inc cnt)
               cnt
               (rest coll))))))
What is the paredit way of getting that in there?

Michael Griffiths18:02:17

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

Chase18:02:59

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...

Chase18:02:43

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?

Michael Griffiths18:02:51

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

Chase18:02:14

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

Chase18:02:11

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

Chase18:02:45

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

Mattias19:02:59

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?

Chase19:02:48

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

cmack20:02:02

@mattias504 https://github.com/shaunlebron/history-of-lisp-parens there is a nice investigation here in the section on Editors

Mattias20:02:45

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

Chase20:02:44

And he had a fun talk a little why back. https://www.youtube.com/watch?v=K0Tsa3smr1w

Chase20:02:26

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.

Mattias21:02:41

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