@bozhidar In your "Dark Cider" talk you showcase the "CIDER can show images in the REPL" feature (around 51:17 in the recording). You start with the "~/kitty.png" path but you edit it to "/home/bozhidar/clojure.png" because you mention a minute later that there is a bug somewhere in CIDER that makes that feature only work with absoluted paths. But not with relative paths.
Well, I´ve looked into it, and the problem is not absolute vs relative paths. Relative paths work ok, as long as they are relative to the user.dir
directory. Because that is the behaviour of <http://clojure.java.io/file|clojure.java.io/file>
(and the underlying http://java.io.File class). The problematic paths are those that contain shell expansion characters, like ~
, $
etc. Precisely because they are expanded by the shell!
But when using <http://clojure.java.io/file|clojure.java.io/file>
to get a http://java.io.File object, no shell is involved. So no expansion occurs. And the file referenced by that path doesn't exist. So this check in the nREPL middleware fails: https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/content_type.clj#L92
So more than a bug, I'd say this is a limitation of the underlying Java platform. Unless the middleware takes care of doing the shell expansion work there is no way this can work. By the way, I don't think it should, as this can get out of hand very quickly, given the amount of different shell expansions existing out there.
@iarenaza Good catch! I keep forgetting about this, because I also do a lot of Ruby and there it's trivial to do the shell globbing.
I guess we can at least add a note to the docs, so someone won't be surprised by this behavior, as I agree it's probably going to be too much to try to do proper globbing in the middleware.