Fork me on GitHub
#protorepl
<
2016-12-08
>
seancorfield00:12:34

@jasongilman Is there an easy way to get it to treat (some-ns/with-some-thing …) as a “with” for indentation (which Emacs/Paredit does without configuration it seems)? i.e., I want

(some-ns/with-some-thing [some bindings]
  (the body))
rather than
(some-ns/with-some-thing [some bindings]
                         (the body))
which is what Cmd-Shift-i seems to do.

jasongilman00:12:29

@seancorfield: in the lisp paredit settings it will let you specify a list of forms for which it will do that indentation.

jasongilman00:12:46

I think you may be able to give it a regex

seancorfield00:12:03

Cool… will try that...

seancorfield00:12:42

:thumbsup::skin-tone-2: Perfect, thank you!

lspector04:12:26

Thanks @jasongilman. I have now installed the lisp-paredit package and set the settings as described in the page to which you linked, but I am not getting reindentation. This is probably because I didn't do anything in response to your comment that "You have to setup the init file and keymap there," because I don't know exactly what this means. Could you possibly spell out what I have to do for this, and where? I need auto-reindentation, but I do not want any other features of paredit or parinfer.

seancorfield04:12:50

@lspector There's an Init... option in the menus or you can use the fuzzy command search to find it... Let me fire it up and give you more precise directions!

seancorfield04:12:07

File > Init Script...

seancorfield04:12:01

Or Ctrl-Shift-p (Cmd-Shift-p on Mac) and type init and you should see Application: Open Your Init Script

seancorfield04:12:58

Either of those will open up init.coffee which is Atom's initialization script -- paste the init stuff in there and save. Then repeat for the keymap stuff... File > Keymap...

robert-stuttaford04:12:40

thank you for asking the questions @lspector and @seancorfield 🙂 now also a happy user of indentation in Atom. must read through @jasongilman’s carefully prepared gist more thoroughly...

seancorfield05:12:52

I just finished setting up my Win10 laptop with Proto REPL per that opinionated setup... and emacs-plus, disable-keybindings, clipboard-plus, git-plus... and some tweaks to the keymap to add more Emacs-y bindings for lisp-paredit since Jason's guide has those keybindings turned off 🙂

seancorfield05:12:14

(because they conflict with proto repl -- but I still want slurp / barf etc)

seancorfield05:12:07

Tonight I shut down Emacs on both machines. Tomorrow I'll only use Proto REPL and see how I get along.

robert-stuttaford05:12:26

😮 i can have slurp and barf? i see some yak shaving in my future

seancorfield07:12:38

'atom-text-editor[data-grammar~="clojure"],
 atom-text-editor[data-grammar~="lisp"],
 atom-text-editor[data-grammar~="newlisp"],
 atom-text-editor[data-grammar~="racket"],
 atom-text-editor[data-grammar~="scheme"]':
  'ctrl-alt-}':         'lisp-paredit:barf-forwards'
  'ctrl-alt-)':         'lisp-paredit:slurp-forwards'
  'ctrl-alt-(':         'lisp-paredit:slurp-backwards'
  'ctrl-alt-{':         'lisp-paredit:barf-backwards'

seancorfield07:12:10

(my keymap is way bigger than that, but that's the relevant portion @robert-stuttaford )

seancorfield07:12:30

I have 233 lines in my keymap so far 🙂

robert-stuttaford07:12:00

we have a public holiday coming up. i can see what i’m going to be doing with it 🤓

seancorfield08:12:21

Which public holiday is that?

seancorfield08:12:55

If you want to know more about my entire Proto-REPL-as-Emacs configuration so far, DM me 🙂

robert-stuttaford08:12:40

i very probably will DM you 🙂

jasongilman12:12:17

@seancorfield: I'm excited to hear how it goes. Let me know how the experiment works out for you.

lspector14:12:38

Thanks again @jasongilman, but alas I'm still not getting re-indentation. FYI on my mac the Init Script... and Keymap... items are in the Atom menu, not the File menu, but I found them, pasted in the text from your gist, saved, quit, and restarted... but still, command-shift-i (and the variants that I tried) don't re-indent anything. I guess maybe some other setting is getting in the way? FWIW IMHO it would be fabulous if this could somehow be made to work out of the box, without configuration, since I think it is a crucial feature.

jasongilman17:12:20

@lspector: I would recommend turning on the atom keybindings inspector. Cmd-. Will do that. Then you can press a keybindings and it will tell you which command it's running.

jasongilman17:12:29

I agree it would be nice to be built in. For now I'm relying on paredit. I think it would be a good thing for Parinfer to handle as well. I'm considering doing something with zprint.

lspector19:12:51

@jasongilman: After Cmd-., shift-cmd-I shows jason:indent-top-sexp

lspector19:12:21

but doesn't reindent the block it's in.

jasongilman20:12:43

@lspector: at that point I would throw in some console.log statements into the associated code in your init script. After doing that restart atom, open up the dev tools to show the console and then trigger the command.

jasongilman20:12:27

Somewhat ironic that I'm telling you to use println style debugging to debug the fancy visualization tool.

jasongilman20:12:51

If you can't find the code in your init script then that's the problem 😁

lspector20:12:56

Thank for this @jasongilman. I do see the code for jason:indent-top-sexp in my init.coffee, but I'm not exactly sure how to print anything (it's not Clojure 😕), and I think I've learned that the on-ramp is a little too steep for me at the moment. So I'm going to step back from this now but I appreciate your efforts to help and I hope to return at some point, because this looks like a great environment.

