help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Lisp code to expand /~ and // but not env vars?


From: Drew Adams
Subject: Lisp code to expand /~ and // but not env vars?
Date: Sun, 2 Oct 2005 15:51:00 -0700

I'm looking for Lisp code that will expand /~ and // in a file name, just as
`substitute-in-file-name' does, but without substituting environment
variables.  I want to rationalize a user-input file name, which might
contain /~ and //, but I only want to expand env vars (recursively) in a
separate, later step (e.g. with `substitute-in-file-name').

Can anyone suggest a way to do this /~ and // conversion in Lisp?

Context: On Windows, `substitute-in-file-name' also changes \ to /, and
that's fine, inside env vars, but I don't want this to be done at the top
user-input level. Instead, I want to treat the user input as a regexp (with
normal regexp interpretation of backslash), and only afterward use
`substitute-in-file-name' to recursively expand the env vars. IOW, I don't
want to change \ to / at the top level; I just want to expand /~ and // at
the top level (and not \~ and \\, even on Windows).

It looks like the only existing code to do the /~ and // conversion is C
code (C function `search_embedded_absfilename') that is embedded as part of
the definition of `substitute-in-file-name'. I'm looking for a way to do
(only) that in Lisp.  Thanks.







reply via email to

[Prev in Thread] Current Thread [Next in Thread]