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.bugs Subject: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly Date: Sat, 09 Nov 2024 13:11:24 +0200 Message-ID: <86bjyomzkz.fsf@gnu.org> References: <20241105.073924.1479117425130782406.enometh@meer.net> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22636"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 74208@debbugs.gnu.org To: Madhu , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 09 12:12:21 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1t9jO8-0005h4-TE for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 09 Nov 2024 12:12:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9jNs-0001Fk-SH; Sat, 09 Nov 2024 06:12:04 -0500 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 1t9jNr-0001Fc-1J for bug-gnu-emacs@gnu.org; Sat, 09 Nov 2024 06:12:03 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t9jNq-00068E-PH for bug-gnu-emacs@gnu.org; Sat, 09 Nov 2024 06:12:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=LYQMXi9lF+pc7sckQpqRx9zMyw/dpRnIJfvLCN0vl6M=; b=fBRiuAuUhj5e77p86g1itM/ZNucM5daf8qf9xJogD4AyAePZ9e1fE+Q2mM7UjJ/IH/oyYKLsFBu4/PyCKqRZMne7xd52KMMTWIlWU+RNOd2glmfuyoY2yHNzqjvIqpUDzKZvF47UgfFhaRCqwaYLIQ/GbPGdfWVCMLp05qcjVy+ux9gNn39QmU8gRuGm4zC2VZXp3SeemhxAms5k7UN8EDsl/u+vKfuhJRWEiLwekn2fAJF0ekdR9yxSz7xn7RziY1BGA9MkrX0RdF9pVKtZI8CDQFTDCZu237Yv8twB+OOfH/dBhp2AjUu26MgZxdFy95Uj3wuG2IHBGHPL6AiVhA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t9jNq-0006jU-Ia for bug-gnu-emacs@gnu.org; Sat, 09 Nov 2024 06:12:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 09 Nov 2024 11:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74208 X-GNU-PR-Package: emacs Original-Received: via spool by 74208-submit@debbugs.gnu.org id=B74208.173115069525842 (code B ref 74208); Sat, 09 Nov 2024 11:12:02 +0000 Original-Received: (at 74208) by debbugs.gnu.org; 9 Nov 2024 11:11:35 +0000 Original-Received: from localhost ([127.0.0.1]:53661 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t9jNO-0006ik-Lm for submit@debbugs.gnu.org; Sat, 09 Nov 2024 06:11:34 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33304) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t9jNM-0006iX-SR for 74208@debbugs.gnu.org; Sat, 09 Nov 2024 06:11:33 -0500 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 1t9jNH-00066o-6d; Sat, 09 Nov 2024 06:11:27 -0500 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=LYQMXi9lF+pc7sckQpqRx9zMyw/dpRnIJfvLCN0vl6M=; b=dOK03NNueh17 bgqw2xSiH65WyRdnoqFEISdaoKJ85oSgrvafDxJ4Uhz+QkM0ZiGQSTgPt16wuYy0DaP/rtepG16QT nXvkTNoI4iuFXIGsIPYASLBmpqMNACEF1iJNn5ObMBRmMLjEBFY6BusdhJ6+/KduVfGxSGfbf/nhv Qp6YSzKVT32kQ1JKZoPAUB5fW1RgYOhJqnsFtmtpHWD+ztTI6ppGPdo6lQrcemE8aBligTEwxsf3l wmk+t7hBuZMD3etQWLHGURPiVQN11MYK21kNA18uiavyrAK13VYfvY0Vd0+GQzSYoW+f7D479lDOu 003gN946/tV8GaV33qKlIA==; In-Reply-To: <20241105.073924.1479117425130782406.enometh@meer.net> (message from Madhu on Tue, 05 Nov 2024 07:39:24 +0530 (IST)) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:295127 Archived-At: > Date: Tue, 05 Nov 2024 07:39:24 +0530 (IST) > From: Madhu > > minibuffer.el: (read-file-name-default) has the following code: > ``` > (minibuffer-with-setup-hook > (lambda () > (setq default-directory dir) > ... > (set-syntax-table minibuffer-local-filename-syntax)) > ``` > > This mutates the global binding of default-directory which is incorrect. > > To demonstrate the problem, in emacs -Q > > (insert "http://example.com") > (setq enable-recursive-minibuffers t) > > position point at in the middle of the string http://example.com > M-: (ffap) > > ;; while waiting for input > M-: default-directory > ;; => default-directory is bound to "http://example.com" > M-: (shell-command "echo foo") > ; ;=> > ;; Debugger entered--Lisp error: (file-missing "Setting current directory" "No such file or directory" "http://example.com/") > > I think this can be addressed by binding default-directory before > modifying it. > > ``` > diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el > --- a/lisp/minibuffer.el > +++ b/lisp/minibuffer.el > @@ -3671,6 +3671,7 @@ read-file-name-default > (expand-file-name dir)))) > (minibuffer-with-setup-hook > (lambda () > + (let ((default-directory default-directory)) > (setq default-directory dir) > ;; When the first default in `minibuffer-default' > ;; duplicates initial input `insdef', > @@ -3689,7 +3690,7 @@ read-file-name-default > (with-current-buffer > (window-buffer (minibuffer-selected-window)) > (read-file-name--defaults dir initial)))) > - (set-syntax-table minibuffer-local-filename-syntax)) > + (set-syntax-table minibuffer-local-filename-syntax))) > (completing-read prompt 'read-file-name-internal > pred require-match insdef > 'file-name-history default-filename))) > ``` > > [I'm sending this before I forget so it can be reviewed, but I can > send this patch as as attachment if needed, and it'll take some more > time until I figure out how to write a test for it and test it.] Stefan, any comments?