jasongilman20:12:09

That's reasonable. Thanks for giving it a try and providing feedback.

seancorfield21:12:33

Having a weird / annoying issue with adding newlines (I think it’s a Parinfer issue?): if my cursor | is as shown (f (a b)|) and I press enter, it adds a newline below and jumps to that, it does not insert a newline between the two closing parens. What am I missing here?

seancorfield21:12:20

I’m used to pressing enter and it leaving my code like this:

(f (a b)
   |)

shaun-mahood21:12:43

I get the same thing with parinfer on Cursive - I think it's just how it works (though I just started using it yesterday).

seancorfield21:12:35

Oh… if I start typing after newline, Parinfer adjust the parens around my code! That will take some getting used to!

fellshard21:12:56

Yeah, parinfers are actually really good about that

shaun-mahood21:12:58

Yeah, totally different result than I first expected too.

fellshard21:12:08

I believe they call that 'indent mode' vs. 'parens mode'?

fellshard21:12:23

So it determines parentheses wrapping based on indentation

fellshard21:12:45

Which also implies you could construct sexps using indentation alone if you really wanted 😉

fellshard21:12:04

"because python is hip right?"

seancorfield21:12:30

I’ll see how I get along with it… I’m so used to paredit’s way of doing things… I’ve already noticed that deleting a ) causes it to just move somewhere else (seems to slurp in paredit parlance?).

seancorfield21:12:44

I am finding the Git integration in Atom to be sub-par, compared to magit in Emacs. Even with git-plus installed.

seancorfield21:12:57

I can’t put my config.cson up there because it differs between Mac and Windows (Boot location plus a few other things)

seancorfield21:12:26

(and I’m now using git to keep my setup in sync between my machines)

fellshard21:12:37

Yeah, it'll use the indentation of subsequent lines to predict where it has to land

fellshard21:12:25

If you've ever used Haskell or ML, very similar intuition / rules to that, except here you just draw a line straight up from the first character in the current line and see what sexp it would fall in

fellshard21:12:38

(first line
    |    (second line)
    (third line
    |  (fourth line))
    (fifth line))

fellshard21:12:51

Which is in line with how the clojure standard formatting tends to go

fellshard21:12:18

If you line up and add a newline between the right closing parens and newline, it should (iirc) indent the next line appropriately to have the new sub-expression be slurped at the expected point

fellshard21:12:35

(map (fn [x] (and (seq? x)⤶) s)
should leave you with
(map (fn [x] (and (seq? x)
       |) s)

fellshard21:12:45

'pre-slurped' I guess

fellshard21:12:41

Though I'm guessing slurp and barf are probably better for keyboard use anyway

lspector22:12:31

Just a "FWIW unsolicited opinionated opinion" following up @shaun-mahood: I find much that parinfer does unexpected, and as a 30+ year lisper (and lisp teacher for most of that), I actually find it really problematic, even more so than strict mode paredit. Both are really clever and I'm sure some people love them. But I'm sad that Nightcode now uses parinfer and doesn't let you turn it off, and I hope that this doesn't befall other great tools in the Clojure world.

jasongilman22:12:33

If any of you are Parinfer opposed then you could use paredit exclusively. There's nothing Proto repl requires with Parinfer. My opinionated setup uses it because that's what I like.

shaun-mahood23:12:26

@lspector: I have no horse in the parinfer race yet, I did all my parens manually up until Tuesday this week 🙂 @sekao: ^ Any chance you could follow up on this with @lspector and maybe allow parinfer to be turned off in Nightcode?

seancorfield23:12:51

I’m starting to like some of what Parinfer does but I’m getting into a mess with it more often than I would like 🙂

shaun-mahood23:12:25

I've found that I don't think about parens as much, but I think about indentation a lot, lot more.

lspector23:12:24

@shaun-mahood: @sekao and I have discussed this, and apparently parinfer is baked into the latest Nightcode pretty hard, for reasons that make good sense relative to what's happening there... but alas, that still doesn't make it usable for me.

shaun-mahood23:12:44

@lspector: Too bad, it's such a good editor for starting Clojure (it was my first) - are you teaching Clojure currently?

lspector23:12:03

@jasongilman: Good to hear. To be clear, I find strict paredit to be problematic too, but it looks like you allow unstrict usage, which is great.

lspector23:12:22

@shaun-mahood: I agree, Nightcode was pretty great for beginners and I did teach with earlier versions. I'm on sabbatical at the moment so not teaching 😀. But I'll be supervising someone else teaching a Clojure-based course in the spring, and resuming my Clojure based courses next fall.

shaun-mahood23:12:13

@lspector: Awesome - any exciting genetic programming during your sabbatical? I really enjoyed your talk at last years Conj

lspector23:12:56

@shaun-mahood: FWIW I'm constantly trying and retrying all of the options I can find, and I switch pretty regularly. Most recently, I've used a modified version of Gorilla REPL (https://github.com/benfb/gorilla-repl)