proton

https://github.com/dvcrn/proton
dvcrn 2015-12-11T02:09:28.000006Z

Yeah, great to see that it's getting a bit more traction :simple_smile:

dvcrn 2015-12-11T02:09:38.000007Z

It also bypassed my sublimetext version in the first day

2015-12-11T02:09:43.000008Z

Haha nice.

2015-12-11T02:09:56.000009Z

sublime just isn’t as extensible as atom or emacs, so that isn’t too surprising

dvcrn 2015-12-11T02:11:06.000011Z

though performance is a big factor. Sublime still smokes atom in startup and rendering time

2015-12-11T02:11:22.000012Z

^^ true

dvcrn 2015-12-11T02:11:23.000013Z

that's why I cut the nuclide stuff again because it made atom soooo slooooow

2015-12-11T02:11:59.000014Z

Yeah, that’s true. I’ve got friends inside facebook who have an internal (to fb) build of nuclide and they say they don’t see any performance hit

2015-12-11T02:12:02.000015Z

That’d be nice

dvcrn 2015-12-11T02:12:43.000017Z

I read that too. I think it might be something with the babel compilation. afaik atom live compiles babel when you install the plugin

dvcrn 2015-12-11T02:14:40.000018Z

do you btw also have the problem that ctrl+j/k is not working anymore?

2015-12-11T02:23:57.000019Z

Let me check, I haven’t been using them...

2015-12-11T02:24:31.000020Z

Looks like they are killing lines

2015-12-11T02:25:26.000021Z

Well ctrl-j doesn’t do anything, ctrl-k cuts the line below

dvcrn 2015-12-11T02:26:38.000022Z

that's odd, something must have gone wrong with the keymap

dvcrn 2015-12-11T02:27:09.000023Z

Oh I have a theory, I think because we don't deep-merge keymaps yet

dvcrn 2015-12-11T02:27:15.000024Z

ah but keymaps are a vector so it shouldn't matter

2015-12-11T02:32:38.000025Z

I think that one of my PRs did apply deep-merge to keymaps

2015-12-11T02:32:45.000026Z

But yeah, as a vector it shouldn’t matter (I think)

dvcrn 2015-12-11T02:49:27.000028Z

also on installation it doesn't automatically reload the packages

dvcrn 2015-12-11T02:49:40.000029Z

usually after a installation it made sure that new packages are usable right away

dvcrn 2015-12-11T02:49:42.000030Z

something is weird

dvcrn 2015-12-11T02:53:16.000031Z

yeah the keymaps are not loaded

2015-12-11T02:58:07.000032Z

Weird, what could have broken?

dvcrn 2015-12-11T03:01:11.000033Z

yeah the deep merge on the layer map broke it

2015-12-11T03:02:27.000034Z

Shoot. Sorry

dvcrn 2015-12-11T03:02:59.000035Z

not sure why it was a merge in the first place, I think I messed this one up. It's a vector of maps so it should have been concatinated

dvcrn 2015-12-11T03:04:13.000036Z

now to check why packages don't get loaded right away

2015-12-11T03:04:44.000037Z

I’ve actually been seeing a bunch of packages ending up in disabledPackages of my ~/.atom/config.cson

2015-12-11T03:04:46.000038Z

You might want to check there

dvcrn 2015-12-11T03:05:48.000041Z

that could be it! The logic for disabling packages changed recently

dvcrn 2015-12-11T03:07:08.000042Z

hmm no, it's getting removed after installation so why is it not loaded

2015-12-11T03:07:22.000043Z

OT: Should we consider having proton (atom) update packages at startup?

dvcrn 2015-12-11T03:08:07.000045Z

I think not without the user specifying it. Imagine you wanna edit something and suddenly the editor loads for 5 minutes

dvcrn 2015-12-11T03:08:27.000046Z

(defn disable-package [package-name]
  (if (is-activated? package-name)
    (do
      (println (str "disabling package " package-name))
      (.disablePackage packages package-name))))

2015-12-11T03:08:49.000047Z

Good call. Maybe just add some command proton-update-pacakges and make a keymap spc _ U or something like that

