Fork me on GitHub

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


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


I think you may be able to give it a regex


Cool… will try that...


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


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.


@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!


File > Init Script...


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


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


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


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 🙂


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


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


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


  'ctrl-alt-}':         'lisp-paredit:barf-forwards'
  'ctrl-alt-)':         'lisp-paredit:slurp-forwards'
  'ctrl-alt-(':         'lisp-paredit:slurp-backwards'
  'ctrl-alt-{':         'lisp-paredit:barf-backwards'


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


I have 233 lines in my keymap so far 🙂


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


Which public holiday is that?


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


i very probably will DM you 🙂


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


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.


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


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.


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


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


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


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


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


Thank for this @jasongilman. I do see the code for jason:indent-top-sexp in my, 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.


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


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?


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

(f (a b)


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


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


Yeah, parinfers are actually really good about that


Yeah, totally different result than I first expected too.


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


So it determines parentheses wrapping based on indentation


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


"because python is hip right?"


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


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


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


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


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


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


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


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


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


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


'pre-slurped' I guess


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


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.


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.


@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?


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 🙂


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


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


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


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


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


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


@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 (