In Elisp, how to get path string with slash properly inserted?
I am manually constructing path strings in Elisp by concatenating partial paths and directory names. Unfortunately sometimes the paths end with slash, sometimes not. Therefore, I need to insert slash before concatenating a directory name when necessary but not otherwise. What's a good way to do this? (file-name-as-directory dir) will return directory path dir with a trailing slash, adding one if necessary, and not otherwise. If you had your sequence of partial paths in a list, you could do something like: (let ((directory-list '("/foo" "bar/" "p/q/" "x/y")) (file-name "some_file.el")) (concat