dvcrn 2015-12-11T03:11:10.000048Z

if you wanna implement it, sure, go for it! 👍

dvcrn 2015-12-11T03:15:18.000049Z

@sglyon: ok fixed both of them. Do you have something fast you want to do otherwise I'm issuing a hotfix to atom packages

2015-12-11T03:15:47.000050Z

Sorry, I don’t understand the question

dvcrn 2015-12-11T03:16:14.000051Z

I mean

dvcrn 2015-12-11T03:16:18.000052Z

I wanna push a release to atom packages

dvcrn 2015-12-11T03:16:24.000053Z

do you have anything you want to get included

2015-12-11T03:16:48.000054Z

Ahh I see. Nope, let’s ship it. I’m skimming the atom API docs trying to figure out how to programmatically update packages

2015-12-11T03:16:56.000055Z

That might take a few minutes

dvcrn 2015-12-11T03:17:01.000056Z

it's not possible as far as I know

2015-12-11T03:17:04.000057Z

ahh

dvcrn 2015-12-11T03:17:11.000058Z

try to interop with apm on the shell and see if that can do it

dvcrn 2015-12-11T03:17:18.000059Z

that's how I install and remove packages too

2015-12-11T03:17:31.000060Z

Yeah apm works smoother for me most of the time also

2015-12-11T03:18:09.000064Z

Ahh cool

2015-12-11T03:23:53.000065Z

Ok my first real bit of clojure code… (haha actually a copy/paste mashup of the function you linked to and the one below):

(defn update-package [package-name]
  (println "Updating: " package-name)
  (let [c (chan)]
    (go
      (if (not (is-installed? package-name))
        (do
          (>! c true)
          (close! c))
        (do
          (.exec child-process (str (get-apm-path) " update " package-name " --no-colors")
            (fn [err stdout stderr]
              (if (nil? err)
                (.setTimeout js/window #(do
                                          (force-reload-package package-name)
                                          (println (str "done: " package-name))
                                          (go (>! c true))
                                          (close! c))
                 1000)
                ; on error just close channel
                (do
                  (go (>! c false))
                  (close! c))))))))
    c))

2015-12-11T03:24:05.000066Z

Anything look horribly wrong there?

dvcrn 2015-12-11T03:26:18.000068Z

seems like the same as install just with update 😛

2015-12-11T03:26:36.000069Z

Close… The first if is different

dvcrn 2015-12-11T03:27:12.000070Z

seems good, though a challenge would be to find which packages need an update

2015-12-11T03:27:19.000071Z

apm outdated

dvcrn 2015-12-11T03:27:27.000072Z

oh lol

2015-12-11T03:27:34.000073Z

:simple_smile:

dvcrn 2015-12-11T03:27:34.000074Z

didn't know about that 😛

2015-12-11T03:27:51.000075Z

proton|master:zap: ⇒ apm outdated --json
[]

2015-12-11T03:28:21.000079Z

Now to see how I can deal with the STDOUT… that might take more work for me to figure out in clojure

dvcrn 2015-12-11T03:28:49.000081Z

I think you can grab that from stdout

dvcrn 2015-12-11T03:29:24.000082Z

