This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-02-09
Channels
- # beginners (205)
- # boot (6)
- # cider (22)
- # cljs-dev (41)
- # cljsrn (4)
- # clojure (97)
- # clojure-dev (61)
- # clojure-greece (40)
- # clojure-italy (8)
- # clojure-russia (16)
- # clojure-spec (18)
- # clojure-uk (34)
- # clojurescript (14)
- # community-development (1)
- # cursive (45)
- # datomic (39)
- # fulcro (66)
- # jobs (2)
- # lein-figwheel (1)
- # lumo (9)
- # off-topic (8)
- # parinfer (98)
- # portkey (8)
- # re-frame (81)
- # reagent (54)
- # remote-jobs (17)
- # ring (2)
- # shadow-cljs (217)
- # spacemacs (32)
- # sql (24)
- # test-check (6)
- # unrepl (73)
- # yada (12)
@shaunlebron What is the best place to point people to when they ask what smart mode is?
i was just about to record a quick video summary
but I wanted to demonstrate it in cursive
but it doesn’t work here yet
i probably just got the wrong version? intellij versions are confusing
That’s weird, it sounds like what @dave.dixon was reporting.
hmm, i’ll try a new clojure project then
@taylor So it was working for you, then it started failing on the same code, or you opened some new code and it didn’t work there?
I was editing a large CLJS file and it was definitely (maybe?) working when I started, but then eventually it ran into some issues with unmatched parens/brackets that I had to manually fix, and after that it seemed to have stopped working?
@shaunlebron Does it work if you’re editing the main code of that project rather than a test file?
that was what I first tried
I tried it in a new clojure project generated by intellij, and it worked in the core.clj file
then I pasted a long clojurescript file into a new cljs namespace in the project, and it didn’t work
oddly, it doesn’t seem to work on any CLJS files in my project at all now, not even a new blank one
should we move this to #cursive?
@cfleming can you review this 60 second video before I tweet it? https://www.youtube.com/watch?v=sl6d9M8jkvU
or anyone awake in this channel wanna look at it?
@shaunlebron Looks good to me!
cool, thanks for checking
wanted to make sure i wasn’t leaving anything out important
@cfleming: looks good in cursive
only thing I found missing was the last part of the video—selecting a line to correct indentation in isolation
@cfleming: this is the line that just turns off smart mode when any line is selected: https://github.com/shaunlebron/parinfer/blob/3.12.0/lib/parinfer.js#L1543
@shaunlebron Ok, I’ll check that.
@doglooksgood i was thinking about the performance problem with your elisp port
180ms for 2k lines doesn’t sound too bad if we just process top-level forms only
atom-parinfer still doesn’t process the whole file, despite it being able to
it just assumes that lines starting with (
are top-level forms
could be a quick workaround for now
It currently does like this. so in the most cases, it's okay. but in a project.clj
it may cause problem.
I'm wondering the dynamic module feature of emacs, that allow it load .so
or .dll
. If port parinfer.js to C, the performance should be good enough.
ha, I don’t see how that would work. thoughts?
I saw people who write JSX are painful for the close things. especially when they in some scopes like
xxxlist.map(x -> {
<div>
<h1>{x}</h1>
</div>
})
maybe if html was written this way:
<div>
<h1>{x}</h1></div>
haha, right
I’m just saying if we want to extend parinfer to other syntaxes, the closing tags have to be consistently placed (according to my current understanding)
maybe not though, i can already look at that and see how the closing tags can be correctly placed based on indentation, according to how people want it
yeah, maybe you’re on to something
I just think the close tag in xml can be inferred, no saying that parinfer should extended to do this stuff. but if we can determine where we put the closers, for most of the languages, this is the only difference I think.
the truth is , for most of the language, the indentation and the code block is relevant.
we can mock out this idea by replacing <div>
=> (
and </div>
=> )
assume divs for all tags
so now:
<div>
<h1>{x}
is equal to:
(
({x}
which should evaluate to:
(
({x})
)
and converting back:
<div>
<h1>{x}</h1>
</div>
that would be a fun experiment 🙂
@doglooksgood cool idea, good insight
right
it could be anything, I didn’t mean its brackets would be inferred
the code inside {} can have jsx tag too, so should wait { closed first. it's bit complex than lisp maybe
haha, we should probably just do HTML first
i wonder if it could work for JS too
it wouldn’t need anything from Smart Mode to work
1. determine where we put closer. 2. custom the opener and closer type. with these two enhancement, I think it will work for html at least.
to clarify why JS wouldn’t need Smart Mode stuff, replacing if
with for
below wouldn’t require the body to shift, since the body is always fixed indentation regardless of the position of the curly:
if (true) {
foo()
}
yeah, i think you’re right, that could be pretty simple to make work for html
parinfer-html
could be a pretty quick project 🙂
the smart-parens in emacs has these kind of work, it handle whatever thing you call them parens, not limited in normal parens.
JSX is nicer than HTML in terms of closing tag consistency
<input>
vs <input />
and <div></div>
vs <div />
honestly, I don’t struggle with writing JSX
easy to align the tags vertically, people like that. it’s just a bit verbose
but I struggle and a lot of my workmates struggled. I don't have to write JSX, we prefer clojurescript.
because it’s too much to type? or the fact that it doesn’t compose well with JS?
the JS interpolation is very awkward
I think the reason why I don't like it, I have to move the cursor here and there, you have to edit both begin and end, just like edit lisp without parinfer or paredit.
especially when you do wrap and raise from
<div>
x
</div>
to
<div>
<span>x</span>
</div>
ah okay, so it’s just the tag manipulation that you don’t like
another thing, i think why my parser in elisp is slow is that I try to save parse result in a vector