From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: Lisp code to expand /~ and // but not env vars? Date: Mon, 3 Oct 2005 14:07:27 -0700 Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1128373855 1633 80.91.229.2 (3 Oct 2005 21:10:55 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 3 Oct 2005 21:10:55 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Oct 03 23:10:47 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EMXa3-0007y4-0Y for geh-help-gnu-emacs@m.gmane.org; Mon, 03 Oct 2005 23:10:40 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EMXa2-0000v6-1f for geh-help-gnu-emacs@m.gmane.org; Mon, 03 Oct 2005 17:10:38 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EMXZS-0000i7-Ha for help-gnu-emacs@gnu.org; Mon, 03 Oct 2005 17:10:02 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EMXZL-0000df-EV for help-gnu-emacs@gnu.org; Mon, 03 Oct 2005 17:09:58 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EMXZK-0000cZ-S5 for help-gnu-emacs@gnu.org; Mon, 03 Oct 2005 17:09:54 -0400 Original-Received: from [148.87.122.31] (helo=rgminet02.oracle.com) by monty-python.gnu.org with esmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1EMXXY-0005g7-LW for help-gnu-emacs@gnu.org; Mon, 03 Oct 2005 17:08:05 -0400 Original-Received: from rgmsgw300.us.oracle.com (rgmsgw300.us.oracle.com [138.1.186.49]) by rgminet02.oracle.com (Switch-3.1.6/Switch-3.1.7) with ESMTP id j93L7igx008880 for ; Mon, 3 Oct 2005 15:07:44 -0600 Original-Received: from rgmsgw300.us.oracle.com (localhost [127.0.0.1]) by rgmsgw300.us.oracle.com (Switch-3.1.7/Switch-3.1.7) with ESMTP id j93L7htX016757 for ; Mon, 3 Oct 2005 15:07:43 -0600 Original-Received: from dradamslap (dhcp-amer-csvpn-gw2-141-144-72-25.vpn.oracle.com [141.144.72.25]) by rgmsgw300.us.oracle.com (Switch-3.1.7/Switch-3.1.7) with SMTP id j93L7gPk016728 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Mon, 3 Oct 2005 15:07:43 -0600 Original-To: "Help-Gnu-Emacs" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) In-Reply-To: Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:29891 Archived-At: 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.