calva

Wednesdays you might find @U0ETXRFEW in the Gather Calva space. Invite is https://gather.town/invite?token=GZqrm7CR and the password is `Be kind`.
pez 2021-01-23T03:14:30.073900Z

It sounds like a VS Code issue. I would start with looking what had been reported there.

pez 2021-01-23T03:16:56.074700Z

This is probably the same issue as this one: https://github.com/BetterThanTomorrow/calva/issues/971

pez 2021-01-23T03:17:36.075700Z

Please add a comment to that issue @agold

plexus 2021-01-23T10:19:51.077200Z

Has anyone figured out how to get the equivalent of emacs' aggressive-indent-mode? I've set "editor.autoIndent": "full" but that doesn't seem to be enough. For example:

(foo)
(bar)

;; slurp
(foo
 (bar))

;; barf, oh no!
(foo)
 (bar)

plexus 2021-01-23T10:20:28.077800Z

I'd like it to always always always auto indent no matter what I do, so it's impossible for indentation and code structure to differ

pez 2021-01-23T10:27:09.080200Z

That looks like an issue with the Calva formatter. It focuses on the enclosing form, and runs into troubles at the top level. File it on GitHub, I don't think we ever did that.

borkdude 2021-01-23T10:27:35.080900Z

funny, I recently asked how to make Calva indenting less aggressive like I'm used to in clojure-mode in emacs :)

😂 1
plexus 2021-01-23T10:27:55.081100Z

ok! I'll make an issue

borkdude 2021-01-23T10:28:21.081500Z

In general you can find some options here: https://calva.io/formatting/#configuration (@plexus)

borkdude 2021-01-23T10:29:44.083300Z

btw, pez, the docs are pretty!

❤️ 1
pez 2021-01-23T10:30:03.083900Z

@plexus, to verify that I have understood the problem correctly you can try the same procedure with fully enclosed forms.

plexus 2021-01-23T10:30:29.084300Z

for me this is really the holy grail, paredit + aggressive-indent, makes me feel like I'm actually manipulating a syntax tree instead of a text file

plexus 2021-01-23T10:30:52.084800Z

@pez you mean with something around it like

(do
  (foo)
  (bar))
?

pez 2021-01-23T10:31:29.085100Z

Yes.

pez 2021-01-23T10:34:36.087700Z

I also want to have one more notch of aggressiveness of the indentation to kick in. I have this feeling it might make parinfer less missed.

clyfe 2021-01-23T10:53:52.088300Z

I keep some paredit extras here: https://github.com/clyfe/calva-extras

clyfe 2021-01-23T11:06:07.089900Z

On a similar note I'd like paredit.deleteBackward in the formation " <space> (|)" to delete just the parens first, and on second key press to delete the space; not both at once. Or maybe I'll get used to and will prefer the current beavior.

plexus 2021-01-23T11:07:40.090800Z

sorry, got called away for a second. Works fine when it's not at the top level @pez

(do
  (foo
   (bar)))

(do
  (foo)
  (bar))

pez 2021-01-23T11:08:40.091700Z

Great. Then it’s not a regression at least. I’m at my computer now and could verify that as well.

plexus 2021-01-23T11:09:30.092700Z

