From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.devel Subject: Re: file-exists-p on empty string Date: Wed, 06 Mar 2019 10:51:02 +0100 Message-ID: <8736o05o1l.fsf@gmx.de> References: <6C8B93F1-4549-4223-AD3D-58A8CF28A97C@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="260935"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Mar 06 10:52:01 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h1TDT-0015iY-JV for ged-emacs-devel@m.gmane.org; Wed, 06 Mar 2019 10:51:59 +0100 Original-Received: from localhost ([127.0.0.1]:58072 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1TDS-0004BD-36 for ged-emacs-devel@m.gmane.org; Wed, 06 Mar 2019 04:51:58 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:46712) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1TCk-0004Ao-Nb for emacs-devel@gnu.org; Wed, 06 Mar 2019 04:51:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1TCj-000057-S3 for emacs-devel@gnu.org; Wed, 06 Mar 2019 04:51:14 -0500 Original-Received: from mout.gmx.net ([212.227.15.19]:49019) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1TCj-0008Vf-FO for emacs-devel@gnu.org; Wed, 06 Mar 2019 04:51:13 -0500 Original-Received: from detlef.gmx.de ([212.86.58.133]) by mail.gmx.com (mrgmx003 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MGjfl-1go0wy0tcX-00DXLo; Wed, 06 Mar 2019 10:51:05 +0100 In-Reply-To: (Stefan Monnier's message of "Wed, 27 Feb 2019 16:18:48 -0500") X-Provags-ID: V03:K1:nFt2CqvjNkSSYNfU8UrxeGJyuHozWCQT9M5ZDiDto7D7+Vc390j 38CSkrPtKQmqPzDIjY2ELQEjyg6a90AizCzq9hfcVvD2jryFWBZMaAt6yJfKxabjgOSi+pp ktxcE8/HxB9Y3i7nmHl07CEGBScB0E5LdWyV89fucjE35Nt3v17/svCxQ1X/6LFzZhdNxtE VuX3ZTW0wgndvG3uJOeTg== X-UI-Out-Filterresults: notjunk:1;V03:K0:ejJxv5RbQws=:7UPlWrwyrOzOMk92g1u38Y nZU9w49fxeEtDl8N0CBW09pfysEF5190aKISwaOWo0uFkOpiCiMcF96+tjeTJRN5ugRI8TXZu aBbPSi5xvods6cFPXskTA1ridB6lWDGPY9EZQ/kAROeuF2/xwRyaJOiy6hMa/r/Mcfup1x63q j7kQ8u7emeprQwDx0uLGZSd0qZg9aF8WWgSnfXQpTPwYYRYjZEt4AWru/h8oOSs5u9967Qz6T GqTaHbAO1xHsxvTtyA5YJThVLR+/4IVloSxfjPtVUOmktglrNa5mko4T3m+nauT4uQlIVwCd1 rCzTGO8tOR6CvkVafFtSmvBBswaOa2sVWK+gIQ5tQPMJKyn9YdTjcrdXrr4VNBq0OpZ1zrdVu IiuxIki62isyqyHzL2QFG+w5Y88kgpPSeTs8Znuhi8gibnmtEQxDBPxBp0Ff+bbZ9q5cLGN5/ Is9FJN7kdmv968EX8aLDe3x7IH3i0SzcmaFwZqcnwyMnbwkIpUaTcYcamSD/SZ+GkQ0XmsoqJ OKs6qVeE+nhaFgNUmeo2gvLz7gKfVlXeRtEF03tas+cw7IXoI/71kKMdkOUrOVhTmTW51kGGi kj/7/2Y8Ok/sloWHmkHG+xLRSxDkdl1TZb5n946y1NEUKjwuvLb7d+JjRH8hQyZdFgWrV7I6g 4keuGefMIOh+ksOw++gJq/B6Onm8+51MlD1opl43iz8s5rKvINFjQRy8gXt8nuUE3m0UKUfJY gCwIKEwgBA5kQSIvvOUfaTTNCDBOz1b1uZObzZonO8LRJClf/7+CpSVTPMDf0VDI65M2mVWh X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.15.19 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:233861 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier writes: >>> So the (not (string-empty-p fn)) test just reflects the tool's semantics >>> and is not an artifact of some suboptimal behavior of file-exists-p. >> I gree, but there is not a line about empty strings in doc-string. >> It is great that this is mentioned in documentation, but anyway >> behaviour was quite unexpected > > The problem is that docstrings describe the behavior of a specific > function, so they usually don't mention the more general aspects that > affect all functions of a given subsystem, such as here the general > treatment of the empty string when used as a file name. > > Otherwise, every file-name-manipulating function would have to repeat > this information in its docstring. What about the appended patch? It does not touch the docstrings, but it explains the situation more verbose in the Lisp manual. > Stefan Best regards, Michael. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment *** /tmp/ediffq2yDYg 2019-03-06 10:49:17.961600214 +0100 --- /home/albinus/src/emacs-26/doc/lispref/files.texi 2019-03-06 10:39:51.804376822 +0100 *************** *** 16,22 **** names. A file name is a string. Most of these functions expand file name arguments using the function @code{expand-file-name}, so that @file{~} is handled correctly, as are relative file names (including ! @file{../}). @xref{File Name Expansion}. In addition, certain @dfn{magic} file names are handled specially. For example, when a remote file name is specified, Emacs accesses the --- 16,22 ---- names. A file name is a string. Most of these functions expand file name arguments using the function @code{expand-file-name}, so that @file{~} is handled correctly, as are relative file names (including ! @file{../} and the empty string). @xref{File Name Expansion}. In addition, certain @dfn{magic} file names are handled specially. For example, when a remote file name is specified, Emacs accesses the *************** *** 2409,2414 **** --- 2409,2425 ---- superroot above the root directory @file{/}. On other filesystems, @file{/../} is interpreted exactly the same as @file{/}. + Expanding @file{.} or the empty string returns the default directory: + + @example + @group + (expand-file-name "." "/usr/spool/") + @result{} "/usr/spool" + (expand-file-name "" "/usr/spool/") + @result{} "/usr/spool" + @end group + @end example + Note that @code{expand-file-name} does @emph{not} expand environment variables; only @code{substitute-in-file-name} does that: --=-=-=--