Fork me on GitHub
#emacs
<
2016-04-20
>
dpsutton12:04:25

i'm working on a patch for cider to issue a warning if the clojure version is not supported by looking through project.clj and build.boot files. My regex: "org.clojure/clojure\s-*\".*\"" works just fine. But when i add the capturing group, it can break: "org.clojure/clojure\s-*\"\\(.*\\)\"". Does anyone have any thoughts on this?

dpsutton12:04:05

it breaks on the build.boot file for cprop which has the line: :dependencies '[[org.clojure/clojure "1.8.0"]

dpsutton12:04:31

but it works without the capturing group. The capturing group version works on all other examples that i have

dpsutton12:04:07

i've got this one now. It seems to work when i call it directly but not when my functions do: "org.clojure/clojure\s-*\"\([\.0-9]+\)\""

dpsutton12:04:18

Well, in the future, if you are wondering, emacs regexes are dumb and require many slashes. "org.clojure/clojure\\s-*\"\\([.0-9]+\\)\""

dpsutton12:04:54

i'm still not sure if the single slash double quote is a ticking time bomb or not

malabarba12:04:25

the thing is that emacs regexps are strings

malabarba12:04:05

so if you want a regexp with a backslash, (like \(), you need to escape that backslash

malabarba12:04:21

because \( is the same as ( in strings

malabarba12:04:30

it's a single char

dpsutton13:04:30

thanks malabarba. I'm gonna write a few tests tonight and then submit the pull request

malabarba13:04:30

so you need to write \\( in the string

malabarba13:04:43

so that the regexp engine actually sees the \\

dpsutton13:04:04

i've also seen that if you are lacking boot and try to run cider-jack-in, you get back a wrong argument stringp message instead of something useful

dpsutton13:04:12

so that'll be my next quality of life feature for cider

dpsutton13:04:07

yeah the hammer dropped on me when you explained that. I understand the significance of different syntaxes for regexes in other languages now

malabarba13:04:50

as for the clojure-version thingy. I feel almost bad saying this, considering the pain you had with regexps, but I think there's a better way to do it.

dpsutton13:04:08

i learned. so even if the code itself is thrown away no biggie

dpsutton13:04:17

are you going to ask nrepl what version of clojure is loaded?

malabarba13:04:25

If you jack-in to a project with an old clojure-version, does evaluation still work?

dpsutton13:04:28

i thought about that but worried that if there was an error it may not be able to report it

dpsutton13:04:38

it does, but with the error message i posted a screenshot of

dpsutton13:04:44

where it complains about an nrepl mismatch

dpsutton13:04:47

and some things break

dpsutton13:04:00

notably M-, navigation

malabarba13:04:22

Then I think the best approach is to run (cider-nrepl-sync-request:eval "*clojure-version*")

dpsutton13:04:36

haha. yeah you're probably right

malabarba13:04:40

This will return the proper clojure version being used

dpsutton13:04:28

and then it looks like those responses are put into a dictionary or hashmap somewhere, is that correct?

malabarba13:04:50

Yes, but that's not how you use them

malabarba13:04:57

with async requests you would have to use a callback

malabarba13:04:07

but with sync request the respoinse is simply returned directly

malabarba13:04:12

so you could do something like this

malabarba13:04:29

(let* ((response (cider-nrepl-sync-request:eval "*clojure-version*"))
       (clojure-version (nrepl-dict-get response "value")))
  (complain about clojure-version))

dpsutton13:04:03

I also saw that there is a version< function out there. I see that explicitly clojure versions 1.7.0 and 1.8.0 are supported. I used these values explicitly rather than set a benchmark of > 1.7.0 as i'm not sure how many point releases of clojure are released, and if it would ever be possible to support say 1.7.0, not 1.7.1, 1.8.0, etc

dpsutton13:04:33

but i may just make it along the lines get clojure version, complain if version< cider-minimum-clojure-version

malabarba13:04:08

Yes, use version<

malabarba13:04:14

I was going to say that too

dpsutton13:04:19

thanks so much for the pointers

malabarba13:04:23

I was on my phone yesterday so couldn't type much simple_smile

dpsutton13:04:42

and huge thanks for all your work on the debugger and general help on the dev mailing list. you are a rockstar man

richiardiandrea15:04:26

After the recence talk about types at Clojure/West, I would like to ask here how and what folks use for racket in emacs? There in geiser and racket-mode. Ideally I would like to keep the cider workflow :)

dpsutton15:04:41

what do you mean by cider workflow?

dpsutton15:04:08

but in general things work like slime/cider, etc with repl's and emacs

dpsutton15:04:23

you create a server, connect over sockets, and emacs nicely sends info back and forth

base69816:04:17

Slime? What is this 2011?

nkraft16:04:12

Emacs? What is this 1975? simple_smile

dpsutton16:04:22

wut? we can't bash common lisp in here

dpsutton16:04:28

this is an emacs channel about clojure haha

richiardiandrea16:04:23

I tried geiser but I think I will need to add quack and change a lot of key bindings

richiardiandrea17:04:38

oh too bad, Paredit does not like typed clojure

dpsutton18:04:17

what's the problem with paredit and typed clojure?

dpsutton18:04:46

oh yeah. that's why i had to get rid of lispy. the [ characters are a navigation command and not a printing character in that mode.

richiardiandrea20:04:19

smartparens works and oh...did not know about modules, that is why it was not finding my symbols 😄

christianromney21:04:27

I use geiser and it’s nice enough. i don’t code in Racket that often though

bozhidar21:04:23

geiser is pretty similar to cider

bozhidar21:04:52

they even have some nice advantages there

bozhidar21:04:04

e.g. their REPL is comint based, unlike our custom REPL

bozhidar21:04:11

and is way nicer

bozhidar21:04:25

and images are displayed in the REPL

bozhidar21:04:42

obviously we can do both these things, but we never found the time to do so

bozhidar21:04:39

@malabarba: The problem is that you can’t really check the version this way

bozhidar21:04:01

as the middleware will blow up before you can evaluate any code...

bozhidar21:04:22

frankly I don’t remember what exactly happens on 1.6, but I remember it wasn’t pretty

nkraft21:04:04

I don't code a lot of Racket, but when I have I've used DrRacket. In Emacs, I found quack to be the easiest to set up.

nkraft22:04:11

Quack also works with a lot of other schemes, which can be nice.

nkraft22:04:40

I was hacking a lot in Chicken Scheme for a while, and quack was pretty usable for that.

dpsutton22:04:29

@bozhidar: are you asking what happens when the version is not supported?

dpsutton22:04:36

on 1.6 it is the following

dpsutton22:04:19

I've got it working so that it looks like the following:

richiardiandrea23:04:05

@nkraft: thanks for the suggestion, but I found quack and it did not actually add much, so for now it is disabled, in favor of geiser, but maybe I am missing something...what does it actually provide?