From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: master 400df210ce0: Fix last change of 'delete-file' Date: Fri, 11 Aug 2023 15:10:18 +0300 Message-ID: <834jl5hj9x.fsf@gnu.org> References: <169133064669.24990.11219399079845613336@vcs2.savannah.gnu.org> <20230806140407.09E6BC038BE@vcs2.savannah.gnu.org> <875y5n6nz2.fsf@gmail.com> <83o7jfhvw3.fsf@gnu.org> <871qgb6mg9.fsf@gmail.com> <83h6p7hueg.fsf@gnu.org> <87wmy355aa.fsf@gmail.com> <83cyzvhri7.fsf@gnu.org> <87msyyt4ne.fsf@gmx.de> <83h6p5hmex.fsf@gnu.org> <87350pu7qq.fsf@gmx.de> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30279"; mail-complaints-to="usenet@ciao.gmane.io" Cc: rpluim@gmail.com, emacs-devel@gnu.org, esr@thyrsus.com To: Michael Albinus Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Aug 11 14:10:45 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qUQya-0007fY-Dj for ged-emacs-devel@m.gmane-mx.org; Fri, 11 Aug 2023 14:10:44 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qUQxm-0005OM-29; Fri, 11 Aug 2023 08:09:54 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qUQxk-0005MJ-EP for emacs-devel@gnu.org; Fri, 11 Aug 2023 08:09:52 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qUQxj-0003KO-F9; Fri, 11 Aug 2023 08:09:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=4cIepbQC4AX7u0p1nE/WWDm/s0xaHsZabvOu0KoikbM=; b=EPXuXbTo5gec Iz9GXVI4EJC7/G0ebKmruJKdIIT0wDCaZ2FXb+dcGAcPkgFRr5LVDxXZAN6ZhCJes3ldfw/LdES+z K1XB4niyWCXfkhMMdkJbrCnxKgjmCnTckfBBUajJVvw7N8oePHYzUef9+hiAAE358yZBB12+H5XuW 7mrfLvm8j/F9S4RK6WC+A7kzeesFd0exihZU0CCo17Clef3E08KiTYCE970lZc9xuQnzQg1XHIVz/ T5DanYKkm/aPz1jg41HVx1PgUdvAtGefKfTjVsrcwyyNl+zPExGeK4/cRTWEIrYqz4K9zJezmPbFE uxlAWfOiFHgoZFmRE/uiSg==; In-Reply-To: <87350pu7qq.fsf@gmx.de> (message from Michael Albinus on Fri, 11 Aug 2023 13:41:01 +0200) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:308574 Archived-At: > From: Michael Albinus > Cc: rpluim@gmail.com, emacs-devel@gnu.org, esr@thyrsus.com > Date: Fri, 11 Aug 2023 13:41:01 +0200 > > > Michael, this is my change, not Eric's. My question is above: is > > there a requirement that file handlers are called with absolute file > > names? If so, where is it documented, and why some places, which I > > mentioned above, call file handlers with file names that were not > > passed through expand-file-name? > > Ffind_file_name_handler calls fast_string_match (string, filename). > STRING is the car of an entry in file-name-handler-alist, FILENAME is > the file name to be checked. > > If the entry in file-name-handler-alist is a regexp for the head of an > absolute file name, the check will fail when FILENAME is relative. Shouldn't Ffind_file_name_handler also check the default-directory, if FILENAME is not absolute and failed to match anything in file-name-handler-alist? If it doesn't do that, a file "foo" in a remote directory will fail to match a handler, and that is probably not expected (a.k.a. "bug")? > >> > But the same would be true for substitute-in-file-name, for example, > >> > and for directory-file-name, and file-name-as-directory, and several > >> > other primitives, which call Ffind_file_name_handler without calling > >> > expand-file-name before that. > > substitute-in-file-name, directory-file-name, file-name-as-directory and > likely more primitives do not support relative file names like > "123". They support file names relative to the remote, like > "/ssh::123". Is this a bug? Don't know, nobody has protested so > far. But at least it is undocumented. These primitives should support relative file names, and they do for local files. So either they should call expand-file-name, or find-file-name-handler should check default-directory. > Other primitives handle this themselves if necessary. Fdelete_file and > other function expand the file name. In Fexpand_file_name itself, we have > > --8<---------------cut here---------------start------------->8--- > handler = Ffind_file_name_handler (name, Qexpand_file_name); > ... > handler = Ffind_file_name_handler (default_directory, Qexpand_file_name); > --8<---------------cut here---------------end--------------->8--- Primitives indeed _must_ call expand-file-name. And expand-file-name does that with default-directory because it accepts a directory as its 2nd argument, and that argument defaults to default-directory. I've added back expand-file-name to delete-file. But I find this situation unsatisfactory: Lisp code should only call expand-file-name when it needs to analyze absolute file names for its own purposes, it is not supposed to call expand-file-name when invoking primitives. The addition of expand-file-name to delete-file made that function a bit slower, and for local files that is a net loss. We should extend instead find-file-name-handler to work for non-absolute file names to avoid this overhead. > I wouldn't touch this as it works. Improvements in documentation might > be appreciated. Indeed, the fact that find-file-name-handler needs an absolute file name is never mentioned anywhere in the documentation. It is strange this didn't pop up earlier.