From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: RE: file-truename, convert-standard-filename Date: Sat, 6 Feb 2010 12:46:02 -0800 Message-ID: <07544B532C8E490F96FE0B1CF403C510@us.oracle.com> References: <83k4urfqs9.fsf@gnu.org> <0B5BFE3DC87648888328B75164292F06@us.oracle.com> <83bpg2g2l8.fsf@gnu.org> <834oluf9c8.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1265489237 6918 80.91.229.12 (6 Feb 2010 20:47:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 6 Feb 2010 20:47:17 +0000 (UTC) Cc: emacs-devel@gnu.org To: "'Eli Zaretskii'" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Feb 06 21:47:14 2010 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.69) (envelope-from ) id 1NdrYf-0004ZW-PU for ged-emacs-devel@m.gmane.org; Sat, 06 Feb 2010 21:47:14 +0100 Original-Received: from localhost ([127.0.0.1]:36332 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NdrYe-0006k9-Sx for ged-emacs-devel@m.gmane.org; Sat, 06 Feb 2010 15:47:12 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NdrYa-0006iW-1R for emacs-devel@gnu.org; Sat, 06 Feb 2010 15:47:08 -0500 Original-Received: from [199.232.76.173] (port=36201 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NdrYZ-0006iI-N7 for emacs-devel@gnu.org; Sat, 06 Feb 2010 15:47:07 -0500 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NdrYX-0002lw-Li for emacs-devel@gnu.org; Sat, 06 Feb 2010 15:47:07 -0500 Original-Received: from acsinet11.oracle.com ([141.146.126.233]:35068) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NdrYX-0002lA-5s; Sat, 06 Feb 2010 15:47:05 -0500 Original-Received: from acsinet15.oracle.com (acsinet15.oracle.com [141.146.126.227]) by acsinet11.oracle.com (Switch-3.4.2/Switch-3.4.2) with ESMTP id o16Kl00E031478 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 6 Feb 2010 20:47:01 GMT Original-Received: from acsmt354.oracle.com (acsmt354.oracle.com [141.146.40.154]) by acsinet15.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id o16KShWo005414; Sat, 6 Feb 2010 20:46:58 GMT Original-Received: from abhmt004.oracle.com by acsmt353.oracle.com with ESMTP id 15766251265489159; Sat, 06 Feb 2010 12:45:59 -0800 Original-Received: from dradamslap1 (/10.175.198.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 06 Feb 2010 12:45:59 -0800 X-Mailer: Microsoft Office Outlook 11 In-reply-to: <834oluf9c8.fsf@gnu.org> Thread-Index: AcqnY0JVtxhGqGYgSGSWrIgfAu3jeQABiNCA X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-Source-IP: acsmt354.oracle.com [141.146.40.154] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090201.4B6DD543.01CA:SCFMA4539814,ss=1,fgs=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) 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:120994 Archived-At: > Let me try to step back a notch and try anew. Thank you. > There's a problem with file names, such as ".emacs", defined in Emacs > Lisp code as literal strings: some filesystems don't allow such > names. `convert-standard-filename' was introduced to take a Posix > file name and produce from it a file name that can be used instead on > the particular filesystem. So instead of > (defvar foo-file > (if (eq system-type 'foo) > "this" > (if (eq system-type 'bar) > "that" > .... > we can now have just this: > (defvar foo-file (convert-standard-filename "this")) > > So far so good? Yes. > Same considerations apply when a file name is constructed from > fragments, like in (append ".emacs." (user-full-name) ".log") OK. (But I think you meant `concat', not `append'.) So it in fact has nothing specially to do with literal strings in source code. That was apparently a red herring. (But you keep repeating it - e.g. see above; so I wonder.) This is the general rule, apparently: > In order to get a file name that any supported platform could use, you > need to run the result of this through `convert-standard-filename'. > Okay? I think so. That means that in order to use ANY file name (any file-name string, no matter where it was coded or how it is produced), you need to apply c-s-f to it, if you don't know whether the name is supported by all platforms that might be used by your code. Am I wrong about that? That would mean that the original code I showed would be necessary, and that using f-t alone, without c-s-f, would not be sufficient. This is the original code: (string= (c-s-f (f-t FILE1)) (c-s-f (f-t FILE2))) So am I misunderstanding now, or was your advice wrong that just f-t suffices here? I'm not trying to point fingers - I appreciate your patient efforts to explain; I'm just trying to understand. > If this part is understood, then just use `convert-standard-filename' > in any situation where a string to be used as a file name might not be > valid on the underlying filesystem, Which for an unknown string (e.g. the string value of a variable) means ALL situations, no? If I don't know which file system a user has, and I don't know which file names are involved, then my code needs to call c-s-f for each file name. No? > like e.g. a literal `?' on a > Windows disk. An arbitrary string generally needs such a treatment, > before it can safely be used as a file name. That's why Emacs > defcustoms use it. > > Any questions so far? I think I understand now - see above. c-s-f is needed for an arbitrary string. Confirmation or correction is welcome. BTW, I notice that prior to Emacs 23 the Emacs source code did not use c-s-f very much (e.g. defcustoms, such as in recentf.el); Emacs 23 uses it much more. I suppose this means that we had more problems with this before Emacs 23. But it does not seem like even the Emacs 23 source code calls c-s-f for all of the situations that I think you're describing. You seem to be saying that it's _nearly always needed_, unless (a) you know which file system is being used, (b) you know the file name being used, and (c) you know that that particular file name is a valid one for that particular file system. I haven't analyzed the Emacs code, but I don't get the impression that (a), (b), and (c) are true for each file-name occurrence where it doesn't call c-s-f. Maybe adding c-s-f everywhere is an ongoing thing, and the code just hasn't yet caught up with the rule? Thx - Drew