GNU bug report logs - #78306
[PATCH] Skip the non-exists path when loading a file on Windows

Previous Next

Package: emacs;

Reported by: Lin Sun <sunlin7 <at> hotmail.com>

Date: Thu, 8 May 2025 00:25:02 UTC

Severity: normal

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Full log


View this message in rfc822 format

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Lin Sun <sunlin7 <at> hotmail.com>, 78306 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: bug#78306: [PATCH] Skip the non-exists path when loading a file on Windows
Date: Thu, 08 May 2025 09:38:15 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

Hi,

> If you want to skip directories that don't exist, or exist as files
> that are non-directories, IMO the right way is to modify the loop in
> openp such that in the following snippet:
>
>   FOR_EACH_TAIL_SAFE (path)
>    {
>     ptrdiff_t baselen, prefixlen;
>
>     if (EQ (path, just_use_str))
>       filename = str;
>     else
>       filename = Fexpand_file_name (str, XCAR (path));
>     if (!complete_filename_p (filename))
>       /* If there are non-absolute elts in PATH (eg ".").  */
>       /* Of course, this could conceivably lose if luser sets
> 	 default-directory to be something non-absolute...  */
>       {
> 	filename = Fexpand_file_name (filename, BVAR (current_buffer, directory));
> 	if (!complete_filename_p (filename))
> 	  /* Give up on this path element!  */
> 	  continue;
>       }
>
> we verify that 'XCAR (path)' (and possibly also the current buffer's
> default-directory') is an accessible directory, e.g. by using
> file-accessible-directory-p.  This might benefit Posix platforms as
> well, but we should benchmark the results before we decide.  (We
> should also consider how likely it is that load-path will include
> non-directories or directories that don't exist.)
>
> Btw, did you benchmark the result of your proposed patch, and if so,
> what is the speedup from this change?

I don't know whether the snippet above is also relevant for remote
files. If yes, adding a call of file-accessible-directory-p might
influence performance.

Best regards, Michael.




This bug report was last modified 21 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.