This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-19
Channels
- # adventofcode (1)
- # announcements (3)
- # babashka (60)
- # beginners (60)
- # calva (5)
- # clj-commons (17)
- # clj-kondo (33)
- # clj-on-windows (1)
- # clojure (40)
- # clojure-austin (3)
- # clojure-europe (19)
- # clojure-gamedev (25)
- # clojure-nl (1)
- # clojure-norway (6)
- # clojure-sweden (4)
- # clojure-uk (2)
- # clojurescript (27)
- # conjure (1)
- # core-async (1)
- # core-typed (7)
- # cursive (5)
- # datomic (35)
- # events (1)
- # fulcro (35)
- # integrant (7)
- # introduce-yourself (2)
- # kaocha (5)
- # leiningen (2)
- # lsp (26)
- # malli (13)
- # nbb (99)
- # off-topic (15)
- # pathom (12)
- # pedestal (5)
- # polylith (8)
- # portal (4)
- # rdf (19)
- # reagent (8)
- # reitit (5)
- # releases (2)
- # remote-jobs (2)
- # rewrite-clj (1)
- # shadow-cljs (94)
- # testing (2)
- # timbre (2)
- # tools-deps (16)
Here's an odd question: I'm trying to make io.aviso.pretty smarter about when to emit ANSI escape codes, and when not to. I have a default based on whether (System/console) returns non-nil. This works well for clj
and does the right things in pipes and background jobs (it will be nil, so no ANSI). However, in a REPL launched by Cursive, console is still nil. Is there another cheap test I can make to determine if in a Cursive-launched REPL? Otherwise, I have to lean on setting an environment variable to override the console check.
Had the idea of checking loaded namespaces and saw cursive.repl.runtime
may be a good indicator of running under Cursive.
I've used
(def is-cursive?
(try
(require '[cursive.repl.runtime])
true
(catch Exception _
false)))
successfully before.
Not sure if it's the best solutionUltimnately, I looked for nrepl.core
(see https://github.com/AvisoNovate/pretty/blob/master/src/io/aviso/ansi.clj#L35) as this worked for Cursive and for lein repl
and for clj
. It probably works for Emacs and other editors too, I have to assume that those can handle ANSI color/font codes.