Fork me on GitHub
#emacs
<
2021-03-31
>
dpsutton15:03:07

my emacs fu is drawing a blank. is there a proper way to combine parts of a path into a single path? ie (f "project" ".shadow-cljs" "socket-repl.port") will return the path to project/.shadow-cljs/socket-repl.port using proper separator, etc?

nivekuil15:03:31

(string-join '("a" "b" "c") "/")

dpsutton15:03:53

yeah that works on unix-y type things

Phil Shapiro15:03:09

If you’re wondering how emacs knows what the path separator character is, I think it hardcodes it to /. I haven’t run emacs on windows in a while but I seem to recall there’s cygwin APIs to munge paths back & forth.

dpsutton15:03:26

i think the proper way is (concat (file-name-as-directory ...))

3
nivekuil15:03:55

oh, misread your q. I've used f.el before, it has f-join

Eamonn Sullivan15:03:26

I use expand-file-name a lot: (add-to-list 'load-path (expand-file-name "lisp" user-emacs-directory)) Something like that, maybe?

dpsutton15:03:33

yeah that's what i ended up using at the top level

dpsutton15:03:39

(expand-file-name "socket-repl.port" (file-name-as-directory (concat (file-name-as-directory proj-dir) ".shadow-cljs")))

dpsutton15:03:55

but it requries a well formed directory at the end and only one.

dpsutton15:03:04

but it took me a bit to get there. thanks everyone