From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Lennart Borgman (gmail)" Newsgroups: gmane.emacs.devel Subject: Re: abbreviate-file-name on Windows seems incorrect Date: Sat, 06 Jan 2007 12:37:25 +0100 Message-ID: <459F89F5.3080504@gmail.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1168083469 22013 80.91.229.12 (6 Jan 2007 11:37:49 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 6 Jan 2007 11:37:49 +0000 (UTC) Cc: Emacs-Devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jan 06 12:37:48 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1H39rr-0002nR-Ql for ged-emacs-devel@m.gmane.org; Sat, 06 Jan 2007 12:37:44 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H39rr-0001nl-8z for ged-emacs-devel@m.gmane.org; Sat, 06 Jan 2007 06:37:43 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1H39rd-0001lQ-EM for emacs-devel@gnu.org; Sat, 06 Jan 2007 06:37:29 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1H39rb-0001iQ-F5 for emacs-devel@gnu.org; Sat, 06 Jan 2007 06:37:29 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H39rb-0001iF-7W for emacs-devel@gnu.org; Sat, 06 Jan 2007 06:37:27 -0500 Original-Received: from [80.76.149.212] (helo=ch-smtp01.sth.basefarm.net) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1H39ra-0006yy-Fd for emacs-devel@gnu.org; Sat, 06 Jan 2007 06:37:26 -0500 Original-Received: from c83-254-145-24.bredband.comhem.se ([83.254.145.24]:62823 helo=[127.0.0.1]) by ch-smtp01.sth.basefarm.net with esmtp (Exim 4.63) (envelope-from ) id 1H39rY-0001cq-5W; Sat, 06 Jan 2007 12:37:25 +0100 User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) Original-To: Drew Adams In-Reply-To: X-Antivirus: avast! (VPS 0701-1, 2007-01-05), Outbound message X-Antivirus-Status: Clean X-Scan-Result: No virus found in message 1H39rY-0001cq-5W. X-Scan-Signature: ch-smtp01.sth.basefarm.net 1H39rY-0001cq-5W bffad30b376b9694f5b4a5c6b174c4cc X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:64872 Archived-At: Drew Adams wrote: > On MS Windows, my $HOME is "c:\\". That is what is returned by (getenv > "HOME"), and that is what I see in Windows itself, in the list of > environment vars. > > The code for `abbreviate-file-name' defines `abbreviated-home-dir' as > follows, in order to be able to "substitute `~' for the user's home > directory", as the doc string says: > > (or abbreviated-home-dir > (setq abbreviated-home-dir > (let ((abbreviated-home-dir "$foo")) > (concat "^" (abbreviate-file-name > (expand-file-name "~")) > "\\(/\\|\\'\\)")))) > > The comment for this code is as follows, which indicates that a slash is > added to distinguish the home dir from a file in that dir: > > ;; We include a slash at the end, to avoid spurious matches > ;; such as `/usr/foobar' when the home dir is `/usr/foo'. > > However, that is improper for a Windows home directory such as mine (not an > uncommon value). (expand-file-name "~") returns "c:/", which is correct, > but the result for `abbreviated-home-dir' becomes "^c:/\\(/\\|\\'\\)", which > is incorrect and useless, AFAICT. It should be something like > "^c:\\(/\\|\\'\\)", I would think. > > I would expect (abbreviate-file-name "c:/foo/bar") to return "~/foo/bar", > but it returns "c:/foo/bar". If `abbreviated-home-dir' were > "^c:\\(/\\|\\'\\)", then the result would be correct: "~/foo/bar". If leave abbreviated-home-dir as "^c:/\\(/\\|\\'\\)" and you instead just comment out this part in abbreviate-file-name, does it works as you expect then? : ;; MS-DOS root directories can come with a drive letter; ;; Novell Netware allows drive letters beyond `Z:'. (not (and (or (eq system-type 'ms-dos) (eq system-type 'cygwin) (eq system-type 'windows-nt)) (save-match-data (string-match "^[a-zA-`]:/$" filename)))))