This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-02-11
Channels
- # announcements (1)
- # beginners (84)
- # boot (325)
- # cbus (1)
- # cider (13)
- # cljs-dev (1)
- # cljsjs (1)
- # cljsrn (15)
- # clojars (8)
- # clojure (221)
- # clojure-czech (2)
- # clojure-ireland (8)
- # clojure-madison (28)
- # clojure-poland (176)
- # clojure-russia (111)
- # clojurebridge (7)
- # clojurescript (75)
- # community-development (70)
- # conf-proposals (19)
- # core-async (29)
- # css (12)
- # cursive (66)
- # datavis (15)
- # datomic (61)
- # devcards (15)
- # dirac (2)
- # editors (13)
- # emacs (9)
- # funcool (7)
- # hoplon (13)
- # jobs-discuss (5)
- # ldnclj (39)
- # ldnproclodo (1)
- # lein-figwheel (3)
- # leiningen (21)
- # liberator (26)
- # off-topic (12)
- # om (153)
- # onyx (168)
- # parinfer (165)
- # proton (21)
- # quil (5)
- # re-frame (58)
- # reagent (4)
- # ring-swagger (12)
- # spacemacs (3)
- # yada (120)
I've thought of turning on paren mode when pasting but haven't got around to trying it, I think it would make a lot of sense
Cursive can actually pre-process text on paste. This is something I’ve been thinking about doing for vanilla paredit - if the user tries to paste unbalanced text (by far the most common cause of unbalancing, for experienced users at least) I can pop up a window with the pasted text, highlight the bad parens and allow them to edit the text until it’s balanced before proceeding with the paste.
I’m thinking that in indent mode I’d adjust the indentation on paste so that it matches the point in the text that the user has pasted at.
Of course, lots of tricky corner cases if the user is replacing a selection with the pasted text, etc etc
what if you run indent mode to balance the parens, then paste in with paren mode, which would indent for you
Interesting, I hadn’t considered that since parinfer wasn’t around when I started thinking about it.
I guess for an arbitrary paste, I’d have to run paren mode first (like the first time you open a file in the editor), then indent mode, then paren mode on paste?
I guess the difficulty is that the problematic case on paste is when it’s unbalanced, and neither parinfer mode handles that well.
eh, it depends, pasting (let [foo bar
and turning it into (let [foo bar])
with indent mode would make sense to me
@cfleming: I had to add special support for the paste use case for Planck's use of Parinfer, but I bet there isn't much to share with respect to it. (The paragraph below the YouTube video in http://blog.fikesfarm.com/posts/2016-02-10-indenting-with-parinfer.html .)
@cfleming my gut feeling is that the popup paste correction window has the right intentions, but will be difficult to get right
when copying multiple lines of text, the user may start at the beginning of a line or start at the first paren instead
pasting it somewhere has the same problems. they may paste at the beginning of a line or somewhere to the right
i would keep with the rules of indent mode here. users manually manage indentation and everything else falls in place
under these rules, pasting code seems to be predictable and correctable for the inevitable minor indentation mistakes that result
@shaunlebron: Ok, I’ll try that first and see how people find it.
good question
chris never figured it out in atom
i’ll give you an example in a minute, brb
In fact, several of the caret parameters are difficult to calculate, depending on how the event happens.
The modification event happens on the document, but the editor holds the caret position.
This is because you might have two editors open on the same document, or you might have modifications to a document that isn’t being edited (e.g. as a result of a refactoring)
Also, is this a true statement: Paren mode only ever touches the leading indent of a line, and indent mode only ever deletes closing parens inside lines, and adds them at the end of lines?
short answer: cursorDx
can be computed if there is an onChange
event that communicates a portion of text that was added or removed and the position of the cursor
but it’s only important for pulling indentation of child expressions back when you move its open-paren container back
not many people are using paren-mode honestly
paren mode will move close-parens in some situations
(let [a 1
])
will be changed to:
(let [a 1])
Since there might be multiple editors looking at the doc, or none. I don’t think I have any way to determine whether a particular change is as a result of a user action in a particular editor.
it’s not something that is critical for a first run of parinfer in cursive
atom-parinfer has never had it, and no one has ever filed an issue
there are complaints about other things, but paren mode never seems to come up
i think folks are sticking to indent mode
What I can do is to maintain a list of open editors for a particular document. When I get a document event, I can see if the caret of any of those editors is at the boundaries of the change result - that is probably as a result of a change in that editor.
But there are some important cases that require knowing which line the caret is on, right?
definitely
part 2 of the design doc covers a bunch of cases that need it
Or at least, I’m going to have a set of them in the case where there is more than one editor.
I’ll probably have to modify the algorithm to clamp the paren trail on any of the caret lines.
that’s strange
sorry, coming in and out of conversations
so yeah, seems strange that it’s hard to determine where the cursor is in a document
a document can have multiple editors
I think that’s fine
when an editor changes a document, process the document with that editor’s cursor information
I suppose we’re using cursor/caret interchangeably here
The problem is that on the document change event, I don’t know which editor (if any) caused the change.
hmm, is intellij open source?
might be a good PR
yeah, that’s a good idea
makes me wonder if there are other types of plugins that would need such information
my first interaction with a text editor API was codemirror, which had this info readily available
so I assumed it was standard
i’ll check sublime-parinfer real quick
it has an on_modified
event for every view
so I suppose there can be multiple views for a document
i.e. tabs/windows
well, I’m guessing here
but suppose I had two tabs opened to the same file
editing on one view will cause the document to update
or its buffer, whatever
if the other view syncs, then that’s fine
the other view will only transform if its view’s on_modified
is called
Yeah, depends if there are two on_modified events, or one and then the other doc is updated somehow.
But it’ll have its caret position moved and so forth, I’d expect it to get an update.
each view has a selection
, which describes the caret position
Right, so it’s like an Editor in IntelliJ. The difference is that their on_modified receives the view, whereas mine doesn't
I wouldn’t expect the secondary view to kick off an on_modified
event based on the first view
Again, for a text editor they can assume that all changes are as a result of user action in a view
i would expect them to sync views though
nice!
yeah, share the post link here when you do
curious to see
oh, I imagined a larger intellij community
well that makes cursive all the more impressive then
at least it’s open source though
i guess that makes up for lack of docs
but you said humungous, so maybe not
I’ve never used cloc
find . -name “*.java” | xargs wc -l
is my poorman’s cloc I guess
haha, that’s worked for smaller codebases at least
30k files!!!
~/d/community (master)> cloc .
78158 text files.
67816 unique files.
14590 files ignored.
v 1.62 T=605.99 s (95.9 files/s, 9563.3 lines/s)
----------------------------------------------------------------------------------------
Language files blank comment code
----------------------------------------------------------------------------------------
Java 46707 571050 689600 3201834
Python 6086 103644 155924 416348
XML 1845 12473 3389 281530
XSD 256 14623 3093 148651
HTML 2133 6639 3829 58595
Kotlin 312 5821 4956 29677
<snip>
Erlang 1 0 0 1
----------------------------------------------------------------------------------------
SUM: 58140 726580 875219 4193527
----------------------------------------------------------------------------------------
blank/comment?
where are the code lines?
oh, my slack window was too narrow
yeah wow
yeah, intellij must do so many things
shame api isn’t documented
plugin api*
i feel spoiled
codemirror was <9k
it was such a pleasure to read
can’t imagine cutting my teeth on 3.2m
Yeah, Marijn has a post where he talks about the pleasure of working on small, self-contained codebases
cool, does he speak at conferences? never looked
cool, I’ll check that out, I like his coding style and his project focus
yeah, stripe does I think
k cool, catch you later
btw, handling multiple cursors in parinfer would fix the issue like you said in the post
@shaunlebron: Yeah, I think I’ll do that tomorrow if I don’t get a response