From: Michael Albinus <michael.albinus@gmx.de>
To: Eli Zaretskii <eliz@gnu.org>
Cc: rpluim@gmail.com, emacs-devel@gnu.org, esr@thyrsus.com
Subject: Re: master 400df210ce0: Fix last change of 'delete-file'
Date: Sat, 12 Aug 2023 11:57:19 +0200 [thread overview]
Message-ID: <878ragshvk.fsf@gmx.de> (raw)
In-Reply-To: <83y1ihfp41.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 11 Aug 2023 20:47:10 +0300")
Eli Zaretskii <eliz@gnu.org> writes:
Hi Eli,
>> > 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.
>>
>> It is not a recent addition, it has been there for ages. In Fdelete_file.
>
> I'm talking about the situation on master now, after delete-file was
> split into two parts. After my change today, delete-file calls
> expand-file-name (because find-file-name-handler needs that), and then
> delete-file-internal calls expand-file-name again (because every
> primitive must).
But this is due to moving delete-file from C core to Lisp. We have the
same situation with other Lisp functions, which support file name
handlers and call a C-level function. For example, make-temp-file /
make-temp-file-internal, make-directory / make-directory-internal,
delete-directory / delete-directory-internal.
>> > 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.
>>
>> find-file-name-handler does not need an absolute file name in
>> general. Several handlers are invoked based on the file name
>> extensions. It are the remote file names which require absolute file
>> names.
>
> A caller of find-file-name-handler cannot (and should not) know which
> parts of the file name the handlers look at.
Yes.
>> If we add expand-file-name for cases it isn't applied yet, Emacs might
>> become slower. And perhaps we introduce new faults by this, because
>> everybody has arranged with the current behavior.
>
> But the situation now is bad already: if I call
> file-name-as-directory, for example, with a relative file name in a
> remote directory, the handler is not invoked. Isn't that a bug?
Perhaps. But in practice, I'm not aware of bug reports about.
However, we cannot call Fexpand_file_name in Ffind_file_name_handler,
because expand-file-name supports also file name handlers. This would be
an infloop. And just binding file-name-handler-alist to nil doesn't
return the proper result, but a result which is similar only:
--8<---------------cut here---------------start------------->8---
(let ((default-directory "/ssh::")
file-name-handler-alist)
(expand-file-name "123"))
=> "/ssh::/123"
--8<---------------cut here---------------end--------------->8---
This might be sufficient, but there are cases where we fail. On MS
Windows, for example, we have
--8<---------------cut here---------------start------------->8---
(let ((default-directory "/ssh::")
file-name-handler-alist)
(expand-file-name "123"))
=> "c:/ssh::/123"
--8<---------------cut here---------------end--------------->8---
Best regards, Michael.
next prev parent reply other threads:[~2023-08-12 9:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <169133064669.24990.11219399079845613336@vcs2.savannah.gnu.org>
[not found] ` <20230806140407.09E6BC038BE@vcs2.savannah.gnu.org>
2023-08-10 13:12 ` master 400df210ce0: Fix last change of 'delete-file' Robert Pluim
2023-08-10 13:25 ` Eli Zaretskii
2023-08-10 13:44 ` Robert Pluim
2023-08-10 13:57 ` Eli Zaretskii
2023-08-10 14:41 ` Robert Pluim
2023-08-10 15:00 ` Eli Zaretskii
2023-08-11 7:33 ` Michael Albinus
2023-08-11 10:59 ` Eli Zaretskii
2023-08-11 11:02 ` Eli Zaretskii
2023-08-11 11:41 ` Michael Albinus
2023-08-11 12:10 ` Eli Zaretskii
2023-08-11 17:24 ` Michael Albinus
2023-08-11 17:47 ` Eli Zaretskii
2023-08-12 9:57 ` Michael Albinus [this message]
2023-08-12 10:36 ` Eli Zaretskii
2023-08-12 11:03 ` Michael Albinus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878ragshvk.fsf@gmx.de \
--to=michael.albinus@gmx.de \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=esr@thyrsus.com \
--cc=rpluim@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).