Fork me on GitHub
#chlorine-clover
<
2020-04-09
>
fabrao01:04:22

Is there any way to hook saving file and call chlorine:clear-inline-results after that?

mauricio.szabo01:04:07

I believe you can do it using the init.js script. You can listen to text editors, listen to some callbacks, and so on. You probably want atom.workspace.observeTextEditors: https://flight-manual.atom.io/api/v1.45.0/Workspace/#instance-observeTextEditors

fabrao01:04:46

or you include an option that "Clean evaluates after save"

fabrao01:04:14

are you going to replace init.js after update?

mauricio.szabo01:04:51

init.js (or init.coffee) is a file that's user-specific

fabrao01:04:00

oh , sorry init.js is for atom not chlorine

mauricio.szabo01:04:38

Yes, the atom specific 🙂

fabrao01:04:09

something like

atom.workspace.observeTextEditors (editor) ->
    editor.onDidSave () -> atom.commands.dispatch(atom.views.getView(editor), 'chlorine:clear-inline-results')
?

seancorfield01:04:49

I think a workflow based on actions-on-save is flawed. I work without saving code a lot. I evaluate code as I write it and change it. I run tests too without saving changes. I clear inline results when I want. I save when I want -- and don't want any magic happening at that point.

seancorfield01:04:14

I think people need to get away from save-watch-run style workflows.

seancorfield01:04:28

But I'm very opinionated about workflow 🙂

seancorfield01:04:03

(luckily with Atom you can customize this any way you want but...)

fabrao01:04:23

Yes, but once you evaluate, evaluate, evaluate it become very anoying and messy

fabrao01:04:51

in Cider you only press ESC and done

fabrao01:04:47

so, this is adapt that guy from Emacs

seancorfield01:04:50

I find it very helpful to keep all those inline results around until I decide to get rid of them. I'd hate them all to vanish if I accidentally saved a file in the middle of some work! :rolling_on_the_floor_laughing:

seancorfield01:04:20

I used Emacs for years (technically decades). I've never looked back since I switched to Atom tho' ...

fabrao02:04:56

I´m in transition of it !!! 🙂 Cider is very very good

fabrao02:04:44

and the best tool for Clojure is clj-refactor

fabrao02:04:00

have you ever used it?

fabrao02:04:09

I think we can implement any kind of functions inside it in Atom

fabrao02:04:01

like you did in sean:... to use with rebl

seancorfield03:04:08

I've never felt a need for any automated refactoring tools.

seancorfield03:04:34

I think people rely too heavily on "tool support".

seancorfield03:04:25

Watch Stu Halloway's talks on "Running with Scissors" and "REPL-Driven Development". Watch Eric Normand's excellent course on REPL-Driven Development.

seancorfield03:04:06

It's the "Java disease" where people rely so heavily on IDE support that they no longer know how to write code in a plain editor.

fabrao03:04:54

I think in the way that the tool (IDE, editor, refactor ...) gives you support to do things that you think less to be more productive

seancorfield03:04:52

I disagree -- I believe that "thinking less" is a mistake. Fully understanding your (basic) tools is important. IDEs and refactoring tools lead to more "magic" and less "understanding". People who rely on them stop being able to do those actions without tooling support. Digital amnesia http://amnesia.kaspersky.com/

mauricio.szabo03:04:44