(.exec child-process "apm outdated --json" (fn [err stdout stderr])

2015-12-11T03:29:56.000084Z

lol now I just need an outdated package so I can have a test case

dvcrn 2015-12-11T03:30:25.000086Z

create a dummy package like proton and set the version to 0.0.1

dvcrn 2015-12-11T03:30:34.000087Z

atom will search it's repository for a higher version

2015-12-11T03:32:02.000091Z

Hmm, didn’t work.

dvcrn 2015-12-11T03:32:09.000092Z

huh? let me try

2015-12-11T03:32:23.000093Z

haha the real proton is killing it

2015-12-11T03:32:35.000094Z

Probably need to add it to my packages list

dvcrn 2015-12-11T03:32:37.000095Z

ah you have to of course put :proton inside your dotfile 😛

2015-12-11T03:34:04.000096Z

Yeah, not working for me still

dvcrn 2015-12-11T03:36:34.000097Z

hrrmm

2015-12-11T03:38:42.000098Z

I’ll just roll back to an old commit of one of my other packages

dvcrn 2015-12-11T03:38:55.000099Z

ah this works @sglyon :

dvcrn 2015-12-11T03:39:04.000100Z

go into ~/.atom/packages/<any-package>

dvcrn 2015-12-11T03:39:08.000101Z

change the version inside package.json

2015-12-11T03:39:12.000102Z

nice

dvcrn 2015-12-11T03:39:19.000103Z

/tmp/proton/plugin
λ apm outdated
Package Updates Available (1)
└── vim-mode 0.62.0 -&gt; 0.63.0

2015-12-11T03:40:20.000104Z

Oh geez I don’t want anything to do with that json output though

dvcrn 2015-12-11T03:41:40.000105Z

maybe a regex match from ── to a number or something

2015-12-11T03:41:49.000106Z

I mean the json isn’t so bad

2015-12-11T03:42:00.000107Z

it is an array of json objects, each of which has a name field

2015-12-11T03:42:05.000108Z

I can skip the rest of it

2015-12-11T03:42:47.000109Z

Is there a way to turn this stdout into a vector of maps?

dvcrn 2015-12-11T03:43:55.000110Z

(.parse js/JSON) to get an object and js-&gt;clj to convert it into a clojure map. Though david nolen mentioned before that it would be better to use goog libraries for dealing with js objects instead of converting them to clojure

2015-12-11T03:44:35.000111Z

I’m happy to leave it as json as long as I can ask the json what name is for each object in the array

dvcrn 2015-12-11T03:45:00.000112Z

try js/JSON then :simple_smile:

2015-12-11T03:45:37.000113Z

wait… can I access the proton ns/commands from the devtools?

2015-12-11T03:45:49.000115Z

That’d be killer

dvcrn 2015-12-11T03:46:01.000116Z

maybe from the REPL but from the devtools console, no

2015-12-11T03:46:09.000117Z

I’m seeing them now

2015-12-11T03:46:14.000118Z

(they tab complete)

2015-12-11T03:46:36.000119Z

proton.lib.package_manager.get_apm_path()
"/opt/homebrew-cask/Caskroom/atom/1.1.0/Atom.app/Contents/Resources/app/apm/bin/apm”

2015-12-11T03:46:44.000120Z

That came from the atom devtools console

dvcrn 2015-12-11T03:46:50.000122Z

oh lol

dvcrn 2015-12-11T03:46:59.000123Z

how did you compile it?

2015-12-11T03:47:17.000124Z

I’ve got a lein run -m build/dev-repl process running right now

2015-12-11T03:47:32.000125Z

So all the stuff is already js (no more clojure), but I can still interact with it

dvcrn 2015-12-11T03:47:44.000126Z

maybe because it is not optimized? @thheller can answer that probably 😛

dvcrn 2015-12-11T03:47:48.000127Z

Didn't know that was possible

2015-12-11T03:47:54.000128Z

Not sure, but I’m pretty happy it is possible :simple_smile:

2015-12-11T03:58:56.000130Z

Nice

2015-12-11T03:59:00.000131Z

JSON.parse worked — gave me an array of json obejcts

dvcrn 2015-12-11T04:02:59.000133Z

anything useful in there?

2015-12-11T04:03:47.000134Z

Yeah

2015-12-11T04:03:51.000137Z

proton.lib.package_manager.child_process.exec(proton.lib.package_manager.get_apm_path().concat(" outdated --json"), function (error, stdout, stderr) {
    var json_stdout = JSON.parse(stdout)
    var names = json_stdout.map(function(x){return x.name;});
    console.log(names)
});
&gt; ChildProcess {domain: null, _events: Object, _eventsCount: 2, _maxListeners: undefined, _closesNeeded: 3…}
&gt;  ["vim-mode”]

2015-12-11T04:04:17.000139Z

Now I just need to figure out how to return that names variable

2015-12-11T04:04:35.000140Z

Ahh is that what the channel is for in the install and remove package methods?

dvcrn 2015-12-11T04:31:00.000143Z

well there is also execSync, but I used a channel because otherwise each installation would block the entire editor

dvcrn 2015-12-11T04:31:18.000144Z

now it's async so it executes and we just pull the result of that execution back and display it

2015-12-11T04:31:31.000145Z

That’s very nice. I think I’m close

dvcrn 2015-12-11T04:31:48.000146Z

in theory just pipe it into the channel, close it and you should be good :simple_smile:

dvcrn 2015-12-11T04:31:58.000147Z

I'm going for lunch, will be back in 1h ish

2015-12-11T04:32:02.000148Z

quick question?

dvcrn 2015-12-11T04:32:06.000150Z

sure

2015-12-11T04:32:12.000151Z

I’ve got the array of json objects

2015-12-11T04:32:17.000152Z

now I want to do something like this:

2015-12-11T04:32:29.000153Z

(map #(.name %) (.parse js/JSON stdout))

2015-12-11T04:32:50.000154Z

where I was hoping the .name would give me the name field on that json object, but it didn't

2015-12-11T04:32:54.000155Z

How should I access that field?

dvcrn 2015-12-11T04:33:07.000156Z

to access properties, you have to use (.-name %)

dvcrn 2015-12-11T04:33:15.000157Z

.- is the interop for that

2015-12-11T04:33:37.000160Z

ok cool

2015-12-11T04:33:38.000161Z

success!

dvcrn 2015-12-11T04:33:42.000162Z

:simple_smile:

2015-12-11T04:33:48.000163Z

So can I shove the result of that map into the chan?

dvcrn 2015-12-11T04:34:15.000165Z

yep, or use the execSync version if it's fast enough for non async

2015-12-11T04:34:34.000166Z

Last question, how do I get it out of the chan?

2015-12-11T04:34:44.000167Z

(defn outdated-packages-chan []
  (println "finding outdated packages")
  (let [c (chan)]
    (go
      (.exec child-process "apm outdated --json"
        (fn [err stdout stderr]
          (if (nil? err)
            (do
              (println (str "The json is here: " (map #(.-name %) (.parse js/JSON stdout))))
              (go (&gt;! c (map #(.-name %) (.parse js/JSON stdout))))
              (close! c))
            (do
              (go (&gt;! c false))
              (close! c))))))
    c))

dvcrn 2015-12-11T04:34:44.000168Z

especially if you never used core.async it might be a bit tricky to understand 😛

2015-12-11T04:34:57.000169Z

Haha i’ve never used clojure...

dvcrn 2015-12-11T04:35:18.000171Z

(&lt;! channel) is for pulling out of a channel, put in cljs you can only use it inside a go block which is also a channel

2015-12-11T04:35:50.000172Z

so instead of that c at the end should I just do (go (&lt;! c)) to return the actual list of package names I want?

dvcrn 2015-12-11T04:36:06.000173Z

so you have to do something like

(go 
   (let [result (&lt;! mychannel)]
    (println result))

dvcrn 2015-12-11T04:36:15.000174Z

no, (go) is also returning a channel

2015-12-11T04:36:21.000175Z

ahh

dvcrn 2015-12-11T04:36:57.000176Z

you can't really return a value out of a go block. If you work with async, just put it inside the channel that you return (`c` in that case) and let the receiving part just pull that value out of it

dvcrn 2015-12-11T04:37:04.000177Z

oooor use the execSync version 😛

2015-12-11T04:37:08.000178Z

haha — I’m determined to learn the async stuff

dvcrn 2015-12-11T04:37:36.000180Z

really fun stuff, but also not that easy to grasp

dvcrn 2015-12-11T04:37:43.000181Z

I also have a lot of problems with it

2015-12-11T04:37:45.000182Z

I’ve seen these concepts in go

2015-12-11T04:37:52.000183Z

But haven’t done a ton with them

2015-12-11T04:38:15.000184Z

what about returning (&lt;!! c)

2015-12-11T04:38:23.000185Z

takes a val from port. Will return nil if closed. Will block
if nothing is available.

dvcrn 2015-12-11T04:38:33.000186Z

that's clojure. You can't use that in clojurescript

dvcrn 2015-12-11T04:38:38.000187Z

in cljs everything has to be inside a go block

dvcrn 2015-12-11T04:38:56.000188Z

<!! is for real threads afaik which we don't really have in cljs :simple_smile:

2015-12-11T04:39:03.000189Z

ok

2015-12-11T04:39:17.000190Z

Oh I think I see what to do

2015-12-11T04:39:19.000191Z

return the channel

dvcrn 2015-12-11T04:39:22.000192Z

check out this talk - very cool! https://www.youtube.com/watch?v=enwIIGzhahw

2015-12-11T04:39:43.000193Z

Then have my update-packages command just call the apm update methods from within a go block?

dvcrn 2015-12-11T04:40:55.000194Z

well if you copied my code then update-packages is also a async operation that uses channels. So calling update-package will give you a channel back

dvcrn 2015-12-11T04:41:24.000195Z

but yeah that should work. But feel free to experiment a bit around with it

2015-12-11T04:41:30.000196Z

Ok thanks

dvcrn 2015-12-11T04:41:58.000197Z

what helps me understand is that everything inside a go block is getting executed async

2015-12-11T04:42:11.000198Z

Pretty cool stuff

dvcrn 2015-12-11T04:42:29.000199Z

high recommendation for that talk up there. It's more clojure stuff but very cool

dvcrn 2015-12-11T04:42:48.000200Z

now going for lunch 🍞

2015-12-11T04:42:57.000201Z

But it’s about time for me to call it a night, so I might balk and just do execSync

dvcrn 2015-12-11T04:43:10.000202Z

sure!

2015-12-11T04:43:14.000203Z

This is a single call, so async doesn’t earn us anything (I think)

dvcrn 2015-12-11T04:43:36.000205Z

well I think atom is doing some requests to the repository though so it could take a while

dvcrn 2015-12-11T04:43:41.000206Z

I could rewrite it later on in async if you want :simple_smile:

dvcrn 2015-12-11T04:43:46.000207Z

if you get the sync version up

2015-12-11T04:43:49.000208Z

That’d be a good way to learn

thheller 2015-12-11T09:26:18.000209Z

@sglyon @dvcrn sorry didn't follow the conversation. what was the issue? 😛

2015-12-11T12:26:32.000211Z

No problem. There wasn't really an issue, @dvcrn was just helping me out with some basic stuff as I've never used clojurescript or clojure before.

2015-12-11T14:44:42.000213Z

Hi there.

2015-12-11T14:44:54.000214Z

@dvcrn what is the 'proton prompt'?

2015-12-11T14:45:21.000215Z

installed atom via .deb package from their site.

2015-12-11T14:46:28.000216Z

then

apm install proton-mode
as given on the github site.

2015-12-11T14:46:40.000217Z

after startup proton does some stuff.

dvcrn 2015-12-11T14:46:40.000218Z

that should work

dvcrn 2015-12-11T14:46:52.000219Z

and it still doesn’t work? Open a file and hit space

2015-12-11T14:47:06.000220Z

I see.

dvcrn 2015-12-11T14:47:13.000221Z

Do you have any errors in your console?

2015-12-11T14:47:23.000222Z

nope.

dvcrn 2015-12-11T14:47:26.000223Z

I just tested the store listed version and don’t have problems hmm

2015-12-11T14:47:31.000224Z

works.

dvcrn 2015-12-11T14:47:35.000225Z

oh?

2015-12-11T14:47:52.000226Z

would it be possible to start opening a file with space?

2015-12-11T14:47:59.000227Z

like space f f

2015-12-11T14:48:02.000228Z

like in spacemacs?

2015-12-11T14:48:29.000229Z

so i open a file with ctrl-o.

dvcrn 2015-12-11T14:48:44.000230Z

you mean on initial start?

2015-12-11T14:48:49.000231Z

yes.

dvcrn 2015-12-11T14:49:29.000232Z

that’s on the list :simple_smile: We need to get atom somehow to accept our command chain without a editor context

dvcrn 2015-12-11T14:49:39.000233Z

definitely something that should come soon

2015-12-11T14:49:39.000234Z

ah, i see.

dvcrn 2015-12-11T14:49:50.000235Z

if you have a file open though you can do &lt;spc&gt; p f to open the file searcher

2015-12-11T14:49:52.000236Z

so for now e.g. opening files is always with ctrl -o?

2015-12-11T14:49:57.000237Z

ok.

dvcrn 2015-12-11T14:50:20.000239Z

&lt;spc&gt; p r for recents and &lt;spc&gt; b b for buffers is also in

2015-12-11T14:50:28.000240Z

ok.

2015-12-11T14:51:14.000241Z

so does atom have a fuzzy file finder?

2015-12-11T14:51:24.000242Z

just asking, because maybe i can help a bit?

2015-12-11T14:51:34.000243Z

(though no expereience with clojure script)

2015-12-11T14:51:45.000244Z

<spc> f f would use the finder then, i guess?

dvcrn 2015-12-11T14:52:24.000245Z

p f is already fuzzy but if you want something even fuzzier, you can open ~/.proton and replace the OpenFileProvider :normal with :nuclide, though I can only recommend it if you have a medium powerful machine because it does a lot of babel compiling first

dvcrn 2015-12-11T14:52:32.000246Z

always looking for help :simple_smile:

dvcrn 2015-12-11T14:52:56.000247Z

Here’s also a doc how to contribute layers to get started https://github.com/dvcrn/proton/blob/master/HOW-TO-LAYER.md

2015-12-11T14:53:26.000251Z

ah, ok.

dvcrn 2015-12-11T14:53:40.000252Z

it’s a fun project to get started with clojurescript

2015-12-11T14:53:51.000253Z

for sure :simple_smile:

dvcrn 2015-12-11T14:54:35.000254Z

&lt;spc&gt; _ d opens your .proton file by the way

2015-12-11T14:54:45.000255Z

thanks.

2015-12-11T14:55:26.000256Z

just killed the only buffer, and

&lt;spc&gt;
menue at the bottom freezes/stays.

dvcrn 2015-12-11T14:56:09.000257Z

hrm yeah we definitely should put more focus on getting it work on non buffers

2015-12-11T14:57:21.000258Z

just a couple of questions:

2015-12-11T14:57:30.000259Z

how can i get highlighted search?

2015-12-11T14:57:48.000260Z

I search with "/" and then start typing

2015-12-11T14:57:52.000261Z

input is at the bottom

2015-12-11T15:00:42.000262Z

how can i change themes? I see the line in the .proton file, is it always like ["core.themes" ["theme-ui", "theme-syntax"]]?

dvcrn 2015-12-11T15:01:54.000263Z

ok for the first part, this is a limitation on atoms site but I already have that working on my local machine. Gonna merge that back in and then incremental search and highlights will work

dvcrn 2015-12-11T15:01:55.000264Z

for themes

2015-12-11T15:02:09.000265Z

that is super cool!

dvcrn 2015-12-11T15:02:42.000266Z

add your theme package inside additional-packages and change

["core.themes" ["atom-material-ui" "atom-material-syntax"]]
to reflect that

dvcrn 2015-12-11T15:02:48.000267Z

the first part is the ui, the second part the syntax theme

2015-12-11T15:02:58.000268Z

ok.

dvcrn 2015-12-11T15:03:21.000269Z

by default we use material but to get the default atom one back for example, just change it to [“core.themes” [“one-dark-ui” “one-dark-syntax”]]

dvcrn 2015-12-11T15:03:53.000270Z

if you are not sure about the name, you can also use the package installer to browse themes, change it and open your atom config (in the settings menu) to see how it is called internally. Then just add that to your .proton file

dvcrn 2015-12-11T15:04:06.000271Z

proton will get rid of all the stuff you tested and don’t need on next start

2015-12-11T15:04:16.000272Z

ah, ok! thanks!