GNU bug report logs - #74208
31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly

Previous Next

Package: emacs;

Reported by: Madhu <enometh <at> meer.net>

Date: Tue, 5 Nov 2024 02:10:01 UTC

Severity: normal

Found in version 31.0.50

Fixed in version 31.1

Done: Michael Albinus <michael.albinus <at> gmx.de>

Bug is archived. No further changes may be made.

Full log


Message #68 received at 74208 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Madhu <enometh <at> meer.net>
Cc: 74208 <at> debbugs.gnu.org
Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates
 global value of default-directory incorrectly
Date: Sun, 08 Dec 2024 09:46:30 +0100
Madhu <enometh <at> meer.net> writes:

Hi,

> ```
> "unhandled-file-name-directory"
>
> Return a directly usable directory name somehow associated with \
> FILENAME.
> A `directly usable' directory name is one that may be used without the
> intervention of any file name handler.
> If FILENAME is a directly usable file itself, return
> \(file-name-as-directory FILENAME).
> If FILENAME refers to a file which is not accessible from a local process,
> then this should return nil.
> The `call-process' and `start-process' functions use this function to
> get a current directory to run processes in.
> ```
>
> (let ((default-directory "https://www.gnu.org/"))
>   (unhandled-file-name-directory default-directory))
> => "https://www.gnu.org/"

unhandled-file-name-directory expects, that special constructs in
FILENAME are handled via a file name handler. Per default,
"https://www.gnu.org/" is not covered by a file name handler, so I
believe it is a non-valid value for default-directory.

See

--8<---------------cut here---------------start------------->8---
(progn
  (url-handler-mode)
  (let ((default-directory "https://www.gnu.org/"))
    (unhandled-file-name-directory default-directory)))
=> nil
--8<---------------cut here---------------end--------------->8---

Whether nil is a proper value to be returned is questionable. However,
call-process and friends are able to handle a nil default-directory.

> I still haven't gotten around to trying url completions (I use the
> implementation in emacs-w3m w3m-urls-completion) but assuming it is
> going to useful, perhaps the completion mechanism should work off a
> new url-default-directory rather than default-directory if needed.

We don't need a new url-default-directory. We must ensure that
url-handler-mode is activated (temporarily) for such use cases.

Best regards, Michael.




This bug report was last modified 159 days ago.

Previous Next


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