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

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

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


From: Drew Adams
Subject: RE: Lisp code to expand /~ and // but not env vars?
Date: Mon, 3 Oct 2005 14:07:27 -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').

Thanks to all who replied. My requirements statement wasn't very good, and I
actually figured out a different way to solve my problem.

FWIW, I meant // or /~ anywhere in an Emacs input file-name, not as the only
input. These are treated specially by substitute-in-file-name, to remove
everything up to and including these, and putting the rest into the root
directory or a home directory, respectively.

Anyway, it turned out that I need to do the regexp matching after this kind
of substitution, but also I want backslash to work for regexps, and not be
interpreted as a directory separator (on Windows). Since I need to
regexp-match after substitute-in-file-name substitution, the solution I
chose was just to fool substitute-in-file-name by replacing any backslashes
with another character (C-g), and then putting them back after
substitute-in-file-name is done.





reply via email to

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