I remember one job in Clojure where people used mostly Intelij. The editor hide imports, adds and removes then at will, and also adds aliases for you. Some files imported 80 namespaces, and lots of test files had syntax errors (load file didn't work, but for some reason running tests worked fine). Also, some aliases were completely impossible to decipher - things like a-tx-inc-ml were common

mauricio.szabo03:04:42

As most people had a tool that organized these things automatically, people were used to not look at the namespace declaration and think "maybe we're importing too much..."

seancorfield03:04:44

I hate IDEs for that exact reason 😞

seancorfield03:04:27

(it's more widespread than just smartphones)

fabrao03:04:37

but if you think like clj-refactor helping me to organize :require stuffs that I included and clean that I do not use is very useful for me, that´s the way I mean about "thinking less" or "left using manual stuffs"

fabrao03:04:19

like you said "(luckily with Atom you can customize this any way you want but...)", in this case doing stuffs that can help me to be more productive, and the tool can be anything that you been conformtable

mauricio.szabo03:04:34

There are some feature that I'm planning to support from cider. In order of my personal preference are orchard extensions for documentation and goto var definition, hotload dependencies, organize ns, debugger and refactor. But the thing with Chlorine is: it'll never inject anything on the classpath. So, it'll use these features if they are present. If not, there will always be a "default option"

seancorfield03:04:39

What I do use is a real-time linter (`clj-kondo`) that prevents me from making a lot of mistakes that would need to be refactored later 🙂

👍 4
fabrao03:04:11

I´ve never used linter

sogaiu04:04:09

i hadn't used a linter much until clj-kondo, but it's near real-time capability completely changed my opinion of the worth of such a thing. to be informed while context is still fresh in one's mind is invaluable imo.

seancorfield04:04:19

I'd been using Joker for ages and found it useful enough, but clj-kondo is a game-changer.

sogaiu04:04:26

ah, that's interesting to hear. is there somewhere i might read up on some of those details?

seancorfield04:04:47

What do you mean?

seancorfield04:04:20

Joker only does a small subset of what clj-kondo does.

sogaiu04:04:15

ah ok -- i had never used joker, so i didn't know. so perhaps part of it is that clj-kondo manages to overcome a certain threshold of usefulness for enough people.

seancorfield04:04:07

Joker does basic unused requires and unused bindings stuff and local arity checking. Useful enough to be worthwhile.

seancorfield04:04:25

But until recently I had no idea how much stuff clj-kondo did.

seancorfield04:04:52

I finally decided to try it out... and switched immediately... and committed a .clj-kondo/config.edn to the repo at work! 🙂

sogaiu04:04:25

great! i found it a bit overwhelming to configure, so i haven't tuned it -- except for one case where i was using it programmatically and needed to turn off all of the linting.

mauricio.szabo12:04:32

I only used Joker so far, mostly because it was already installed (because it is also an interpreter with socket-repl support), but I'll try clj-kondo after this thread 😄

👍 4
seancorfield16:04:23

There's a linter-kondo package to wire up Atom to the command line clj-kondo command. Works well. Pity it only supports warning/error levels, not info.

seancorfield16:04:22

I just double-checked the source code and linter-kondo isn't at fault here -- clj-kondo itself only produces a non-zero exit code for warning/error levels and that's what triggers the linter to decode/display the summary results.

sogaiu04:04:01

i'd like to add a point to the refactoring discussion -- i have heard these types of discussions multiple times, but have always left feeling they tended to remain abstract. i think if concrete cases were discussed it would be much more enlightening to all parties involved. especially in the realm of cs / it, people seem to have very different notions of terms.

fabrao04:04:03

Ohhhh 😀

seancorfield04:04:08

I like that I can configure clj-kondo a lot: I've made unsorted requires an error 🙂

seancorfield04:04:37

And Borkdude is so responsive and works so hard to make it better all the time.

sogaiu04:04:12

indeed, those are definitely important points!

seancorfield04:04:36

Part of why I'm so passionate about Chlorine is because @mauricio.szabo is so responsive and proactive. The same is now applying to clj-kondo too.

😄 4
sogaiu04:04:46

i agree, @mauricio.szabo has been (and continues to be) great! it would be nice if this were true of more projects, but it is not so easy.

😄 4
seancorfield04:04:35

As someone who maintains a bunch of projects, yeah, it's definitely hard to be that responsive and that proactive!

sogaiu04:04:55

i often wonder if it wouldn't be helpful if there were a "successor" or "co-maintainer" in training. kind of like what the romans used to do 🙂

seancorfield04:04:33

For some projects, that naturally happens. I'm the third maintainer of tools.cli, the second for java.jdbc, the second for java.data and core.cache and core.memoize. The third for honeysql too I think? Maybe also clj-time. I was the second or third maintainer for congomongo and handed that off to someone else.

parrot 4
seancorfield04:04:06

Not all projects deserve to live. Important projects always get new maintainers. If a project dies for lack of a maintainer, then it wasn't important enough to live.

sogaiu05:04:40

it's nice when it works out, but i don't think it does all of the time.