> it might make parinfer less missed exactly, I always thought parinfer got it backwards. why manipulate structure via whitespace when you can just manipulate the structure and let the whitespace take care of itself (I'm aware many people will disagree with this sentiment 🙂 )

pez 2021-01-23T11:11:27.094Z

Parinfer does both, though? Especially if you are furtunate enough to be using an editor that can handle smart mode.

plexus 2021-01-23T11:13:40.095700Z

filed an issue https://github.com/BetterThanTomorrow/calva/issues/982

pez 2021-01-23T11:21:25.101Z

I think the Parinfer preference has a lot to do with personal, yeah, preferences. I was “forced” to think about Clojure code from te structural angle, because I learnt my first Clojure by pair programming with people who were using Emacs and shunned Parinfer. It stuck with me, even with my Python background. Paredit is my buddy. But for some it seems to be second nature (or quickly become at least) to indent their way to structure. I have a new colleague who belongs to that latter category, @anthony-galea. When we pair program I often notice that he accepts quite a lot of work to avoid Paredit. 😃

plexus 2021-01-23T11:36:55.103700Z

I have accepted that for some people parinfer works really well, I try to avoid getting into arguments about it, but I can't say I get it. And I strongly resist promoting parinfer for newcomers. If people figure out it works for them ok great, but it's clearly not a great fit for everyone. I've seen too many people (e.g. at clojurebridge workshops) just confuse themselves, accidentally ending up with some weird unexpected structure, and just having no clue how to come back from it.

roelof 2021-01-23T11:41:55.105400Z

Yep, I have seen a lot of these problems when learning clojure @plexus

pez 2021-01-23T11:46:24.109Z

I also avoid promoting Parinfer to newcomers. Of course somewhat because Calva’s auto-formatter does not play well with it, but mostly because I think Paredit is quite easy to learn and learning it helps in figuring out the structured nature of the code. But, yeah, arguing about this is boring. 😃 And, since the VS Code team does not get Parinfer either, Smartmode is not likely to become an option in this editor anytime soon.

roelof 2021-01-23T11:48:47.111300Z

but still I find calva very good to work with as a beginner

roelof 2021-01-23T11:48:57.111600Z

made even my first web project with it

pez 2021-01-23T11:50:38.113Z

The aspects I am interested in is mainly when Parinfer speeds up an operation. When I watch it being used I notice both that it is slower and that is faster than Paredit. I haven’t quite wrapped my head around it, but when I do I will try to use the understanding to make Calva editing more efficient.

pez 2021-01-23T11:52:03.113100Z

I saw that. 😃 Noticed that you have commited a lot of tempfiles produced by Calva, clojure-lsp and clj-kondo. Which reminds me that Calva should help with avoiding that.

roelof 2021-01-23T11:52:48.113300Z

oke

roelof 2021-01-23T11:53:30.113500Z

now im stuck because I thought of a way to use pre-loading but get a error message which do not tell where the error is

pez 2021-01-23T11:53:54.113700Z

pre-loading of what?

roelof 2021-01-23T11:53:57.113900Z

that I find a bummer about clojure. the error messages that are nor clear

roelof 2021-01-23T11:54:09.114100Z

pre-loading of some images from a external api

roelof 2021-01-23T11:56:50.114300Z

but this is off-topic of this channel

pez 2021-01-23T11:58:36.114500Z

Since we’re in a thread we can go off-topic, me thinks. 😃 Not sure if this is useful to you, but in my Advent of Code util.clj I cache my input data using memoize:

(defn- fetch-input' [day]
  (try
    (let [cookie (slurp ".aoc-session")]
      (:body (client/get
              (str "<https://adventofcode.com/2020/day/>" day "/input")
              {:cookies {"session" {:value cookie}}})))
    (catch Exception e
      (println "Ho, ho, ho! Did you forget to populate `.aoc-session` with your AOC session cookie?")
      (throw e))))

(def fetch-input
  (memoize fetch-input'))
Maybe images are not something that should be memoized.

roelof 2021-01-23T12:00:02.114700Z

it worked before

pez 2021-01-23T12:00:23.114900Z

Agree about error messages and stack traces often being less helpful than we have in other languages. But you will get better at recognizing the patterns, so the problem will not remain this big for you.

roelof 2021-01-23T12:00:31.115100Z

but I think this line mess things up

(future (memo-display-data (inc page))

roelof 2021-01-23T12:01:18.115300Z

but to get more info, I begin a question on the beginners question where you can find all the data

pez 2021-01-23T12:02:13.115500Z

Yeah #beginners is the place for this. I don’t have much experience with futures anyway. 😃

roelof 2021-01-23T12:02:37.115700Z

NP

roelof 2021-01-23T12:02:47.115900Z

maybe someone else can see what is wrong

roelof 2021-01-23T12:03:01.116100Z

Im just a beginner which have to learn a lot

pez 2021-01-23T12:03:11.116300Z

I think I saw an API key in your repo, btw. You might want to not have that public.

roelof 2021-01-23T12:03:43.116500Z

yep, I still have to learn how to hide it

roelof 2021-01-23T12:03:59.116700Z

but is a key from a company which do not exist anymore

pez 2021-01-23T12:05:16.116900Z

One way is the way I do it in the util code I posted above. Then I have .aoc-session in .gitignore.

roelof 2021-01-23T12:07:13.117100Z

oke

roelof 2021-01-23T12:07:27.117300Z

so like this :

{:cookies {"session" {:value cookie}}})))```

roelof 2021-01-23T12:07:49.117500Z

I have to think well how I can make that work

pez 2021-01-23T12:08:03.117700Z

It’s is rather this:

(let [cookie (slurp ".aoc-session")]

roelof 2021-01-23T12:08:14.117900Z

oke

roelof 2021-01-23T12:08:34.118100Z

and in the file .aoc-session I can put the key?

roelof 2021-01-23T12:09:18.118400Z

easy fix then , which I would do after I get this working again

pez 2021-01-23T12:11:52.118600Z

Yes, put the key in some file that is gitignored, then read it in. You can make a memoized function that does the reading, so that the server doesn’t read the file every time.

pez 2021-01-23T12:14:08.118800Z

Also, you might want to use <http://clojure.java.io/resource|clojure.java.io/resource> to predictably find the file: https://clojuredocs.org/clojure.java.io/resource

roelof 2021-01-23T12:14:43.119Z

oke, fix on my list

roelof 2021-01-23T12:15:00.119200Z

like I said first I want to make the site running again

pez 2021-01-23T12:15:02.119400Z

Also put on that list to change the key. 😃

roelof 2021-01-23T12:15:37.119600Z

and then practice more with 4clojure and exercism

roelof 2021-01-23T12:16:05.119800Z

and learn re-frame so that I can make the next idea I have for this site

roelof 2021-01-23T12:16:15.120Z

so enoughh to learn this year

roelof 2021-01-23T12:16:54.120200Z

and maybe even try some AOC challenges after exercism and 4clojure

pez 2021-01-23T12:19:18.120400Z

Good plan! I think Exercism should suit you very well, since you like getting feedback. It helped me tons and tons. There’s #exercism , btw.

roelof 2021-01-23T12:21:36.120600Z

yep

pez 2021-01-23T12:52:13.122Z

I’ve commented on the issue with top level formatting. Could be interesting reading for anyone who is curious about the innards of Calva structural editing: https://github.com/BetterThanTomorrow/calva/issues/982

pez 2021-01-23T12:53:45.123500Z

I think there are a lot of quite interesting things with Calva structural editing that I could write some articles about, btw. I might even start that soon. 😃

pez 2021-01-23T17:06:05.125200Z

Here’s a VSIX with a fix for the ; line comment bug that hits some of you. It might also fix the issue that @agold had with auto-closing quotes. Please try it out, Calva friends.

👍 3
😀 1
vlad_poh 2021-01-23T19:12:34.126100Z

what's the shortcut key for closing a tab in calva (ctrl w is taken)

pez 2021-01-23T19:29:05.127500Z

You'll have to assign a shortcut, @kbosompem . At least until we update the Calva shortcut.

👍 1
clyfe 2021-01-23T20:36:58.129Z

Toying with https://nextjournal.github.io/clojure-mode/ Nifty how modifier key highlights the form to be repl-sent.

❤️ 1
agold 2021-01-23T21:46:19.129200Z

@pez Worked like a charm! Many thanks!

❤️ 2
pez 2021-01-23T21:57:50.130300Z

Don't think it's possible with vscode, but would be so sweet!

Janne Sauvala 2021-01-23T23:33:21.132700Z

Hi 👋:skin-tone-2: is it possible to define keybindings for certain repl-commands? I would like to have a keybinding that would tap&gt; the form I’m evaluating. I noticed there is setting for calva.customREPLCommandSnippets but I think I cannot pass args to those snippets

pez 2021-01-24T11:22:04.139100Z

I think it should be solved with those command snippets. We recently pulled a PR that adds some editor variables to those snippets. Sounds like if we add variables for the current form and current top level form, we would handle this case. You think so too, @janne.sauvala ?

Janne Sauvala 2021-01-24T14:14:28.146900Z

Yes, that could work. I got the idea from Sean Corfield’s setup with vscode+Clover. And your suggestion could be how Clover handles custom command integration with the editor 👍:skin-tone-2:

bringe 2021-01-24T19:09:01.157100Z

I guess allowing params would make it way more extensible. Also if it seems many users are using the same custom command, maybe it's a candidate for a built-in command.

bringe 2021-01-24T21:28:16.170Z

I just re-read what @pez said and I'm not sure it hit me the first time. That sounds like a great idea. :simple_smile:

1
Janne Sauvala 2021-01-25T13:38:06.177300Z

I finally made an issue for tracking purposes https://github.com/BetterThanTomorrow/calva/issues/986

❤️ 2