I have a function which returns a file path, but the returned value has backslash excaped 'special' characters e.g.
"/home/fred/Documents/This\ file\ \(20200120\).txt"
but the function where I want to use this value does not handle the string escaping and just wants the plain filename string i.e.
"/home/fred/Documents/This file (20200120).txt"
What would be the canonical way to do this in elisp?
My quick and dirty solution (which seems to work) is a simple function
(defun tx-parse-path (p) (concat (reduce #'(lambda (acc l) (if (not (= ?\\ l)) (cons l acc) acc)) (reverse p) :initial-value '()))) I suspect there is some built-in function, but have not found it. I don't need to worry about win32 compatibility (only use GNU Linux and macOS) and of course, the flaw with the brute force solution above is that it will strip legitimate '\' from a filename.
shell-quote-argumentmight do more than just add backslashes, depending on the input.