This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-12
Channels
- # aleph (61)
- # announcements (2)
- # babashka (65)
- # beginners (64)
- # calva (2)
- # clerk (1)
- # cljsrn (1)
- # clojure (60)
- # clojure-austin (7)
- # clojure-europe (13)
- # clojure-italy (2)
- # clojure-losangeles (4)
- # clojure-nl (2)
- # clojure-norway (94)
- # clojure-romania (2)
- # clojure-uk (7)
- # clojuredesign-podcast (5)
- # clojurescript (3)
- # core-typed (2)
- # datomic (42)
- # docker (24)
- # emacs (10)
- # exercism (50)
- # graphql (83)
- # honeysql (25)
- # hyperfiddle (12)
- # malli (13)
- # membrane (49)
- # off-topic (50)
- # podcasts-discuss (1)
- # re-frame (3)
- # reagent (12)
- # reitit (5)
- # releases (2)
- # remote-jobs (8)
My Windows machine is broken, so I can't test, but can someone please verify what this returns on a Windows machine in Clojure?
(System/getenv "HOME")
(System/getenv "USERPROFILE")
(System/getenv "userprofile")
PS C:\Users\mmer> clj
Clojure 1.11.1
user=> (System/getenv "HOME")
nil
user=> (System/getenv "USERPROFILE")
"C:\\Users\\mmer"
user=> (System/getenv "userprofile")
"C:\\Users\\mmer"
user=>
the clj PowerScript script checks for HOME
in Windows first, but AFAIK this is not a Windows convention at all. Do you know the reason for this, @U064X3EF3?
Thanks @U4C3ZU6KX
Not a windows convention but its a common user convention to set it, tools like Emacs require it iirc
anyone tried using babashka and/or sci to make a https://docs.racket-lang.org/pollen/ markup preprocessor for markup formats like markdown? I had this sudden urge to do something like
# my doc
◊(defn link [s] (str "[" link "](." link ")"))
- ◊(link "")
- ◊(link "")
then
$ cat doc | bb pollenish.clj | pandoc --from markdown --to html
. Markdown feels like toil sometimes.a quick google search turned up https://github.com/JeremS/prose! It seems to mention sci. But from what I can tell, JeremS/prose is not an attempt to create a fast-starting bb script that one can use to preprocess.
@U04V15CAJ you got it first 😄
from the readme it appears to already support sci. So perhaps an argument for supporting sci from Babashka scripts (which I believe has been discussed before).
> don’t know if the code is bb-compatible but perhaps can be made so
Using the eval
evaluation strategy could potentially work from bb! I’ve gotta try this.
Not quite pollen syntax, but my https://github.com/fabricate-site/fabricate also features the ability to embed arbitrary Clojure expressions. It uses a somewhat different evaluation model than prose. Not (yet) bb-compatible though!
I definitely need to put more work into thinking about an extensible markdown-like syntax that: • Allows embedding Clojure expressions • Can be formally specified using EBNF I think there's potential for something that can be specified using a tree-sitter grammar, which would allow for support across tools (fabricate's notation currently relies heavily on an emacs package to work well in an editor)
Right -- providing a good editor experience is a challenge here because we're no longer editing pure markdown, or pure clojure.
Over in the github repo for #CLDK6MFMK, https://github.com/metosin/malli/pull/966#discussion_r1356842655 to add uri?
support to malli.transform
. They tried to use java.net.URISyntaxException
, which failed in the Babashka tests. Are such exceptions something you're interested in supporting? Or should they just stick with Exception
?
I'll add it to bb, but perhaps they can work around it using this for now:
#?(:clj
(defmacro if-exists [x y]
(if (resolve x)
x y)))
and then (throw new #?(:clj (if-exists java.net.URISyntaxException java.lang.Exception) ...) :cljs ...)
they were trying to catch it, which makes that harder
once the exception type becomes available in bb it will automatically use the more specific type
hot damn, thank you!
and make a note that from 1.3.186 on the other type will work, and in a year time we can probably shift to that one
or we can just shift to the new type once 136 comes out, people can still use the old malli version
👋 I tried this:
#?(:clj
(defmacro if-exists [x y]
(if (resolve x)
x y))
(defn -string->uri [x]
(if (string? x)
(try
(URI. x)
(catch (if-exists URISyntaxException Exception) _
x))
x)))
I'm getting a syntax error compiling the try, saying: Unable to resolve classname: (if-exists URISyntaxException Exception)
So maybe sticking with a plain Exception for now, and then revisit once 136 comes out?
i think that's smart
@U03N9E40Q2F yeah, let's do that.
I'll put a comment that it can be tightened up.
I’m missing something simple: (fs/list-dir "/tmp/" "**")
or (fs/list-dir "/tmp/" "*")
I’m trying to get the full recursive list
(fs/list-dir "/tmp/" "**/*"
is also a no-go
the docstring made me think to use the “glob” style argument to fs/list-dir rather than the accept function style
babashka.fs/list-dir
([dir] [dir glob-or-accept])
Returns all paths in dir as vector. For descending into subdirectories use `glob.`
- `glob-or-accept` - a glob string such as "*.edn" or a (fn accept [^java.nio.file.Path p]) -> truthy
but fs/glob
returns an empty vector for me, for anything other that "."
e.g. (fs/glob "/tmp" "*")
-> []
(fs/glob "/tmp" "**")
-> []
@U0250GGJGAE You're hitting exactly a bug which has been fixed yesterday, namely when you query a root directory
oh lol
another isue may be that /tmp
is a symlink and fs/glob
doesn't follow symlinks (yet)
(fs/glob (fs/canonicalize "/tmp") "**")
this now works for me with the version on masterGotcha - yeah the canonicalize makes it work for me too. Thank you sir 👍
Was trying it as an example
I see now, that regular glob does work for non top-level
actually I need canonicalize for my use-case anyhow, so thanks for pointing that one out
Well I don’t need it. I just have some things mapped with soft-links and I prefer to refer to them that way.
(which then works fine if I canonicalize the target directory, which is a soft-link to somewhere else)