From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 04 21:09:35 2024 Received: (at submit) by debbugs.gnu.org; 5 Nov 2024 02:09:35 +0000 Received: from localhost ([127.0.0.1]:43004 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t890h-0002GK-9T for submit@debbugs.gnu.org; Mon, 04 Nov 2024 21:09:35 -0500 Received: from lists.gnu.org ([209.51.188.17]:33646) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t890f-0002GC-Lb for submit@debbugs.gnu.org; Mon, 04 Nov 2024 21:09:34 -0500 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 1t890f-0000Id-Fe for bug-gnu-emacs@gnu.org; Mon, 04 Nov 2024 21:09:33 -0500 Received: from smtp0.ctinetworks.com ([205.166.61.207]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t890d-0000Fu-JF for bug-gnu-emacs@gnu.org; Mon, 04 Nov 2024 21:09:33 -0500 X-ctinetworks-Watermark: 1731636565.02982@taQz5AdbyGXdI6nORWgj5A X-ctinetworks-Envelope-From: enometh@meer.net X-ctinetworks-SpamCheck: X-ctinetworks-VirusCheck: Found to be clean X-ctinetworks-Message-ID: 4E5755F57.AAE35 Received: from localhost (unknown [117.254.36.161]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: enometh@meer.net) by smtp0.ctinetworks.com (Postfix) with ESMTPSA id 4E5755F57 for ; Mon, 4 Nov 2024 21:09:24 -0500 (EST) Date: Tue, 05 Nov 2024 07:39:24 +0530 (IST) Message-Id: <20241105.073924.1479117425130782406.enometh@meer.net> To: bug-gnu-emacs@gnu.org Subject: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly From: Madhu X-Mailer: Mew version 6.9 on Emacs 31.0.50 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=205.166.61.207; envelope-from=enometh@meer.net; helo=smtp0.ctinetworks.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) 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.] From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 09 06:11:35 2024 Received: (at 74208) by debbugs.gnu.org; 9 Nov 2024 11:11:35 +0000 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 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 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==; Date: Sat, 09 Nov 2024 13:11:24 +0200 Message-Id: <86bjyomzkz.fsf@gnu.org> From: Eli Zaretskii To: Madhu , Stefan Monnier In-Reply-To: <20241105.073924.1479117425130782406.enometh@meer.net> (message from Madhu on Tue, 05 Nov 2024 07:39:24 +0530 (IST)) Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly References: <20241105.073924.1479117425130782406.enometh@meer.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74208 Cc: 74208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > 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? From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 09 11:11:30 2024 Received: (at 74208) by debbugs.gnu.org; 9 Nov 2024 16:11:30 +0000 Received: from localhost ([127.0.0.1]:54144 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t9o3e-00030Y-8m for submit@debbugs.gnu.org; Sat, 09 Nov 2024 11:11:30 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:23861) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t9o3b-00030J-UU for 74208@debbugs.gnu.org; Sat, 09 Nov 2024 11:11:28 -0500 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 9A62D440BEA; Sat, 9 Nov 2024 11:11:21 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1731168680; bh=FVDpGRg3vqPuhKPgQLLHiDChuB6bNX9NgBbQ7WUV9t8=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Z57kDhe2lJKCOKbuThm7kqC1T0aeufSHHGuHDCks1G23rO3y10n7xkC0Aapz+tfG8 4j8hqu1bsnuajhr8xrk8u033YMgfmvC963neXiA4pyM6nwxPWDf6dNPWuFhCr0qkEd JxYkmKgbBhPq4I33Z1Lcd/RoBpy07fCTokehabHJAiNIIXt+cQjwhgyb9hd+fCGVK1 lrQAl5iwB7F6YF4ROWzH1TgnR2WcEgtgdVRrZpl6KrpymvZcO0Sr/mq8T5/xdA/GBD wQRx+sdaPsHZ0P4N6p7rAsEWbn7W8i3L+dBEi9bFxEguvqZRGeTGSPI6E7ggCe0PEO W6bVFPwMU4ZKg== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 6F21C440B86; Sat, 9 Nov 2024 11:11:20 -0500 (EST) Received: from pastel (104-195-225-43.cpe.teksavvy.com [104.195.225.43]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 45317120403; Sat, 9 Nov 2024 11:11:20 -0500 (EST) From: Stefan Monnier To: Madhu Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly In-Reply-To: <20241105.073924.1479117425130782406.enometh@meer.net> (Madhu's message of "Tue, 05 Nov 2024 07:39:24 +0530 (IST)") Message-ID: References: <20241105.073924.1479117425130782406.enometh@meer.net> Date: Sat, 09 Nov 2024 11:11:19 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.042 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74208 Cc: 74208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > 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. IIRC the `setq` is really there to set the value of `default-directory` during the whole duration of the completion, not just during the setup hook. This is needed/used if the user modifies the minibuffer's content to hold only a relative file name, at which point we need that default directory info in order to perform completions. > ``` > 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))) > ``` The let+setq could be simplified to (let ((default-directory dir)) but none of the code within this `let` uses `default-directory` since there are only calls to `car/cdr`, `setq`, and `set-syntax-table`, none of which touch file names, so we may as well remove the (setq default-directory dir) instead. I'm leaning towards declaring the `shell-command` behavior above as a feature rather than a bug. Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 09 19:57:32 2024 Received: (at 74208) by debbugs.gnu.org; 10 Nov 2024 00:57:32 +0000 Received: from localhost ([127.0.0.1]:54942 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t9wGh-000183-Ra for submit@debbugs.gnu.org; Sat, 09 Nov 2024 19:57:32 -0500 Received: from smtp0.ctinetworks.com ([205.166.61.207]:55348) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t9wGe-00017t-1H for 74208@debbugs.gnu.org; Sat, 09 Nov 2024 19:57:29 -0500 X-ctinetworks-Watermark: 1732064244.55231@k/Da2ALokb7LuRAA9jic9A X-ctinetworks-Envelope-From: enometh@meer.net X-ctinetworks-SpamCheck: X-ctinetworks-VirusCheck: Found to be clean X-ctinetworks-Message-ID: CB77D601C.A3D10 Received: from localhost (unknown [117.254.36.91]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: enometh@meer.net) by smtp0.ctinetworks.com (Postfix) with ESMTPSA id CB77D601C; Sat, 9 Nov 2024 19:57:22 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp0.ctinetworks.com CB77D601C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meer.net; s=ctidkims1; t=1731200243; bh=YfHO5JBoKBbV8wsMKQhs/lfJeT9ebJTeMq3A669UFkc=; h=Date:To:Cc:Subject:From:In-Reply-To:References:From; b=Bwlpb2bnB8PAqDedWhhDTyLVz1MJh9zkiecqUPBmnwtvx+e6QESq3Yorp6AEATIci itKfvLwoaGmrI/ZHLuCUWvP3cdpiWoUMkc21WZPrAQWmcFGQh5Sq7Zh3OTAwpNbOrX ETdzJi/xraiAUcIO6jDkadoiqRKtG+bVGd6fCKHs= Date: Sun, 10 Nov 2024 06:27:00 +0530 (IST) Message-Id: <20241110.062700.1848871414792572122.enometh@meer.net> To: monnier@iro.umontreal.ca Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly From: Madhu In-Reply-To: References: <20241105.073924.1479117425130782406.enometh@meer.net> X-Mailer: Mew version 6.9 on Emacs 31.0.50 Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Sun_Nov_10_06_27_00_2024_142)--" Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 74208 Cc: 74208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) ----Next_Part(Sun_Nov_10_06_27_00_2024_142)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit [snip: I hope the context can be seen on the bug-list] * Stefan Monnier > IIRC the `setq` is really there to set the value of `default-directory` > during the whole duration of the completion, not just during the setup hook. > This is needed/used if the user modifies the minibuffer's content to > hold only a relative file name, at which point we need that default > directory info in order to perform completions. Ah yes I missed that, (though I haven't worked out yet how it works) > The let+setq could be simplified to > > (let ((default-directory dir)) > > but none of the code within this `let` uses `default-directory` since > there are only calls to `car/cdr`, `setq`, and `set-syntax-table`, none > of which touch file names, so we may as well remove the > (setq default-directory dir) instead. I still think the default-difectory should be let-bound so the binding is undone when the dynamic scope exits. I have not worked out where the default-directory is being restored to the original value, but i know it is possible for the global value to be set incorrectly (e.g. after a M-: (debug), quit - -in the recursive minibuffer which would do a non-local exit.) > I'm leaning towards declaring the `shell-command` behavior above as > a feature rather than a bug. We could avoid still binding default-directory to a non-directory. Using the logic of expand-file-name, how about the following: [shouldn't binding it before the call to `minibuffer-with-setup-hook' be equivalent to a top level let in a hypothetical (with-minibuffer-setup-hook FN &body BODY), or setting it via FN] ----Next_Part(Sun_Nov_10_06_27_00_2024_142)-- Content-Type: Text/X-Patch; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="0001-minibuffer.el-read-file-name-default-avoid-setting-i.patch" >From ff4a2e046a66f7b364ad570c7dce11dab4987155 Mon Sep 17 00:00:00 2001 From: Madhu Date: Tue, 5 Nov 2024 07:19:55 +0530 Subject: [PATCH] minibuffer.el: (read-file-name-default): avoid setting incorrect default-directory * minibuffer.el: (read-file-name-default): bind default-directory (in dynamic scope) instead of modifying it. try to bind it to a valid directory. (e.g. don't set it to a url when calling (ffap) at a url). --- lisp/minibuffer.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index c970752ec2a..672f7b2b318 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -3668,10 +3668,11 @@ read-file-name-default ;; changing `default-directory' in the current buffer, ;; we don't let-bind it. (let ((dir (file-name-as-directory - (expand-file-name dir)))) + (expand-file-name dir))) + (default-directory (if (file-name-absolute-p dir) + dir default-directory))) (minibuffer-with-setup-hook (lambda () - (setq default-directory dir) ;; When the first default in `minibuffer-default' ;; duplicates initial input `insdef', ;; reset `minibuffer-default' to nil. -- 2.46.0.27.gfa3b914457 ----Next_Part(Sun_Nov_10_06_27_00_2024_142)---- From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 10 01:00:47 2024 Received: (at 74208) by debbugs.gnu.org; 10 Nov 2024 06:00:47 +0000 Received: from localhost ([127.0.0.1]:55288 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tA10A-0006V9-MQ for submit@debbugs.gnu.org; Sun, 10 Nov 2024 01:00:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36140) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tA108-0006Uu-0F for 74208@debbugs.gnu.org; Sun, 10 Nov 2024 01:00:44 -0500 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 1tA102-0006Pd-JU; Sun, 10 Nov 2024 01:00:38 -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=/NzG4yFYNOZKl5AB6JfcLAlg5CmPdNJOvrZPZ+v+9rQ=; b=O6rAXqyFfYPk Rz4Mh+Zva7itF8mI3pISfQN4+anq0rgQMvPGdgB57107bigWyZtf1HfPaNAZALtyQIGCaMABvTK/N kSYlvSephkEeMgi1ARrJZc7TwZ0CzAhV9prXV22NxNoHpfFOTwLVqOOC95NQ81wT0bZOJDgeSTAwv 7YyPXL6gdA+prNBhgqhv9vWqaMrlqQH3xQnaPhdADWIA3QGcdZc6twbu6FJspWY4rt1Hpa8xDGdKX x60KyAeWQk0YmmjLHJMZWa4NRsJMJuA8HSVLJZ47MqH8a7NCrbND3U2Q8wn39UOTS7Um4sJUPJ9bV Zq6SXQsKOLJrYnnF1P5EUA==; Date: Sun, 10 Nov 2024 08:00:35 +0200 Message-Id: <86msi7ljb0.fsf@gnu.org> From: Eli Zaretskii To: Madhu In-Reply-To: <20241110.062700.1848871414792572122.enometh@meer.net> (message from Madhu on Sun, 10 Nov 2024 06:27:00 +0530 (IST)) Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly References: <20241105.073924.1479117425130782406.enometh@meer.net> <20241110.062700.1848871414792572122.enometh@meer.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74208 Cc: monnier@iro.umontreal.ca, 74208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Cc: 74208@debbugs.gnu.org > Date: Sun, 10 Nov 2024 06:27:00 +0530 (IST) > From: Madhu > > --- a/lisp/minibuffer.el > +++ b/lisp/minibuffer.el > @@ -3668,10 +3668,11 @@ read-file-name-default > ;; changing `default-directory' in the current buffer, > ;; we don't let-bind it. > (let ((dir (file-name-as-directory > - (expand-file-name dir)))) > + (expand-file-name dir))) > + (default-directory (if (file-name-absolute-p dir) > + dir default-directory))) You probably meant to use let*, right? But anyway, I don't understand the logic: expand-file-name always returns an absolute file name, so the test will always succeed. What did I miss? From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 10 01:59:54 2024 Received: (at 74208) by debbugs.gnu.org; 10 Nov 2024 06:59:54 +0000 Received: from localhost ([127.0.0.1]:55380 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tA1vO-0000zi-9z for submit@debbugs.gnu.org; Sun, 10 Nov 2024 01:59:54 -0500 Received: from smtp0.ctinetworks.com ([205.166.61.207]:54794) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tA1vM-0000zZ-5D for 74208@debbugs.gnu.org; Sun, 10 Nov 2024 01:59:53 -0500 X-ctinetworks-Watermark: 1732085990.65307@9PwtgjUKi3QcOrn/Cmxxuw X-ctinetworks-Envelope-From: enometh@meer.net X-ctinetworks-SpamCheck: X-ctinetworks-VirusCheck: Found to be clean X-ctinetworks-Message-ID: 6D722601C.A4E82 Received: from localhost (unknown [117.254.37.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: enometh@meer.net) by smtp0.ctinetworks.com (Postfix) with ESMTPSA id 6D722601C; Sun, 10 Nov 2024 01:59:47 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp0.ctinetworks.com 6D722601C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meer.net; s=ctidkims1; t=1731221988; bh=fDqaA6I8a5e1VsczABwG2D4SnfesToR3uzD5ZC8Y6Fo=; h=Date:To:Cc:Subject:From:In-Reply-To:References:From; b=pTM1pxhFd41P/Lloo8+OFq9lui543zJrcHzOJARFrwF36yraA2Mnt0Eo4ThiaI2HN Se86fk0EK3i94L5mBH4vEzNaXpBndZe0TJi09pRg66l23k8See2mZipYjEBu5VEKx+ qqjeiVE4zDC+iTEZ71ydU2Iz8R+R+2UDu3sWsx88= Date: Sun, 10 Nov 2024 12:30:07 +0530 (IST) Message-Id: <20241110.123007.483734644166546380.enometh@meer.net> To: eliz@gnu.org Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly From: Madhu In-Reply-To: <86msi7ljb0.fsf@gnu.org> References: <20241110.062700.1848871414792572122.enometh@meer.net> <86msi7ljb0.fsf@gnu.org> X-Mailer: Mew version 6.9 on Emacs 31.0.50 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 74208 Cc: monnier@iro.umontreal.ca, 74208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * Eli Zaretskii <86msi7ljb0.fsf@gnu.org> Wrote on Sun, 10 Nov 2024 08:00:35 +0200 >> --- a/lisp/minibuffer.el >> +++ b/lisp/minibuffer.el >> @@ -3668,10 +3668,11 @@ read-file-name-default >> ;; changing `default-directory' in the current buffer, >> ;; we don't let-bind it. >> (let ((dir (file-name-as-directory >> - (expand-file-name dir)))) >> + (expand-file-name dir))) >> + (default-directory (if (file-name-absolute-p dir) >> + dir default-directory))) > You probably meant to use let*, right? Oops. yes, of course. > But anyway, I don't understand the logic: expand-file-name always > returns an absolute file name, so the test will always succeed. What > did I miss? for the example in the thread, ffap.el:(ffap-read-file-or-url) calls read-file-name-default, via (funcall #'read-file-name-default prompt guess guess) => read-file-name-default("Find file or URL: " "http://example.com" "http://example.com") (read-file-name-default PROMPT &optional DIR DEFAULT-FILENAME MUSTMATCH INITIAL PREDICATE) The problem is that the parameter DIR == "http://example.com" was getting bound to default-directory with undesirable results. DIR a url not a file name but a url. and since expand-file-name behaves like this: (expand-file-name "http://example.com" "~") -> "http://example.com" it can probably be used to determine that DIR is not a legit filename and default directory should not be bound to it. I don't think it has any consequences for the completion-system completion via read-file-name, which would not work anyway (and completing urls in this context say matching against a history list of urls would not make sense either) From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 10 05:01:10 2024 Received: (at 74208) by debbugs.gnu.org; 10 Nov 2024 10:01:10 +0000 Received: from localhost ([127.0.0.1]:55616 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tA4kn-0000k9-Of for submit@debbugs.gnu.org; Sun, 10 Nov 2024 05:01:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37204) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tA4ki-0000jS-Pb for 74208@debbugs.gnu.org; Sun, 10 Nov 2024 05:01:08 -0500 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 1tA4kb-00048j-SQ; Sun, 10 Nov 2024 05:00:58 -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=Jw1NPd0VHdXw93cxM7FR2EQp3ZTVzHiro+Vr4TRKZtU=; b=UaeAVXNLaa4v TkmUY4fh6Amp3ZI2t2b9Jnq4pSsafPGBKn4kaRNYbG++PNc8lTAPB6p6VUzLg/LVHrpKzEukcuc4q kGudzwyJpF44QCrJ6EBbgrjgzlRyJ83seiO7W5qsfznxAsIMwuLEXrMYnIeukP9vkLUCFWd/bYrVI QDvqAt3KzZh7fjPaOjHLozUY2QFaHOh9hT2tI035f9ZlMhUURiyB+2B9m7avb1rMOqvKNDNK54Qmt 6mjQbKrjXVnpsKuM4UJc2vbE0Y82z2bhbzAAR8ZjEqGCR2gk59N/8MeltbZP53UdDneQMHrox/W5e tLFPvP1B9IRZYo5YrcgIuA==; Date: Sun, 10 Nov 2024 12:00:48 +0200 Message-Id: <86h68fl86n.fsf@gnu.org> From: Eli Zaretskii To: Madhu In-Reply-To: <20241110.123007.483734644166546380.enometh@meer.net> (message from Madhu on Sun, 10 Nov 2024 12:30:07 +0530 (IST)) Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly References: <20241110.062700.1848871414792572122.enometh@meer.net> <86msi7ljb0.fsf@gnu.org> <20241110.123007.483734644166546380.enometh@meer.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74208 Cc: monnier@iro.umontreal.ca, 74208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Sun, 10 Nov 2024 12:30:07 +0530 (IST) > Cc: monnier@iro.umontreal.ca, 74208@debbugs.gnu.org > From: Madhu > > >> - (expand-file-name dir)))) > >> + (expand-file-name dir))) > >> + (default-directory (if (file-name-absolute-p dir) > >> + dir default-directory))) > > You probably meant to use let*, right? > > Oops. yes, of course. > > > But anyway, I don't understand the logic: expand-file-name always > > returns an absolute file name, so the test will always succeed. What > > did I miss? > > for the example in the thread, > ffap.el:(ffap-read-file-or-url) calls read-file-name-default, via > (funcall #'read-file-name-default prompt guess guess) => > > read-file-name-default("Find file or URL: " "http://example.com" "http://example.com") > > (read-file-name-default PROMPT &optional DIR DEFAULT-FILENAME > MUSTMATCH INITIAL PREDICATE) > > The problem is that the parameter DIR == "http://example.com" was > getting bound to default-directory with undesirable results. DIR a url > not a file name but a url. and since expand-file-name behaves like > this: > > (expand-file-name "http://example.com" "~") -> "http://example.com" That's not what I see. I see this: (expand-file-name "http://example.com" "~") => /my/home/directory/http:/example.com In what version of Emacs do you see your result? Is that in "emacs -Q"? In any case, the code you propose calls (expand-file-name dir) without the 2nd argument. > it can probably be used to determine that DIR is not a legit filename > and default directory should not be bound to it. I don't see how expand-file-name could help here, see above. From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 10 05:41:38 2024 Received: (at 74208) by debbugs.gnu.org; 10 Nov 2024 10:41:38 +0000 Received: from localhost ([127.0.0.1]:55854 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tA5Ny-0002sf-2k for submit@debbugs.gnu.org; Sun, 10 Nov 2024 05:41:38 -0500 Received: from smtp0.ctinetworks.com ([205.166.61.207]:53510) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tA5Nv-0002sX-Tr for 74208@debbugs.gnu.org; Sun, 10 Nov 2024 05:41:36 -0500 X-ctinetworks-Watermark: 1732099290.65369@onhV3aCWmTYJr/eIArmVVg X-ctinetworks-Envelope-From: enometh@meer.net X-ctinetworks-SpamCheck: X-ctinetworks-VirusCheck: Found to be clean X-ctinetworks-Message-ID: 356D9601C.A2CAC Received: from localhost (unknown [117.254.37.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: enometh@meer.net) by smtp0.ctinetworks.com (Postfix) with ESMTPSA id 356D9601C; Sun, 10 Nov 2024 05:41:23 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp0.ctinetworks.com 356D9601C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meer.net; s=ctidkims1; t=1731235285; bh=xelK99mkxs1Xtc766a1O0HKqsiyHDljGP/wM7hgQNkk=; h=Date:To:Cc:Subject:From:In-Reply-To:References:From; b=TJJYpZyKq6gW2lZaT1DZXw2QW8qJ6yWEePhkOD9ZtSQ7d93Q0xtCly83JYrjVcwRV ZZJt2YfPKv1JqvxLx0UOA+4QL4rdyru9n7a0FZIQEhJoe1rbYzuLQSdP00Tpf6i10M PizKvMvQrp14MxRyuXsn/T1vJDZJawuw/oBlCDwk= Date: Sun, 10 Nov 2024 16:11:41 +0530 (IST) Message-Id: <20241110.161141.2279816734440691375.enometh@meer.net> To: eliz@gnu.org Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly From: Madhu In-Reply-To: <86h68fl86n.fsf@gnu.org> References: <86msi7ljb0.fsf@gnu.org> <20241110.123007.483734644166546380.enometh@meer.net> <86h68fl86n.fsf@gnu.org> X-Mailer: Mew version 6.9 on Emacs 31.0.50 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 74208 Cc: monnier@iro.umontreal.ca, 74208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * Eli Zaretskii <86h68fl86n.fsf@gnu.org> Wrote on Sun, 10 Nov 2024 12:00:48 +0200 > (expand-file-name "http://example.com" "~") > => /my/home/directory/http:/example.com I get the same result. > In what version of Emacs do you see your result? I was evaluating it under edebug after calling edebug-defun on read-file-name-default, and ivoking (ffap) on the url. It returns the argument with or without the second parameter to expand-file-name, and I was hoping I could count on this behaviour to separate the urls from the files. The behaviour of expand-file-name is apparenlty modified when it comes to read-file-name-default, but I can't spot what's going on. ????? From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 10 05:46:03 2024 Received: (at 74208) by debbugs.gnu.org; 10 Nov 2024 10:46:03 +0000 Received: from localhost ([127.0.0.1]:55872 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tA5SF-00036p-CF for submit@debbugs.gnu.org; Sun, 10 Nov 2024 05:46:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43788) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tA5SC-00036L-MC for 74208@debbugs.gnu.org; Sun, 10 Nov 2024 05:46:01 -0500 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 1tA5S7-00036g-F8; Sun, 10 Nov 2024 05:45:55 -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=+imfZX82TX0pZ2YrS6Jhq3BmcQHtiPDY+Zz0HS7nd5w=; b=DKzIDAjDEVAe My7uj1EwvAq7lIFe533GEHQwJi6Wzv5OQiJc/jQOi/QrTU91gjyqcIc7MiZ9tqerEvUWlB4WFEXWn JqDWK4A/5/Tnk//HOHFJtatYeO1RJ4UqEqqBzmUHQl1Ap/u9NAFwkALwCOIxZmxi6K/zFEqxDnogd uHUjj8VkFxjELBdFmWjPVYA1WdvWY7pHLkIM+jjhkGH1fBgaLCx/+mabvAlMvXNxYQZl2yRwtTgmY +CdigNrQT/Z8m9Hvr65ryYgePVkrpT7UkMjdCDqTWJeo4Whd86/kRWUhvSoP64SdgOiaj+eobzSCq Eb8waaVxgv+AP2ID0zaEGA==; Date: Sun, 10 Nov 2024 12:45:52 +0200 Message-Id: <86ed3jl63j.fsf@gnu.org> From: Eli Zaretskii To: Madhu In-Reply-To: <20241110.161141.2279816734440691375.enometh@meer.net> (message from Madhu on Sun, 10 Nov 2024 16:11:41 +0530 (IST)) Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly References: <86msi7ljb0.fsf@gnu.org> <20241110.123007.483734644166546380.enometh@meer.net> <86h68fl86n.fsf@gnu.org> <20241110.161141.2279816734440691375.enometh@meer.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74208 Cc: monnier@iro.umontreal.ca, 74208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Sun, 10 Nov 2024 16:11:41 +0530 (IST) > Cc: monnier@iro.umontreal.ca, 74208@debbugs.gnu.org > From: Madhu > > * Eli Zaretskii <86h68fl86n.fsf@gnu.org> > Wrote on Sun, 10 Nov 2024 12:00:48 +0200 > > (expand-file-name "http://example.com" "~") > > => /my/home/directory/http:/example.com > I get the same result. > > > In what version of Emacs do you see your result? > > I was evaluating it under edebug after calling edebug-defun on > read-file-name-default, and ivoking (ffap) on the url. > > It returns the argument with or without the second parameter to > expand-file-name, and I was hoping I could count on this behaviour to > separate the urls from the files. > > The behaviour of expand-file-name is apparenlty modified when it comes > to read-file-name-default, but I can't spot what's going on. ????? Perhaps because TRAMP was loaded? From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 10 06:17:04 2024 Received: (at 74208) by debbugs.gnu.org; 10 Nov 2024 11:17:04 +0000 Received: from localhost ([127.0.0.1]:55912 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tA5wG-0004T0-4g for submit@debbugs.gnu.org; Sun, 10 Nov 2024 06:17:04 -0500 Received: from smtp0.ctinetworks.com ([205.166.61.207]:44642) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tA5wD-0004SX-7D for 74208@debbugs.gnu.org; Sun, 10 Nov 2024 06:17:02 -0500 X-ctinetworks-Watermark: 1732101420.46826@L/QH0/6OdMg5ayOckosNrA X-ctinetworks-Envelope-From: enometh@meer.net X-ctinetworks-SpamCheck: X-ctinetworks-VirusCheck: Found to be clean X-ctinetworks-Message-ID: B5685601C.A0863 Received: from localhost (unknown [117.254.37.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: enometh@meer.net) by smtp0.ctinetworks.com (Postfix) with ESMTPSA id B5685601C; Sun, 10 Nov 2024 06:16:55 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp0.ctinetworks.com B5685601C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meer.net; s=ctidkims1; t=1731237416; bh=JM47T+TeQ10rcuoBWBLM/RlDMLphK43dlLZqntnYtGA=; h=Date:To:Cc:Subject:From:In-Reply-To:References:From; b=ECrrvoyZ3LTxzYYfrXbCUj0ckcpiUvLTcHdLJ4o3twC1mhY2z9tZmz2Pd37L3pNFn egQmJU90WMlPN3Y1r8VMXFK6NUeMPFiWW9iVa8hhrXuyGJVVNBCec5gcgf0Gmqf5g4 7rhGMXBzAfovDVSipiz9HHycZDSju5UQCFjnCBjo= Date: Sun, 10 Nov 2024 16:47:17 +0530 (IST) Message-Id: <20241110.164717.37865040188913982.enometh@meer.net> To: eliz@gnu.org Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly From: Madhu In-Reply-To: <86ed3jl63j.fsf@gnu.org> References: <86h68fl86n.fsf@gnu.org> <20241110.161141.2279816734440691375.enometh@meer.net> <86ed3jl63j.fsf@gnu.org> X-Mailer: Mew version 6.9 on Emacs 31.0.50 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 74208 Cc: monnier@iro.umontreal.ca, 74208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * Eli Zaretskii <86ed3jl63j.fsf@gnu.org> Wrote on Sun, 10 Nov 2024 12:45:52 +0200 >> I was evaluating it under edebug after calling edebug-defun on >> read-file-name-default, and ivoking (ffap) on the url. >> >> It returns the argument with or without the second parameter to >> expand-file-name, and I was hoping I could count on this behaviour to >> separate the urls from the files. >> >> The behaviour of expand-file-name is apparenlty modified when it comes >> to read-file-name-default, but I can't spot what's going on. ????? > > Perhaps because TRAMP was loaded? It's because of the call to (ffap-read-file-or-url "foo" "https://example.com/") which roughly does the equivalent of (let ((file-name-handler-alist (cl-adjoin (cons ffap-url-regexp #'ffap--url-file-handler) file-name-handler-alist))) (expand-file-name "https://example.com" "~")) Maybe the idea will still work? From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 10 06:26:23 2024 Received: (at 74208) by debbugs.gnu.org; 10 Nov 2024 11:26:23 +0000 Received: from localhost ([127.0.0.1]:55932 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tA65H-0004to-65 for submit@debbugs.gnu.org; Sun, 10 Nov 2024 06:26:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59076) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tA65E-0004tS-T9 for 74208@debbugs.gnu.org; Sun, 10 Nov 2024 06:26:21 -0500 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 1tA658-0007MU-Ge; Sun, 10 Nov 2024 06:26:14 -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=HvVNyGEj6D6g8+FcKeexnIMzclgvoQvwFdZTLuTRF/E=; b=Ar2ceEyr6mwk 6DLgN82GJNoowCa72f0c4SGdBVyar4VBWwdQ4oxGpEGMjlQNIpC2P+AH+JQ2Jr4HOi304c6KdCU8n HPC6ZcsjLhDbZ927ZHyxQFMnCF4AJp1ZTXr9k8DiV3mMgoLizEs9wGkIazsp1WikHsz2auI72RBhk IRHD9EcP2Owdd0F45ZLsixRUm6ObuxFab8EjowFNMS276MEIlUfWRyIA+x9l7nPvOTbHRWl+xQXg3 2jH/NSqM6cTolLFRRk2XaOfgZel7fFBwYWyW+jhITn9WS7FbeR1CC3OL2iIzO/PZ8f4zwOU3rXvHS Sni9tUh9Tag1x6uWAgvohg==; Date: Sun, 10 Nov 2024 13:26:10 +0200 Message-Id: <86cyj3l48d.fsf@gnu.org> From: Eli Zaretskii To: Madhu In-Reply-To: <20241110.164717.37865040188913982.enometh@meer.net> (message from Madhu on Sun, 10 Nov 2024 16:47:17 +0530 (IST)) Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly References: <86h68fl86n.fsf@gnu.org> <20241110.161141.2279816734440691375.enometh@meer.net> <86ed3jl63j.fsf@gnu.org> <20241110.164717.37865040188913982.enometh@meer.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74208 Cc: monnier@iro.umontreal.ca, 74208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Sun, 10 Nov 2024 16:47:17 +0530 (IST) > Cc: monnier@iro.umontreal.ca, 74208@debbugs.gnu.org > From: Madhu > > * Eli Zaretskii <86ed3jl63j.fsf@gnu.org> > Wrote on Sun, 10 Nov 2024 12:45:52 +0200 > >> I was evaluating it under edebug after calling edebug-defun on > >> read-file-name-default, and ivoking (ffap) on the url. > >> > >> It returns the argument with or without the second parameter to > >> expand-file-name, and I was hoping I could count on this behaviour to > >> separate the urls from the files. > >> > >> The behaviour of expand-file-name is apparenlty modified when it comes > >> to read-file-name-default, but I can't spot what's going on. ????? > > > > Perhaps because TRAMP was loaded? > It's because of the call to > (ffap-read-file-or-url "foo" "https://example.com/") > > which roughly does the equivalent of > > (let ((file-name-handler-alist > (cl-adjoin (cons ffap-url-regexp #'ffap--url-file-handler) > file-name-handler-alist))) > (expand-file-name "https://example.com" "~")) > > Maybe the idea will still work? The idea being not to bind default-directory to the URL? Doesn't ffap need that? If not, why does it override the file handlers? From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 10 11:54:46 2024 Received: (at 74208) by debbugs.gnu.org; 10 Nov 2024 16:54:46 +0000 Received: from localhost ([127.0.0.1]:56430 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tABD4-0002cI-BD for submit@debbugs.gnu.org; Sun, 10 Nov 2024 11:54:46 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:39223) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tABD2-0002c4-3A for 74208@debbugs.gnu.org; Sun, 10 Nov 2024 11:54:44 -0500 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id B2DB98099D; Sun, 10 Nov 2024 11:54:38 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1731257677; bh=2rBs12x+ESmgDhqKxYJfI5zvrOKu2Vx3q2cJNtBOxbk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Pb0W9gOSY46wAq/PUFyU3xisqCclon1Uy3EezK4UbDTmWjYgTH42TCIfpwN6/im6g 9V8BjwPZpstNlNSXrWNDrLa5PQMvYGS0TEQULjF55YpIv87YhNlUKoiz6utPm69VAK gAZlvJwpVeJMmwBdbs/17mI9UmODFIQgfxxYvCN4IKo/vhOjes9qgrbJL+x2BMtMhm +amHt0shHslwQ8umyrJ7XzkjYMAesHnQJpvKcwmi2rpTf6tg1Z6ky+K6OhZpYZlSfA Hg+kaxSbc4RjG9ob8GF6iQhD716T8CuVqGd8hlVl2oDBwBfCslTd0a+QeSxXcHgrgO yiKtkOJ5DB4yA== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id C691080964; Sun, 10 Nov 2024 11:54:37 -0500 (EST) Received: from pastel (104-195-225-43.cpe.teksavvy.com [104.195.225.43]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 9416E1204E5; Sun, 10 Nov 2024 11:54:37 -0500 (EST) From: Stefan Monnier To: Madhu Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly In-Reply-To: <20241110.123007.483734644166546380.enometh@meer.net> (Madhu's message of "Sun, 10 Nov 2024 12:30:07 +0530 (IST)") Message-ID: References: <20241110.062700.1848871414792572122.enometh@meer.net> <86msi7ljb0.fsf@gnu.org> <20241110.123007.483734644166546380.enometh@meer.net> Date: Sun, 10 Nov 2024 11:54:36 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.039 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74208 Cc: eliz@gnu.org, 74208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > for the example in the thread, > ffap.el:(ffap-read-file-or-url) calls read-file-name-default, via > (funcall #'read-file-name-default prompt guess guess) => > > read-file-name-default("Find file or URL: " "http://example.com" "http://example.com") > > (read-file-name-default PROMPT &optional DIR DEFAULT-FILENAME > MUSTMATCH INITIAL PREDICATE) > > The problem is that the parameter DIR == "http://example.com" was > getting bound to default-directory with undesirable results. It can also have desirable results sometimes (depends on the URL at point and what kind of support for URLs you have in your Emacs, admittedly). Do you happen to have a more realistic scenario than your "echo foo" that lets us better judge the severity of the problem, and maybe other ways to solve the actual problem? Stefan From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 10 21:17:09 2024 Received: (at 74208) by debbugs.gnu.org; 11 Nov 2024 02:17:09 +0000 Received: from localhost ([127.0.0.1]:57235 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tAJzJ-0002gm-07 for submit@debbugs.gnu.org; Sun, 10 Nov 2024 21:17:09 -0500 Received: from smtp0.ctinetworks.com ([205.166.61.207]:37310) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tAJzG-0002gd-P1 for 74208@debbugs.gnu.org; Sun, 10 Nov 2024 21:17:07 -0500 X-ctinetworks-Watermark: 1732155426.07367@yJywO38YMS7czIZkKlNpsA X-ctinetworks-Envelope-From: enometh@meer.net X-ctinetworks-SpamCheck: X-ctinetworks-VirusCheck: Found to be clean X-ctinetworks-Message-ID: 1DFB9601C.A449F Received: from localhost (unknown [117.254.37.51]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: enometh@meer.net) by smtp0.ctinetworks.com (Postfix) with ESMTPSA id 1DFB9601C; Sun, 10 Nov 2024 21:17:03 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp0.ctinetworks.com 1DFB9601C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meer.net; s=ctidkims1; t=1731291425; bh=lhfFbGlYrTQcAnf6XknIjP2DFCl+e/7PqrFvXjlZrfo=; h=Date:To:Cc:Subject:From:In-Reply-To:References:From; b=dXXjy/e/xytdWXu6oA1dcsMcnNl5a4XsH3hLZToNGO6ufoZ4u2Y4ZXLmD3g2UAcFA uDwflu66XaPaKkfJGffzmxROZnZ0xO6aHvAZLz+firZl4qWr/qAPob+HI9HBPX9D2l 8D89B7JimFsZ5j5Snmfu3quv9Zpu3SdO4Pd4Oh2s= Date: Mon, 11 Nov 2024 07:47:25 +0530 (IST) Message-Id: <20241111.074725.1221470735788072992.enometh@meer.net> To: monnier@iro.umontreal.ca Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly From: Madhu In-Reply-To: References: <86msi7ljb0.fsf@gnu.org> <20241110.123007.483734644166546380.enometh@meer.net> X-Mailer: Mew version 6.9 on Emacs 31.0.50 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 74208 Cc: eliz@gnu.org, 74208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) >> The problem is that the parameter DIR == "http://example.com" was >> getting bound to default-directory with undesirable results. > It can also have desirable results sometimes (depends on the URL at point > and what kind of support for URLs you have in your Emacs, admittedly). > Do you happen to have a more realistic scenario than your "echo foo" > that lets us better judge the severity of the problem, and maybe other > ways to solve the actual problem? Are you saying it is ok for emacs to make all calls to `call-prcoess' to unconditionally fail --- when emacs is waiting for input at the minibuffer? the calls to call-process can come from anywhere, from timers, or from outside via emacsclient, etc. I already posted that any hypothetical completion facilites are singularly useless for the task of ffap (url) -- to get the url at point into the minibuffer and maybe manually edit it. If these facilities exist and you are using them, I'd like to see an example. From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 10 22:40:39 2024 Received: (at 74208) by debbugs.gnu.org; 11 Nov 2024 03:40:39 +0000 Received: from localhost ([127.0.0.1]:57363 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tALI7-0006UI-6u for submit@debbugs.gnu.org; Sun, 10 Nov 2024 22:40:39 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:13493) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tALI4-0006U3-0i for 74208@debbugs.gnu.org; Sun, 10 Nov 2024 22:40:38 -0500 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id DC59C100417; Sun, 10 Nov 2024 22:40:28 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1731296428; bh=ksLAJHI57xt7ViFssEbBNze3CW+WVT6a9/s7uc0xkSM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=CHHeve7ATbCpi/wqd1Z1hZQDxJF1I8JWq31dvlodkuuu75CisB3IB+q0EG1RwbSGD q6a/Wuv5vXNEkuxDPgNA3fMHzWgFDq7s+TyuIz1c7jJUxqOtjM6XBgma45aMkLFx9I hayjOYMqRJXE8B5vvqGCyvMXV0SnX/AANfDLvirhe230l8i1sUwnSe1BJ4H4Hz9ExF BKTalzujGTrfzDxAVivYlYGoyhJRV2MdqhzMDIubYmvXKFbQABPYPYGjbU+XJ1zEsb z6NStK1kGr8lRGFZQE8a3Unct6w3MMF/arYhrqupLbG19sG1t/QxUzQDXnQXb+02SA J1/Y/ogHH0NfQ== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 11BC21001D9; Sun, 10 Nov 2024 22:40:28 -0500 (EST) Received: from pastel (104-195-225-43.cpe.teksavvy.com [104.195.225.43]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id DB0AA12020E; Sun, 10 Nov 2024 22:40:27 -0500 (EST) From: Stefan Monnier To: Madhu Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly In-Reply-To: <20241111.074725.1221470735788072992.enometh@meer.net> (Madhu's message of "Mon, 11 Nov 2024 07:47:25 +0530 (IST)") Message-ID: References: <86msi7ljb0.fsf@gnu.org> <20241110.123007.483734644166546380.enometh@meer.net> <20241111.074725.1221470735788072992.enometh@meer.net> Date: Sun, 10 Nov 2024 22:40:27 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.030 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74208 Cc: eliz@gnu.org, 74208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >>> The problem is that the parameter DIR == "http://example.com" was >>> getting bound to default-directory with undesirable results. > >> It can also have desirable results sometimes (depends on the URL at point >> and what kind of support for URLs you have in your Emacs, admittedly). >> Do you happen to have a more realistic scenario than your "echo foo" >> that lets us better judge the severity of the problem, and maybe other >> ways to solve the actual problem? > > Are you saying it is ok for emacs to make all calls to `call-prcoess' > to unconditionally fail --- when emacs is waiting for input at the > minibuffer? the calls to call-process can come from anywhere, from > timers, or from outside via emacsclient, etc. `default-directory` can point to random places, including non-existing directories, HTTP places (e.g. if you enable `url-handler-mode`), so code like timers need to take this possibility into account, yes. The ffap minibuffer discussed here is just one of many other ways to get into this situation. > I already posted that any hypothetical completion facilites are > singularly useless for the task of ffap (url) -- to get the url at > point into the minibuffer and maybe manually edit it. If these > facilities exist and you are using them, I'd like to see an example. diff --git a/lisp/url/url-handlers.el b/lisp/url/url-handlers.el index 9edc7865a74..17013345c25 100644 --- a/lisp/url/url-handlers.el +++ b/lisp/url/url-handlers.el @@ -375,18 +375,48 @@ url-insert-file-contents-literally (kill-buffer buffer) nil)) -(defun url-file-name-completion (url _directory &optional _predicate) - ;; Even if it's not implemented, it's not an error to ask for completion, - ;; in case it's available (bug#14806). - ;; (error "Unimplemented") - url) +(defun url-file-name-completion (url directory &optional predicate) + (let ((all (url-file-name-all-completions url directory))) + (if (null all) + ;; If `url' is the empty string, don't return nil, so as to prevent + ;; partial-completion from recursing into the parent directory. + (if (equal url "") url) + (try-completion url all predicate)))) (put 'file-name-completion 'url-file-handlers #'url-file-name-completion) -(defun url-file-name-all-completions (_file _directory) - ;; Even if it's not implemented, it's not an error to ask for completion, - ;; in case it's available (bug#14806). - ;; (error "Unimplemented") - nil) +(defvar url-handler-temp-buf) + +(defun url-file-name-all-completions (file directory) + ;; FIXME: Cache the "directory" buffers between completion requests. + (let ((buf (get-file-buffer directory))) + (unless buf + (setq buf (ignore-errors (find-file-noselect directory))) + (when buf + (with-current-buffer buf + (set (make-local-variable 'url-handler-temp-buf) t)))) + (when buf + (unwind-protect + (with-current-buffer buf + (save-excursion + (let ((all ()) + (case-fold-search t) + ;; FIXME: Handle URL-quoting. + (regexp (format ") id 1tEpD4-00042A-Ps for submit@debbugs.gnu.org; Sat, 23 Nov 2024 07:25:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59866) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tEpD2-00041x-EH for 74208@debbugs.gnu.org; Sat, 23 Nov 2024 07:25:57 -0500 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 1tEpCw-0006GP-Sa; Sat, 23 Nov 2024 07:25:51 -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=7rEkQPL2+U28sx9VzyWiU9YtAgAbXS6CWSLSpg7bRNY=; b=RZMsygdcJrTh T1ryBgrp9fqOsocKjqnRLimcMeN+XFOn0do3r2RdQ0lg/a9mWuIsYL02wICCKCmTKGD24/k5gTqqM MpS1CAMpyifalLqiD/VMd2k0oZODxYJmyfJAmyCyJ7PzV9NlENaVb1QnlG/eNKgji2yEKOYUW19ZA JeK+WIQaM8r2oq8i0piBT1G9tVymOZzWASFEj2e4r8eWRI+d9YeJU6Q40AzlcrENVz1NEoDHV+nMs lO9dsCp8vtjwhMv3YaNb8l2oZM48QZwp0JiZWf++wOMQB19UFVCImFcn/Lk2oU3wM0JRBL7Sf8gYg 9U3GimVcGq+rvRnL5x09Eg==; Date: Sat, 23 Nov 2024 14:25:42 +0200 Message-Id: <864j3ym915.fsf@gnu.org> From: Eli Zaretskii To: Stefan Monnier In-Reply-To: (message from Stefan Monnier on Sun, 10 Nov 2024 22:40:27 -0500) Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly References: <86msi7ljb0.fsf@gnu.org> <20241110.123007.483734644166546380.enometh@meer.net> <20241111.074725.1221470735788072992.enometh@meer.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74208 Cc: enometh@meer.net, 74208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Ping! How should we make progress with this issue? > From: Stefan Monnier > Cc: eliz@gnu.org, 74208@debbugs.gnu.org > Date: Sun, 10 Nov 2024 22:40:27 -0500 > > >>> The problem is that the parameter DIR == "http://example.com" was > >>> getting bound to default-directory with undesirable results. > > > >> It can also have desirable results sometimes (depends on the URL at point > >> and what kind of support for URLs you have in your Emacs, admittedly). > >> Do you happen to have a more realistic scenario than your "echo foo" > >> that lets us better judge the severity of the problem, and maybe other > >> ways to solve the actual problem? > > > > Are you saying it is ok for emacs to make all calls to `call-prcoess' > > to unconditionally fail --- when emacs is waiting for input at the > > minibuffer? the calls to call-process can come from anywhere, from > > timers, or from outside via emacsclient, etc. > > `default-directory` can point to random places, including non-existing > directories, HTTP places (e.g. if you enable `url-handler-mode`), so > code like timers need to take this possibility into account, yes. > The ffap minibuffer discussed here is just one of many other ways to get > into this situation. > > > I already posted that any hypothetical completion facilites are > > singularly useless for the task of ffap (url) -- to get the url at > > point into the minibuffer and maybe manually edit it. If these > > facilities exist and you are using them, I'd like to see an example. > > diff --git a/lisp/url/url-handlers.el b/lisp/url/url-handlers.el > index 9edc7865a74..17013345c25 100644 > --- a/lisp/url/url-handlers.el > +++ b/lisp/url/url-handlers.el > @@ -375,18 +375,48 @@ url-insert-file-contents-literally > (kill-buffer buffer) > nil)) > > -(defun url-file-name-completion (url _directory &optional _predicate) > - ;; Even if it's not implemented, it's not an error to ask for completion, > - ;; in case it's available (bug#14806). > - ;; (error "Unimplemented") > - url) > +(defun url-file-name-completion (url directory &optional predicate) > + (let ((all (url-file-name-all-completions url directory))) > + (if (null all) > + ;; If `url' is the empty string, don't return nil, so as to prevent > + ;; partial-completion from recursing into the parent directory. > + (if (equal url "") url) > + (try-completion url all predicate)))) > (put 'file-name-completion 'url-file-handlers #'url-file-name-completion) > > -(defun url-file-name-all-completions (_file _directory) > - ;; Even if it's not implemented, it's not an error to ask for completion, > - ;; in case it's available (bug#14806). > - ;; (error "Unimplemented") > - nil) > +(defvar url-handler-temp-buf) > + > +(defun url-file-name-all-completions (file directory) > + ;; FIXME: Cache the "directory" buffers between completion requests. > + (let ((buf (get-file-buffer directory))) > + (unless buf > + (setq buf (ignore-errors (find-file-noselect directory))) > + (when buf > + (with-current-buffer buf > + (set (make-local-variable 'url-handler-temp-buf) t)))) > + (when buf > + (unwind-protect > + (with-current-buffer buf > + (save-excursion > + (let ((all ()) > + (case-fold-search t) > + ;; FIXME: Handle URL-quoting. > + (regexp (format " + (goto-char (point-min)) > + (while (re-search-forward regexp nil t) > + (let ((url (match-string 1))) > + (unless (string-match > + "\\`\\(?:\\.\\.\\|[#?/]\\|[-a-z]+:/\\)\\|" url) > + ;; It's a relative URL. > + (when (string-match "[#?]\\|/\\(.\\)" url) > + (setq url (substring url (or (match-beginning 1) > + (match-beginning 0))))) > + ;; FIXME: Handle URL-unquoting. > + (push url all)))) > + all))) > + (and (buffer-live-p buf) > + (buffer-local-value 'url-handler-temp-buf buf) > + (kill-buffer buf)))))) > (put 'file-name-all-completions > 'url-file-handlers #'url-file-name-all-completions) > > > From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 23 09:55:42 2024 Received: (at 74208) by debbugs.gnu.org; 23 Nov 2024 14:55:42 +0000 Received: from localhost ([127.0.0.1]:58316 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tErXx-00030X-Th for submit@debbugs.gnu.org; Sat, 23 Nov 2024 09:55:42 -0500 Received: from smtp0.ctinetworks.com ([205.166.61.207]:60718) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tErXv-0002zG-6V for 74208@debbugs.gnu.org; Sat, 23 Nov 2024 09:55:40 -0500 X-ctinetworks-Watermark: 1733237738.60077@K2qR3Ok8RbcKwIsivEkYkA X-ctinetworks-Envelope-From: enometh@meer.net X-ctinetworks-SpamCheck: X-ctinetworks-VirusCheck: Found to be clean X-ctinetworks-Message-ID: 365265F4B.A2CC3 Received: from localhost (unknown [117.254.37.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: enometh@meer.net) by smtp0.ctinetworks.com (Postfix) with ESMTPSA id 365265F4B for <74208@debbugs.gnu.org>; Sat, 23 Nov 2024 09:55:31 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp0.ctinetworks.com 365265F4B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meer.net; s=ctidkims1; t=1732373734; bh=0oSbS6ggUOU8sh+MKKeoECbsGxvttLcVHjK8sd7ZcD8=; h=Date:To:Subject:From:In-Reply-To:References:From; b=D0NH0qzk9jBd/36R+tzbyAfUJEe3BiZEwm6MAt3FZo6KW61jK09d11F9G0TBjyV+o eMezYsVte1UTToAMB54IIncGDvECRgoPysbxeheVyOdcmXZbHfWqqhR9n4kWzUYrCe FJ6InNVoJb2J5A5ESwRKMlgd9j8zkRp3NwGfSGrE= Date: Sat, 23 Nov 2024 20:26:10 +0530 (IST) Message-Id: <20241123.202610.1298271958174406341.enometh@meer.net> To: 74208@debbugs.gnu.org Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly From: Madhu In-Reply-To: <864j3ym915.fsf@gnu.org> References: <20241111.074725.1221470735788072992.enometh@meer.net> <864j3ym915.fsf@gnu.org> X-Mailer: Mew version 6.9 on Emacs 31.0.50 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 74208 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * Eli Zaretskii <864j3ym915.fsf@gnu.org> Wrote on Sat, 23 Nov 2024 14:25:42 +0200 > Ping! How should we make progress with this issue? I haven't had a chance to use Stefan's url history code yet to see how it works, but hopefully i'll get around to it soon. But I don't think it is acceptable for call process to fail just because default-directory is bound to a url. (There are other problems like bogus invalid entries in file-name-history -- resulting from a merging a relative pathname to a url) which also argue against setting the default-url in general (it may make sense in a specific use case) From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 23 22:00:27 2024 Received: (at 74208) by debbugs.gnu.org; 24 Nov 2024 03:00:28 +0000 Received: from localhost ([127.0.0.1]:60184 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tF2rL-0006dg-Lg for submit@debbugs.gnu.org; Sat, 23 Nov 2024 22:00:27 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:14871) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tF2rJ-0006dS-H5 for 74208@debbugs.gnu.org; Sat, 23 Nov 2024 22:00:25 -0500 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id EE36944125F; Sat, 23 Nov 2024 22:00:17 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1732417217; bh=rvVjE6ijXsZHeD4Py2i0/twGjatDAeGNnrwgPyg7Ato=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=HZoMJ3u4s++PJDHSNC2FJZC6nhM8yvPdL57F/gqMmYmdQUuB2zO2OlemmdvYfHlVC GEzNv0Rl5QbjC6ihM8AWsblEhrmje3hokdQ72WUHQlRNOjW7g5WiGuBf31sLjyZvGj 7xWCLXsRiHvZ3s09yAxruGLtCSPsCOx9eKEylcOAKKd9kpskDPOdIuTUvNkySvHnSw V1LiTnXpMDsMh6FwBMOh4etdzh/TnHSJcfKsJqHrx44mWUdlGYozeJxEk8emDP952Y tF8LMFCdnkXvE7DkArcS9eXoGqnlVWR70D49GfVuD+wuON3Jt3XuLdrVJkIiAW7F+7 AbYSAADmjOcXw== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 2043C441201; Sat, 23 Nov 2024 22:00:17 -0500 (EST) Received: from pastel (104-195-225-43.cpe.teksavvy.com [104.195.225.43]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id E62EA1203B5; Sat, 23 Nov 2024 22:00:16 -0500 (EST) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly In-Reply-To: <864j3ym915.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 23 Nov 2024 14:25:42 +0200") Message-ID: References: <86msi7ljb0.fsf@gnu.org> <20241110.123007.483734644166546380.enometh@meer.net> <20241111.074725.1221470735788072992.enometh@meer.net> <864j3ym915.fsf@gnu.org> Date: Sat, 23 Nov 2024 22:00:16 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.019 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74208 Cc: enometh@meer.net, 74208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Ping! How should we make progress with this issue? I think the core of this bug report is that `shell-command` can fail when `default-directory` is set to a value that doesn't correspond to a local directory. At least for things like `(shell-command "date")` this is undesirable. Maybe `call-process` should try to "look for" a valid directory if `default-directory` isn't good enough? Stefan From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 24 02:19:57 2024 Received: (at 74208) by debbugs.gnu.org; 24 Nov 2024 07:19:57 +0000 Received: from localhost ([127.0.0.1]:60525 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tF6uS-0002g6-WE for submit@debbugs.gnu.org; Sun, 24 Nov 2024 02:19:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57310) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tF6uR-0002fm-At for 74208@debbugs.gnu.org; Sun, 24 Nov 2024 02:19:56 -0500 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 1tF6uL-0005AV-Ss; Sun, 24 Nov 2024 02:19:49 -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=krAurI3Y9M8h3TV8Yk1ZCG+fjgECZm+loc/Y72uX/so=; b=QlH70vvIMqd1 baL4ICPHTebcYO9H0I89tWxm3DHTg05vpxI7Az7u0gWHOF2sC7N0kQAeOLZ0PwFPEU97Ztm2itoF9 N/n2cLUmW5sWCFp8Ben8i+yt7+qn4BMVxILll2tG1JrGAV58U4EoF+pOf3OCk+LPXopYzfx/3JQug uN9TBv2HrL5N5YpGr4stMv00PC0HchjKMMmbBHVgrAdiDR6rw/UgEEEpJ48AKwLO3nnLNSBktlxXE 8NB3Xonw3Gssl0gJ5WfmoqaifxPBbg0NN6ERJ9qyRlsPvlOGHprV4T8+fr9D7zuetlpoXdJ1D8kWX XTKuK2KTUecx3ePU4wzW8A==; Date: Sun, 24 Nov 2024 09:19:47 +0200 Message-Id: <86v7wdjdyk.fsf@gnu.org> From: Eli Zaretskii To: Stefan Monnier In-Reply-To: (message from Stefan Monnier on Sat, 23 Nov 2024 22:00:16 -0500) Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly References: <86msi7ljb0.fsf@gnu.org> <20241110.123007.483734644166546380.enometh@meer.net> <20241111.074725.1221470735788072992.enometh@meer.net> <864j3ym915.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74208 Cc: enometh@meer.net, 74208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Stefan Monnier > Cc: enometh@meer.net, 74208@debbugs.gnu.org > Date: Sat, 23 Nov 2024 22:00:16 -0500 > > > Ping! How should we make progress with this issue? > > I think the core of this bug report is that `shell-command` can fail > when `default-directory` is set to a value that doesn't correspond to > a local directory. > > At least for things like `(shell-command "date")` this is undesirable. > > Maybe `call-process` should try to "look for" a valid directory if > `default-directory` isn't good enough? It already does: Lisp_Object get_current_directory (bool encode) { Lisp_Object curdir = BVAR (current_buffer, directory); Lisp_Object dir = Funhandled_file_name_directory (curdir); /* If the file name handler says that dir is unreachable, use a sensible default. */ if (NILP (dir)) dir = build_string ("~"); I guess this case somehow evades the test? From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 07 07:20:57 2024 Received: (at 74208) by debbugs.gnu.org; 7 Dec 2024 12:20:57 +0000 Received: from localhost ([127.0.0.1]:45682 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tJtns-0001Yt-ML for submit@debbugs.gnu.org; Sat, 07 Dec 2024 07:20:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39214) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tJtnq-0001Ye-Jc for 74208@debbugs.gnu.org; Sat, 07 Dec 2024 07:20:55 -0500 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 1tJtnj-0000vb-M3; Sat, 07 Dec 2024 07:20:49 -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=maLxO9OgeJbvu6QjDXKjgZVbtrsPcIq40V6xmigVUjs=; b=NTZbPtgfaMkf zIEz9mcZ5xuRYb8nWunQF7t6kbLNkhXd1oV48GpTsvDFHgQzXtWDL1hQvtXfso47L2e5psRFkwNmf +MrCGmGCiWCkxqlYIU89nNeb7zgtwH0fLU0Wa/wMdTu+BblJVgHr6U0aqdAm5P5GCXYi4g+ra0Vmm eOBSjf0UAwDH4YWreB4wZDx41pRsjrVVCwwiRMLf9pIYXjRgPHkmvQBSQBljiWbJhwgQbbDUJSRUQ kUvdpIowA1oJ5Ut0BW1Jo4H92t6Kz3mCeaYGlaqDd7XVvGZF3SjLYdYZ9VIZW09NsCGZLFpZsDprA gXHTEyGeftORAeLm4SZu3A==; Date: Sat, 07 Dec 2024 14:20:45 +0200 Message-Id: <8634izk7ky.fsf@gnu.org> From: Eli Zaretskii To: monnier@iro.umontreal.ca, enometh@meer.net In-Reply-To: <86v7wdjdyk.fsf@gnu.org> (message from Eli Zaretskii on Sun, 24 Nov 2024 09:19:47 +0200) Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly References: <86msi7ljb0.fsf@gnu.org> <20241110.123007.483734644166546380.enometh@meer.net> <20241111.074725.1221470735788072992.enometh@meer.net> <864j3ym915.fsf@gnu.org> <86v7wdjdyk.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74208 Cc: 74208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Ping! Do we want to do anything about this issue? > Cc: enometh@meer.net, 74208@debbugs.gnu.org > Date: Sun, 24 Nov 2024 09:19:47 +0200 > From: Eli Zaretskii > > > From: Stefan Monnier > > Cc: enometh@meer.net, 74208@debbugs.gnu.org > > Date: Sat, 23 Nov 2024 22:00:16 -0500 > > > > > Ping! How should we make progress with this issue? > > > > I think the core of this bug report is that `shell-command` can fail > > when `default-directory` is set to a value that doesn't correspond to > > a local directory. > > > > At least for things like `(shell-command "date")` this is undesirable. > > > > Maybe `call-process` should try to "look for" a valid directory if > > `default-directory` isn't good enough? > > It already does: > > Lisp_Object > get_current_directory (bool encode) > { > Lisp_Object curdir = BVAR (current_buffer, directory); > Lisp_Object dir = Funhandled_file_name_directory (curdir); > > /* If the file name handler says that dir is unreachable, use > a sensible default. */ > if (NILP (dir)) > dir = build_string ("~"); > > I guess this case somehow evades the test? > > > > From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 07 12:24:15 2024 Received: (at 74208) by debbugs.gnu.org; 7 Dec 2024 17:24:15 +0000 Received: from localhost ([127.0.0.1]:48379 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tJyXP-0000TC-4a for submit@debbugs.gnu.org; Sat, 07 Dec 2024 12:24:15 -0500 Received: from smtp5.ctinetworks.com ([205.166.61.198]:51040) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tJyXN-0000T2-Gi for 74208@debbugs.gnu.org; Sat, 07 Dec 2024 12:24:14 -0500 X-ctinetworks-Watermark: 1734456252.96574@FwmBLrOS0Eu2McofbWje4A X-ctinetworks-Envelope-From: enometh@meer.net X-ctinetworks-SpamCheck: X-ctinetworks-VirusCheck: Found to be clean X-ctinetworks-Message-ID: C54822064ED3.A0875 Received: from localhost (unknown [117.254.36.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: enometh@meer.net) by smtp5.ctinetworks.com (Postfix) with ESMTPSA id C54822064ED3 for <74208@debbugs.gnu.org>; Sat, 7 Dec 2024 12:24:10 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp5.ctinetworks.com C54822064ED3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meer.net; s=ctidkims1; t=1733592251; bh=utPxiwjj5FugXxgjOHHU2aQV3HU1RHyDVQf/RJTQoEs=; h=Date:To:Subject:From:In-Reply-To:References:From; b=D+B0o21hcjt2vriU09oU4Ay8OSbZXGUJQJ/9FkpZqGEjIPzwJdOuOcxGoFFpvmy1w tEFOL9S7VkuP8J43yTPOJ7kvUKQhKsNRwSUgUacYp5VlseQafHhnoAg/JMIEYgbt2+ m0naOJw0mYHM2UHla24lipGf+IuOmm2zQLeLa0Fs= Date: Sat, 07 Dec 2024 22:53:57 +0530 (IST) Message-Id: <20241207.225357.658499983555480229.enometh@meer.net> To: 74208@debbugs.gnu.org Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly From: Madhu In-Reply-To: <8634izk7ky.fsf@gnu.org> References: <86v7wdjdyk.fsf@gnu.org> <8634izk7ky.fsf@gnu.org> X-Mailer: Mew version 6.9 on Emacs 31.0.50 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Score: 3.6 (+++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * Eli Zaretskii <8634izk7ky.fsf@gnu.org> Wrote on Sat, 07 Dec 2024 14:20:45 +0200 > Ping! Do we want to do anything about this issue? is "Keep it open" an option? :) call-process calls get_current_directory (which you exhibited) which in turn calls unhandled-file-name-directory, for which the documentation is Content analysis details: (3.6 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [205.166.61.198 listed in sa-trusted.bondedsender.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 3.6 RCVD_IN_SBL_CSS RBL: Received via a relay in Spamhaus SBL-CSS [117.254.36.43 listed in zen.spamhaus.org] 0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [205.166.61.198 listed in bl.score.senderscore.com] X-Debbugs-Envelope-To: 74208 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 2.6 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * Eli Zaretskii <8634izk7ky.fsf@gnu.org> Wrote on Sat, 07 Dec 2024 14:20:45 +0200 > Ping! Do we want to do anything about this issue? is "Keep it open" an option? :) call-process calls get_current_directory (which you exhibited) which in turn calls unhandled-file-name-directory, for which the documentation is Content analysis details: (2.6 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [205.166.61.198 listed in sa-accredit.habeas.com] 3.6 RCVD_IN_SBL_CSS RBL: Received via a relay in Spamhaus SBL-CSS [117.254.36.43 listed in zen.spamhaus.org] 0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [205.166.61.198 listed in bl.score.senderscore.com] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager * Eli Zaretskii <8634izk7ky.fsf@gnu.org> Wrote on Sat, 07 Dec 2024 14:20:45 +0200 > Ping! Do we want to do anything about this issue? is "Keep it open" an option? :) call-process calls get_current_directory (which you exhibited) which in turn calls unhandled-file-name-directory, for which the documentation is ``` "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/" call-process is bound to fail. 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. From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 07 13:28:06 2024 Received: (at 74208) by debbugs.gnu.org; 7 Dec 2024 18:28:06 +0000 Received: from localhost ([127.0.0.1]:48483 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tJzXC-0003mk-5C for submit@debbugs.gnu.org; Sat, 07 Dec 2024 13:28:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38360) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tJzXA-0003mE-2J for 74208@debbugs.gnu.org; Sat, 07 Dec 2024 13:28:04 -0500 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 1tJzX4-0002KL-Ln; Sat, 07 Dec 2024 13:27:58 -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=IlZK8iK7yPMvRtGL4ZiG5gVuqJMIFzEGPBlLS9UFLIE=; b=pDO8th/bcHSL c6it3uLSR+YEssy38Vfs4rT4cgokBwLH1YBjbiDo7AFxxgMpRvH+c7tag6IR1Oe9h7s/KQZTphPHE EDXpiG4+g+P1vaeMb8WZUkuzej5DjfpdYWVGFqFeT7n+RK8xs0ZAniEjsjiqNtV04kkS8I6TiwJao qHpujsVwVG1CW1RrtITSjE4krhjMtgbK37YdHY5MgFa/F8y1+Em1MYOmb98aEb47NRm8ShYfpI8rL bGAH73W3MG8CaLIKmdg2vO9kmcBeUyBKaSs8OTQeQGBRcKZhf9V5x/533aD9wC7CYT9RYrxqcrM/P HB9BNC0Tn824rTQpMh3mjQ==; Date: Sat, 07 Dec 2024 20:27:56 +0200 Message-Id: <86v7vvgxg3.fsf@gnu.org> From: Eli Zaretskii To: Madhu In-Reply-To: <20241207.225357.658499983555480229.enometh@meer.net> (message from Madhu on Sat, 07 Dec 2024 22:53:57 +0530 (IST)) Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly References: <86v7wdjdyk.fsf@gnu.org> <8634izk7ky.fsf@gnu.org> <20241207.225357.658499983555480229.enometh@meer.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74208 Cc: 74208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Sat, 07 Dec 2024 22:53:57 +0530 (IST) > From: Madhu > > * Eli Zaretskii <8634izk7ky.fsf@gnu.org> > Wrote on Sat, 07 Dec 2024 14:20:45 +0200 > > Ping! Do we want to do anything about this issue? > > is "Keep it open" an option? :) That is not a valid interpretation of "do something", not in my book. > (let ((default-directory "https://www.gnu.org/")) > (unhandled-file-name-directory default-directory)) > => "https://www.gnu.org/" Which is why I asked what, if anything, do we want to do about it. From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 08 03:46:50 2024 Received: (at 74208) by debbugs.gnu.org; 8 Dec 2024 08:46:50 +0000 Received: from localhost ([127.0.0.1]:49662 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKCwE-0004Ze-Am for submit@debbugs.gnu.org; Sun, 08 Dec 2024 03:46:50 -0500 Received: from mout.gmx.net ([212.227.15.15]:37021) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKCwA-0004ZK-Jl for 74208@debbugs.gnu.org; Sun, 08 Dec 2024 03:46:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1733647594; x=1734252394; i=michael.albinus@gmx.de; bh=EoOJftLe9Qr0XAjNfLA+5JVA4u7g1EtUYlgBp4mMhUI=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=uYKbg+JgaDwTQu8eSReen+1nHhn6JEMwGS7t2c59QvpVvXW/mxby/dxMDszJ4QD9 X3f+XP/JHDgiq6lHGkvkfopSlgVDrOd6gsA+vxX26hvZfHir9YJ4zWI6raLthIq9c ru73KTXrf/np3hHLIF+FFtf8xDlpcJ5Wnle2IpbzM6nNmNGOIa+7A5SGU0xBdVM/K inH0rgbye4yzlnVCD1t7fKsOCcl7hJk6PzuMikRHjez9q6QGD+FyCX6oP06ixdIl1 0ObB4FC9XDvVUWWeCJBKhGfVFs46iuNIDsDO6vy/arJ6cUWjXuwcBl77NBZIWTKCN JUUfeMBPfZ1SwuW5RA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from gandalf.gmx.de ([185.89.38.155]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N2E1M-1tmLae0CiM-00ybvK; Sun, 08 Dec 2024 09:46:34 +0100 From: Michael Albinus To: Madhu Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly In-Reply-To: <20241207.225357.658499983555480229.enometh@meer.net> (Madhu's message of "Sat, 07 Dec 2024 22:53:57 +0530 (IST)") References: <86v7wdjdyk.fsf@gnu.org> <8634izk7ky.fsf@gnu.org> <20241207.225357.658499983555480229.enometh@meer.net> Date: Sun, 08 Dec 2024 09:46:30 +0100 Message-ID: <87y10qv9y1.fsf@gmx.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:q33mwg43iJ1luU4isjeUYUQMTU9U7bSTNyke2Mmab47QkYfB4Tp khZufrle7bMXubThY3IAnw4kuffjtkzVmlhnsxIS96BZBi64XIb2IcY1YbygEvM1RzVuL4r EtDVDXpm/kVj1cK4KqKhsKbABqxd+0AYGoSix6FExV2/OlW/tJXwHXeuMlzo1oVMug3SCzH JwJnGBs6b4hRtfIMQDghg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:oaPUqR0bJ5I=;U0ci6z8ui/8B4688EDa2wMgtxEm Xsd1q0zBxpFQRG003liYSgeyj31r4uVKrzKD4tqS3cFVuEgPUuArHTBfFywSmvgp42+Zs5X+j X5h7v5ldVf2kZRhpJqckeLXzSJdqPmZ3BGqlxdhh+laWutiN5hFgttrK2D/T5h6+L5KdtalkJ fZIxR7DiJt2evMjNbaXcMknOiVLhEbajRoxw7pHQ4dM+0UJygQp5koF1ncES1AIzSC6lnNnGJ b7OqmVOuvtJQchkKWfyEROUUHDil4bW5DMdrOREj/MLtGm+tA/LeG/CVk15Zc+mTML2Feir2A BLKfjqVc+618B5EDoDgCB8BWudI38aJ2RecRMnQC21QpmG0MPP8H0JotFOktPeRFppdsRERgt aLKlIB2Bx/R43BrVBVuGVG1SR3dyNbsLsuxLGETKU+3nuiIOWz8fuV5K7wZwhwsUZQ76feGDk iyHnn6w1ytKbAme0WcMytrjRWPt+RporS0yZbyJ3CKJAyr2y3nqCc57l5y3yWC4UmfRLRaD5o FAR8LdXV2Nt41eUVRGB+BQtHRyFKq4G8LZ6lzwsi2wxPV761MgzsB34dm4c0q/87Ws4HMPlG9 lvSLHs8vg1on78dIRVC2LRNGExjWyOJQ7b1/z7xxK5IQB+idFIJFVxuWpprC0WVGCd3gl7h3X UPzGHwlQET9ZZRPEcbxOeXMswDenSmc23nSZkMvH2QmRfdIeYgnFbJJnVkT9cjuqSC1aAKaPl hXeZEmToMs8i31BMc5QYhVSafuZDAulBVJzALh53RjHsBf60BjlJzwXPKvg9+/k54EiXQgdIw m0u5bHw/UGw4CpiIxo7jn+9JsHaH7TtZutkBp6FrncABW3Dl+KrBTI0qkMr58jRy2Gr0AxzRS n5gPP6bit20fxWyIT6dCtRcWPoQivs0C48b4/h1P0Wz2a6yKbOP0LT5uHfhHPty6rcx0V1mw9 sPPb38SiwXvFY4yFisoMwOd3OJph2Jmmm4Kp3+At5VPm2gOYJYhLnH8Zq/PBX9e9wRisVDSFH 5vF/3H94o/Gqvqv3E4DOr0A17yz0fa2IQ2rLIScjuWLRV+P/gKB4DTouYy5tYgdZnJ9VfDkM/ vquRt2LnTtiSaUqx25LGnWM16wU8fB X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 74208 Cc: 74208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Madhu 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. From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 08 05:49:34 2024 Received: (at 74208) by debbugs.gnu.org; 8 Dec 2024 10:49:34 +0000 Received: from localhost ([127.0.0.1]:49795 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKEqz-0001ki-J4 for submit@debbugs.gnu.org; Sun, 08 Dec 2024 05:49:34 -0500 Received: from smtp5.ctinetworks.com ([205.166.61.198]:52024) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKEqx-0001kY-2y for 74208@debbugs.gnu.org; Sun, 08 Dec 2024 05:49:32 -0500 X-ctinetworks-Watermark: 1734518970.17476@ETkMAJs/VoRHqaHEiHHFPw X-ctinetworks-Envelope-From: enometh@meer.net X-ctinetworks-SpamCheck: X-ctinetworks-VirusCheck: Found to be clean X-ctinetworks-Message-ID: E444B2064ED0.A449C Received: from localhost (unknown [117.254.36.205]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: enometh@meer.net) by smtp5.ctinetworks.com (Postfix) with ESMTPSA id E444B2064ED0; Sun, 8 Dec 2024 05:49:27 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp5.ctinetworks.com E444B2064ED0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meer.net; s=ctidkims1; t=1733654968; bh=M4EykvIMH//cyB6ooigZwEvZof6ps5dyAy+rXqTi8xg=; h=Date:To:Cc:Subject:From:In-Reply-To:References:From; b=qf923CL0WWozTONkG4UEYWeqpCOyEYip7hL4gtBsBX/awXep2D5ZtULASG44DSJQJ et1qcZkVKGcVil3E4excjGjMTLa4VWt0RE0briYS4tYMkYoZCRuHwU3lQBlT9qn8mB vL4PKxW2o0jreJo8JqjfoxDVvHKEk+Vbe3MTJAkg= Date: Sun, 08 Dec 2024 16:19:24 +0530 (IST) Message-Id: <20241208.161924.1904937058365373006.enometh@meer.net> To: michael.albinus@gmx.de Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly From: Madhu In-Reply-To: <87y10qv9y1.fsf@gmx.de> References: <8634izk7ky.fsf@gnu.org> <20241207.225357.658499983555480229.enometh@meer.net> <87y10qv9y1.fsf@gmx.de> X-Mailer: Mew version 6.9 on Emacs 31.0.50 Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Sun_Dec__8_16_19_24_2024_543)--" Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 74208 Cc: 74208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) ----Next_Part(Sun_Dec__8_16_19_24_2024_543)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit * Michael Albinus <87y10qv9y1.fsf@gmx.de> Wrote on Sun, 08 Dec 2024 09:46:30 +0100 > > 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. Thanks, something like the attached? the implementation of "turn on url-handler-mode temporarily" looks a bit gross but i guess it can't be avoided. should call to turn it on be outside the minibuffer-setup-hook? --Regards, Madhu ----Next_Part(Sun_Dec__8_16_19_24_2024_543)-- Content-Type: Text/X-Patch; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="0001-minibuffer.el-read-file-name-default-handle-default-.patch" >From 91c22af6c317855370eb405f8daf6f56c68c4f9f Mon Sep 17 00:00:00 2001 From: Madhu Date: Tue, 5 Nov 2024 07:19:55 +0530 Subject: [PATCH] minibuffer.el: (read-file-name-default): handle default-directory urls * minibuffer.el: (read-file-name-default): bind default-directory (in dynamic scope) instead of modifying it, protect setting against non-local exits. Turn on url-handler-mode temporarily, so any calls to call-process and friends do not fail because the default-directory is a URL. (bug#24708) --- lisp/minibuffer.el | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index c970752ec2a..607a118dd53 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -3667,11 +3667,18 @@ read-file-name-default ;; just use `default-directory', but in order to avoid ;; changing `default-directory' in the current buffer, ;; we don't let-bind it. - (let ((dir (file-name-as-directory - (expand-file-name dir)))) + (let* ((dir (file-name-as-directory + (expand-file-name dir))) + (default-directory dir) + (orig-uhm url-handler-mode)) (minibuffer-with-setup-hook (lambda () - (setq default-directory dir) + ;; turn on url-handler-mode temporarily so + ;; call-process and friends don't fail on on a + ;; encountering a url default-directory + ;; (bug#74208) + (unless orig-uhm + (url-handler-mode 1)) ;; When the first default in `minibuffer-default' ;; duplicates initial input `insdef', ;; reset `minibuffer-default' to nil. @@ -3690,9 +3697,12 @@ read-file-name-default (window-buffer (minibuffer-selected-window)) (read-file-name--defaults dir initial)))) (set-syntax-table minibuffer-local-filename-syntax)) - (completing-read prompt 'read-file-name-internal - pred require-match insdef - 'file-name-history default-filename))) + (unwind-protect + (completing-read prompt 'read-file-name-internal + pred require-match insdef + 'file-name-history default-filename) + (unless orig-uhm + (url-handler-mode -1))))) ;; If DEFAULT-FILENAME not supplied and DIR contains ;; a file name, split it. (let ((file (file-name-nondirectory dir)) -- 2.46.0.27.gfa3b914457 ----Next_Part(Sun_Dec__8_16_19_24_2024_543)---- From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 08 06:33:29 2024 Received: (at 74208) by debbugs.gnu.org; 8 Dec 2024 11:33:29 +0000 Received: from localhost ([127.0.0.1]:49857 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKFXV-0003tt-Ed for submit@debbugs.gnu.org; Sun, 08 Dec 2024 06:33:29 -0500 Received: from mout.gmx.net ([212.227.15.19]:54453) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKFXS-0003tY-VW for 74208@debbugs.gnu.org; Sun, 08 Dec 2024 06:33:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1733657594; x=1734262394; i=michael.albinus@gmx.de; bh=WgOwj5x7rr9ENJ0kxpExuGj9peKprCJh5HsuWrplQMY=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=HEZKju+BiDwtfZcRIE4ZfNFFfI4iakY+iWp3QYc4toyuLylyEwypAGKoFShYXEdI KqSZNg/r9kD6GZrmU2Ek0rrvW2US0np6TSFSPEqEu5L6IvwJelI9dp9AM083bBagA UbE+1ghH65qHbN1xfmBJg1eKVck1P9q6VL8TQqWV6r5cmabjjtcJRx5bcZiUBX49Z ECV8cw8+BydtkB1d6oCPWtoMat+fBHiBgdZXD3J4bECbuPxCNl6ymDH/X1iz11KEr GUVdZx6BVTYyuEGP+JX28xK9PtW96Q63TErV5h1HyVFhjmLpi12vMeKYGf66WHs9q 4y1RGz+DT8dMNdfhIg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from gandalf.gmx.de ([185.89.38.155]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M9FjR-1tF2jd2j5z-00AKcS; Sun, 08 Dec 2024 12:33:14 +0100 From: Michael Albinus To: Madhu Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly In-Reply-To: <20241208.161924.1904937058365373006.enometh@meer.net> (Madhu's message of "Sun, 08 Dec 2024 16:19:24 +0530 (IST)") References: <8634izk7ky.fsf@gnu.org> <20241207.225357.658499983555480229.enometh@meer.net> <87y10qv9y1.fsf@gmx.de> <20241208.161924.1904937058365373006.enometh@meer.net> Date: Sun, 08 Dec 2024 12:33:13 +0100 Message-ID: <87seqyv286.fsf@gmx.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Provags-ID: V03:K1:BAjKjqZLHNkyKmiXE9YQNtxzCp4Ht5t4KfrUvjIdGU8SAZFvnwG U5ayVR+LtF91OXD14+fpuCpEb2VohG4o21HwS+UYR7exp8msOxRg4AlT3T/ylCXVPNEGC9d xDxI/8GwwUfNOzIHdhN87ObQs1GQIrcnMGYjfn9x+8cG8Ig+bMIPirbcW/YJ6/dLEJcstee k8uNl2a/f8AIg7bX1LdGA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:+ACkIXcmMbc=;eLDEZ+usVYCo1EydbCl9YNwfZvE WRtsBKf+cXFtAH/3h7tnJeNsV/txr7FE/ZH5Hx5hHMzvj102E/8O7zKKM4M7Ld/GCvg9QToI6 18WnmQ29lxfQR9VoHh8Ge51GVZ2yqDaAOxL2EApUq3XXlRp+OwgCRHio6+u8XToreiC1Znnyr Y0N7NADH865DLMceDO3iMNaSXp4KXMEljtpNP8P2U1avPCOyr6ekadjA2NRdjsh+tW8RNuZdW 77GrK9cRrirEaLWHtfC3aL1myPWYWsSFP3qvTZoDrIUiqsHsJccqgFooWLKwHyVUU32iTE2bX hjDjq/cj51qyzzZsbx9sFX8OsdMYJ6YINBsaHz9z+NRztwJBOslWaaUuomuo0v5NWy+PoHfFD L7bZk2qLCeHrZUheYtjKsObxJemtcWNTGrv9Tk0xDvwZcw/G4mq/5HXuOxp+QQQL/Y44jfsas fDqdgBQMP/jxmszb5ej9DheM8GMhoTZIlrZo3QRCq9WFjSqIsARhYn63JfDAulHuCuAVxueXz 4pBQIkysc4KOtyuEgon6tw6gsoiaI5/q4vMruCrUilqUjRX2bymmsQjlRteh4lNi5QwDTFKQz QAmXOz0RE8oFKo7uc2sz5vcc/abdQlV+NlQ7U/Fs/rQM5soBo6v5lmt04Ery2aRSHPWIwdVM/ FY8/KvIzDApl43mcfweyinNom5Sps+Q1k02KzlLUss9KmgZpkPUWlj79xNnr2zMie1pg9D8pE 5OSuupVJLy/f+tU+tQP1xeJcZetxcDVpZFMB3GmCPHd3SUmZZEs+QaC0l4d/t/nnfhQpSLeiS VpQyonwOUhDA2yI5W2tZO2d5bGd/8X85dtiNp2VrtVXb4jK2Wn1E0VMwi6u8FJgIHEBzs417v D0DBj2pxsN3Rtily8w76PBagE57SwZ2vgzNKUpAEotyr2Ui5CpNcESHWmvN+Z8JTnWzVpqJ82 xVTg7W+cQcbtY9Rwp6yVGjxudguvELFpa24OBssbrRCx3TcZLmxEtCigKwBJ0yFlJyGK5b+IZ yCAbCYpea1amIMh0DpRetpmurRIzbzPcca0OCb5tmHr1q8rsmTka4Sj4Jizsc9j8ZjrsMPP0V BMYubTvz+bCyaLbR0lQAdR/ojDSxa5 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 74208 Cc: 74208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain Madhu writes: Hi Madhu, > Thanks, something like the attached? the implementation of "turn on > url-handler-mode temporarily" looks a bit gross but i guess it can't > be avoided. should call to turn it on be outside the > minibuffer-setup-hook? Perhaps, I haven't tested. However, the leading comment doesn't match anymore the implementation (default-directory is let-bound now); better you'll adjust it. I've checked the problem in ffap.el. It looks like we could use a much simpler solution: implement unhandled-file-name-directory in ffap--url-file-handler. Something like --=-=-= Content-Type: text/x-patch Content-Disposition: inline Content-Transfer-Encoding: quoted-printable diff --git a/lisp/ffap.el b/lisp/ffap.el index 6a4915fb5a3..b03e625c123 100644 =2D-- a/lisp/ffap.el +++ b/lisp/ffap.el @@ -1512,6 +1512,7 @@ ffap--url-file-handler ;; We mainly just want to disable these bits: (substitute-in-file-name (car args)) (expand-file-name (car args)) + (unhandled-file-name-directory nil) (otherwise (apply operation args))))) --=-=-= Content-Type: text/plain Does this solve your problem? > --Regards, Madhu Best regards, Michael. --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 08 06:59:21 2024 Received: (at 74208) by debbugs.gnu.org; 8 Dec 2024 11:59:21 +0000 Received: from localhost ([127.0.0.1]:49879 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKFwW-000577-S0 for submit@debbugs.gnu.org; Sun, 08 Dec 2024 06:59:21 -0500 Received: from smtp5.ctinetworks.com ([205.166.61.198]:45808) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKFwV-00056z-9K for 74208@debbugs.gnu.org; Sun, 08 Dec 2024 06:59:20 -0500 X-ctinetworks-Watermark: 1734523155.76547@PjcVtVxRKsclfazAqWCj5g X-ctinetworks-Envelope-From: enometh@meer.net X-ctinetworks-SpamCheck: X-ctinetworks-VirusCheck: Found to be clean X-ctinetworks-Message-ID: 964442064ED0.A0EF5 Received: from localhost (unknown [117.254.36.205]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: enometh@meer.net) by smtp5.ctinetworks.com (Postfix) with ESMTPSA id 964442064ED0; Sun, 8 Dec 2024 06:59:12 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp5.ctinetworks.com 964442064ED0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meer.net; s=ctidkims1; t=1733659153; bh=3gAYN5+ttTFzJvgdiyn2C1ukqCkzq+ydcYjF+Uq8hIg=; h=Date:To:Cc:Subject:From:In-Reply-To:References:From; b=dJ1PNjUBU77oY9f5S8aBu4Gk3dgHVR8slYV6V4DlDOgItUTN1lz8GH6uxFr0ySA72 Wz+tWY0EwAyeK6ERrEIjZoXYrXL07CnUELA9UbRoWYD3xdDPVVBPyWrZQNAbyMThGj SU/qrvCkJVzD/JwV8atlfCwjhVYD5/10+pS6x5LE= Date: Sun, 08 Dec 2024 17:29:10 +0530 (IST) Message-Id: <20241208.172910.1771877886474437176.enometh@meer.net> To: michael.albinus@gmx.de Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly From: Madhu In-Reply-To: <87seqyv286.fsf@gmx.de> References: <87y10qv9y1.fsf@gmx.de> <20241208.161924.1904937058365373006.enometh@meer.net> <87seqyv286.fsf@gmx.de> X-Mailer: Mew version 6.9 on Emacs 31.0.50 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 74208 Cc: 74208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * Michael Albinus <87seqyv286.fsf@gmx.de> Wrote on Sun, 08 Dec 2024 12:33:13 +0100 > Perhaps, I haven't tested. However, the leading comment doesn't match > anymore the implementation (default-directory is let-bound now); better > you'll adjust it. No, that is an independent change in the patch, (which is still in the Subject: line, but not admittedly not relevant to the ffap fix.) > I've checked the problem in ffap.el. It looks like we could use a much > simpler solution: implement unhandled-file-name-directory in > ffap--url-file-handler. Something like In a quick test with the "M-! echo foo" (in a recursive minibuffer at the ffap prompt), call-shell-region still fails "Setting current directory" error, -- Regards, Madhu From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 08 10:14:04 2024 Received: (at 74208) by debbugs.gnu.org; 8 Dec 2024 15:14:04 +0000 Received: from localhost ([127.0.0.1]:51391 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKIyy-0006h6-Ee for submit@debbugs.gnu.org; Sun, 08 Dec 2024 10:14:04 -0500 Received: from mout.gmx.net ([212.227.17.20]:52395) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKIyw-0006gU-Al for 74208@debbugs.gnu.org; Sun, 08 Dec 2024 10:14:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1733670829; x=1734275629; i=michael.albinus@gmx.de; bh=Z0GHhJ+FHB9MzA61UrystWj8Su0Lc3Cbt/iLZVkcxMA=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=AKeE0uMLhka5LRZVhsf8oBBJrvMxLK32MbbdctOvfjVcgN00nYFrh99D/Ww/ks7I 8QuSDvN0mPHwhqmisjUAE3DclGoQs7DDo6qop4AOIETPpRGttBybIKht7r5QpHA73 DulV7FptfKi8h4Xx+kK9dsBYXQDgRyBIq4wP1zbzPyqtu9lgaTWV8fTALgJw5Ijez hVVd7XTlUaNPgUoi1bzKqx/Ux3n86u/tHTPdxMjx/6azxN1kj/xk2kB7qoQtYjyLf 24AGJQAbmUVAV/sL1LDhDnraxFn05inQyc8pFzjdy9ur17lTgCisPEs+xTLTcKNTN qYaXFT+GwrAvZ0U7IQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from gandalf.gmx.de ([185.89.38.155]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MHoNC-1tO63v2Piw-0075QQ; Sun, 08 Dec 2024 16:13:49 +0100 From: Michael Albinus To: Madhu Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly In-Reply-To: <20241208.172910.1771877886474437176.enometh@meer.net> (Madhu's message of "Sun, 08 Dec 2024 17:29:10 +0530 (IST)") References: <87y10qv9y1.fsf@gmx.de> <20241208.161924.1904937058365373006.enometh@meer.net> <87seqyv286.fsf@gmx.de> <20241208.172910.1771877886474437176.enometh@meer.net> Date: Sun, 08 Dec 2024 16:13:48 +0100 Message-ID: <87jzcaus0j.fsf@gmx.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Provags-ID: V03:K1:vEAJezcFULfebr6DacoTu/mPPXoSriK/58ndoQOM9Y/Ns8wndMN XN8OS+mwYTrHSED6RSYXn/tfENX2rLcE/RytWV2fGFCiF56L/VtqgovMHxtQTNJ1nN9g4kB W7SGE/Xv2uHT0usiigLwQy82CFcq5A3VJRI/iLXvIMYuWXvjbjjm+jsVMyv5+XtjXZur/5H tj8ja7Ka5+Kerek2eNz5A== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:8bdcbcDiSHo=;7BdpG/4OFaIFqGEE/1/lf3Rmz0s 7ELsiLbgOPVknuXQ6iMXBnMbqB6+N8Qzu1qcTrFbJ7e6ghATrsRGSkPIzJzodIsaBZfw8Onfg hBELve+UJ2+yPnPSOJNXldhb/0FC2WQG9qJ6BhGllll+SkmHWYIeEnFKtja8slltltvHgPXUA RuMBoK7In31cu68gVXEf70U9QBwWZQtrzQcRp/xkt8d8/FW0yBDlY4k6UGFw7jDeDhmuz2cqY rhngOy5Kmmi4vCe9X/hR/rn5Ir/WJrQNM+dvHOU89gWl/qJr1nf+fMjAGrldfYYy7kHWMQdNx 2CtsVe4ZZNJsTSz0Xmu6M7gofmoetBLK7xEq3sMlbFAB/gFpYqH1VvRfUWYLwNnSYJHCPrIVF AMaa4HaxR4UBU0qT1IHnloHUaOCFQe/YhaSPvdOjK5enb3gkJ67ZUcWvwyheUtmx/VNLUyytj io4PvL4aEV7Ud9iZseZLBC+209K8euc7ghoUKf4jf3ozITEi+V3d2rzNcBjYtS/duj+Z4YRSX 2fBrEt1IFuOcXQVFYZrSxNnwKRV77oYoTuNuGNNxTL414k1XDXjI/PK3VVGl9Hvbhl8u9Qmq6 soc5INXvzbzaNZs2g3npuYrjdjR1yG8NRgPJDCRmhkRjvzXo6nv7tLwDSkF/OTTS2wflwrmeB UqCRlRWPZPHBMRaA13anenNjlXe0IHDwq7UaGZfHqzcE51QP3Jpp/sYMEgLVQBDci6EJCU6Pd /hlvEHwLC3xtiE8GElMt+hIjuIjNfn5B24JEMdNIGmw99i7al1UiHX7koIdPzusXvDqN1Xu/C S1yujrm0s70FAt5/rRhHbq3sCaBz16iSq0m65ep7pRZVRDJ7xN3IQUgOWdOM3B0pbLXXU/7uJ b4LkuOOCyHJzCtqSL6Xy1/WbNF1aeq/A3aevHRDaMWgKErexLkDmU28qFSmzAJhe+D7LoSezG jFUQ00pPJ/IRMEOwdLwH25l9cpaRotdhVc4Ciq4BXpu++tDKaGLBYHhwp1BM2X8Hbgo3efZeu K1KHMhq2XfJFYOkGJ+xnruBaa4yJzV2C2qjYVaKwCKOkC+Jp0MHFwNPMtfLuVvc++wHEKijSH aOfGaluGeBze/8jrgP/0e7RkQhPBQy X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 74208 Cc: 74208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain Madhu writes: Hi Madhu, >> I've checked the problem in ffap.el. It looks like we could use a much >> simpler solution: implement unhandled-file-name-directory in >> ffap--url-file-handler. Something like > > In a quick test with the "M-! echo foo" (in a recursive minibuffer at > the ffap prompt), call-shell-region still fails "Setting current > directory" error, Indeed. The following patch seems to work better, could you pls test? --=-=-= Content-Type: text/x-patch Content-Disposition: inline Content-Transfer-Encoding: quoted-printable diff --git a/lisp/ffap.el b/lisp/ffap.el index 6a4915fb5a3..180fe408104 100644 =2D-- a/lisp/ffap.el +++ b/lisp/ffap.el @@ -1512,6 +1512,7 @@ ffap--url-file-handler ;; We mainly just want to disable these bits: (substitute-in-file-name (car args)) (expand-file-name (car args)) + (unhandled-file-name-directory temporary-file-directory) (otherwise (apply operation args))))) --=-=-= Content-Type: text/plain > -- Regards, Madhu Best regards, Michael. --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 08 11:27:04 2024 Received: (at 74208) by debbugs.gnu.org; 8 Dec 2024 16:27:04 +0000 Received: from localhost ([127.0.0.1]:51472 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKK7b-0001rE-Uq for submit@debbugs.gnu.org; Sun, 08 Dec 2024 11:27:04 -0500 Received: from smtp5.ctinetworks.com ([205.166.61.198]:53522) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKK7Z-0001qm-8l for 74208@debbugs.gnu.org; Sun, 08 Dec 2024 11:27:02 -0500 X-ctinetworks-Watermark: 1734539220.45541@Nn5EJ0U3xJIxRdA14fX+xA X-ctinetworks-Envelope-From: enometh@meer.net X-ctinetworks-SpamCheck: X-ctinetworks-VirusCheck: Found to be clean X-ctinetworks-Message-ID: 123782064ED3.A1E83 Received: from localhost (unknown [117.254.37.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: enometh@meer.net) by smtp5.ctinetworks.com (Postfix) with ESMTPSA id 123782064ED3; Sun, 8 Dec 2024 11:26:58 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp5.ctinetworks.com 123782064ED3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meer.net; s=ctidkims1; t=1733675219; bh=9DsOgHweAoMg0CBbM+kN+KkDb8P8n4tTFNVEWPd4Gxw=; h=Date:To:Cc:Subject:From:In-Reply-To:References:From; b=QXs0SHMJTrxIHvpJd5zM9GDn9MzTaSU3gaYQksOAG3iZOnttB7lbBRwI6rj94z0qw zSddPgLB2DMuuedt1gM3XQKxHqYHo1rZSE8TbXJCECOhJgpuEcvHFgl8OsmIlB4CxK jxJaeIWhSO9fbIrjZ1XHoD47gd3xLel9pPLGA84A= Date: Sun, 08 Dec 2024 21:56:57 +0530 (IST) Message-Id: <20241208.215657.808667871380904989.enometh@meer.net> To: michael.albinus@gmx.de Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly From: Madhu In-Reply-To: <87jzcaus0j.fsf@gmx.de> References: <87seqyv286.fsf@gmx.de> <20241208.172910.1771877886474437176.enometh@meer.net> <87jzcaus0j.fsf@gmx.de> X-Mailer: Mew version 6.9 on Emacs 31.0.50 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 74208 Cc: 74208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * Michael Albinus <87jzcaus0j.fsf@gmx.de> Wrote on Sun, 08 Dec 2024 16:13:48 +0100 > Madhu writes: >>> I've checked the problem in ffap.el. It looks like we could use a much >>> simpler solution: implement unhandled-file-name-directory in >>> ffap--url-file-handler. Something like >> >> In a quick test with the "M-! echo foo" (in a recursive minibuffer at >> the ffap prompt), call-shell-region still fails "Setting current >> directory" error, > > Indeed. The following patch seems to work better, could you pls test? Yes this works, M-! pwd prints /tmp while in the recursive minibuffer at the ffap prompt. This looks like the right solution to the problem but perhaps use "~" instead of /tmp in line with what the other code does. Thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 08 12:29:13 2024 Received: (at 74208) by debbugs.gnu.org; 8 Dec 2024 17:29:13 +0000 Received: from localhost ([127.0.0.1]:51563 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKL5l-0004qo-1o for submit@debbugs.gnu.org; Sun, 08 Dec 2024 12:29:13 -0500 Received: from mout.gmx.net ([212.227.15.18]:41821) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKL5j-0004qa-KE for 74208@debbugs.gnu.org; Sun, 08 Dec 2024 12:29:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1733678935; x=1734283735; i=michael.albinus@gmx.de; bh=G4zElcdfmn/Kx5YjPGGN5Es2WP7poAwtRS6/UaYLf+k=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=DWCkOUeA1czsxcmty+qOZklBDRimjs6OOEsMJsPKyse+VlgwzGIB16CUKb/DQuUP lMsaCRhwfkO4msnB0FIjY1YSosKt9i8EhyB8mQQmqH8TTK98RQUbBHwb+dgO1qbTO URF0XjHcyoH2H8F7aRTuIaFPklzAqDB26leHwqT0Wj3L5Rlpn2xXL9t7A1GB1sfct NLq8Q0ljQWNb2H0hfwP4oGH9GhD8IcXBHp0+kws51QTvnsosRTlMOUNIVeMWEvKAb dI5usmKOAhaqi1gsmbgDzv/0p3h87gVkOCZ8UgM8VicALfoj1zFQNEg3lwPsS9A// 7qrRLrEWSeo9nNEbkw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from gandalf.gmx.de ([185.89.38.155]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MgvrL-1tpoLq0iKL-00m9Bu; Sun, 08 Dec 2024 18:28:55 +0100 From: Michael Albinus To: Madhu Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly In-Reply-To: <20241208.215657.808667871380904989.enometh@meer.net> (Madhu's message of "Sun, 08 Dec 2024 21:56:57 +0530 (IST)") References: <87seqyv286.fsf@gmx.de> <20241208.172910.1771877886474437176.enometh@meer.net> <87jzcaus0j.fsf@gmx.de> <20241208.215657.808667871380904989.enometh@meer.net> Date: Sun, 08 Dec 2024 18:28:54 +0100 Message-ID: <87ed2iulrd.fsf@gmx.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:7fDelwt5/DyBRxGnnMYxb+LQ9qdM2kxnz8W6H1Ygnsf4oIrB+SD N8hQRdID9VYokHvz8bsk3GpOrqEYYDAmeLoz6IQDo8L5uSy/oixbjK0Xe+xKUZwTYt0UV9d mFZQvwTr0zaLybFxfLJ+em1Zlbnm5DXKJeShrJVYHgVN2LvSMxWmpgOmDHfIivZq2gPfk00 9R/k7WlY+eneadkBYD/zw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:aZk7/LYucGY=;bJ6SzfE9bMXxj7q0Xc2fNATaD2C v8mOcqGycAfCOxDSQ+rpzFblM8XcOlVzgrkdDqJ2Tb/swZmP2tDnnioTzT5In8OfiTE7bPv46 BS/FNubaBfEz6mQgUFCXxdptaOOX1dFeXK5g4NxAYT1aIAPLxjj1HqQoJfyimtyUDbZULADzk K45HLUG1+kM1jl1MMwNiHK+GMkUCzG0zeYt9YHxiLq0IfyAq3OwR7WG5CLgjPjlb5Gt/fsudc Yh7rjQ8MCbXfPNUN2BMTamer4ildbI7YSgLu2M9mGlXFbBEBXHaV4WER1Y33OkBnyuPg+WLRo gyB8wny7MVi8NcAkTvw8uFklYOfydDrTWPMUI51zjT5YQQtpnskZlojtjvtqS8ZYirTTjkSRt CHnkkbnqzdWVh8j7bfZ9BIl/Yv7D2Q/2+5ex3vh0wJcPp6q7QkZVnvunhWRRZJbtDEH19Sry5 G0Hc5LEQyQyIXbk4tG53StEfWqE9ab2ftv6TwiXKCj0LaX2jXhnlKyefRkfJt7WPivJ2bK9NN 1wc4ymVoptgBlIzZhZ02txjSA4qYFPmzksnr/O2cvioN6fEe0dxUTUjsQsc26ml5kv3mKupYG tmiOVZecaKEASNykh14LpMth9YGjBq1d7lqEnm4/j7Vi8me5OBuB1I2sOVqI4Q1MlBMhC+Y9f ev9OIXoTqPyROx5o4fXd95/3PNDC8Qu5oyCLFhGZJxbYyzRVPEuaF1eoncHERDrOSuwPEPuYG k9zn7uOkglIzBMdDEuYWAHzXa84QfkonmyUKh5DwaRN8dohc2gnZ5IyFh18Iy2ge+t7FvwD8m /amvgl2fEYZNx8Y6G/GbtSuyElAjp8r/kUz3OoqVcJiCB1+2rpkiq9hZubidHcNnJWvomfGmE G2pzjbS+qHw4eqw6FVFkligbNsX29yV1l+JjsTeML4BhXoVXqBB0eEpgZS27snp0ul4ZmufmB q8iR44c/14O8ltRbZV9GjPRcAe0BNenXjfGzM2uQRFs3L/FzoDUZelLQSzASACdyGD2P0/H78 CWohx9qPvvx4byQQGNi01RGESTch68HYz1bfEPxNpk3oo5642vJ/XXSurGyu6wfJysOihTLdC WdGgF4p0GlwWfb8/Lf4VcN8aNVdsY2 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 74208 Cc: 74208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Madhu writes: Hi Madhu, > Yes this works, M-! pwd prints /tmp while in the recursive minibuffer > at the ffap prompt. Thanks for the feedback. I've pushed the change to Emacs master. > This looks like the right solution to the problem but perhaps use "~" > instead of /tmp in line with what the other code does. Thanks No, it isn't guaranteed that the directory "~/" does exist, it depends on the external environment Emacs is called from. And likely, we would need to use (expand-file-name "~/"), which might be problematic when the default directory is a URL. Btw, I don't see any other use of "~/" in ffap.el. What do you mean with "what the other code does"? I didn't follow closely the bug discussion. Is there something left to be done, before closing? Best regards, Michael. From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 08 18:42:47 2024 Received: (at 74208) by debbugs.gnu.org; 8 Dec 2024 23:42:47 +0000 Received: from localhost ([127.0.0.1]:52026 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKQvH-0006oJ-DS for submit@debbugs.gnu.org; Sun, 08 Dec 2024 18:42:47 -0500 Received: from smtp5.ctinetworks.com ([205.166.61.198]:48850) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKQvF-0006o9-61 for 74208@debbugs.gnu.org; Sun, 08 Dec 2024 18:42:46 -0500 X-ctinetworks-Watermark: 1734565364.02561@UN6sl4xZwyokdY3zaV0ovA X-ctinetworks-Envelope-From: enometh@meer.net X-ctinetworks-SpamCheck: X-ctinetworks-VirusCheck: Found to be clean X-ctinetworks-Message-ID: ED0EB2064ED0.A491A Received: from localhost (unknown [117.254.36.132]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: enometh@meer.net) by smtp5.ctinetworks.com (Postfix) with ESMTPSA id ED0EB2064ED0; Sun, 8 Dec 2024 18:42:41 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp5.ctinetworks.com ED0EB2064ED0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meer.net; s=ctidkims1; t=1733701362; bh=V2CWKpw/KLRq0f4ceac9K1QIo6vgp/uE/kSvFeKnyG4=; h=Date:To:Cc:Subject:From:In-Reply-To:References:From; b=iE32TyVPz2VqX/xH5inIm1+UtuyDtClpU+KKBYlpI+N0fqtb8UFmkGTIjcYuKjAwN R0wBYavt1olBG+S6mHBNigy9mbiYXRKlILJqN1JmO5giupMJGlygeBuNmbQA9MqFj8 Ew2bG1vWbsuqX4EToj15np5a7ygjES4JNhq5H+tk= Date: Mon, 09 Dec 2024 05:12:40 +0530 (IST) Message-Id: <20241209.051240.1641477245108615749.enometh@meer.net> To: michael.albinus@gmx.de Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly From: Madhu In-Reply-To: <87ed2iulrd.fsf@gmx.de> References: <87jzcaus0j.fsf@gmx.de> <20241208.215657.808667871380904989.enometh@meer.net> <87ed2iulrd.fsf@gmx.de> X-Mailer: Mew version 6.9 on Emacs 31.0.50 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 74208 Cc: 74208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * Michael Albinus <87ed2iulrd.fsf@gmx.de> Wrote on Sun, 08 Dec 2024 18:28:54 +0100 >> This looks like the right solution to the problem but perhaps use "~" >> instead of /tmp in line with what the other code does. Thanks > > No, it isn't guaranteed that the directory "~/" does exist, it depends > on the external environment Emacs is called from. And likely, we would > need to use (expand-file-name "~/"), which might be problematic when the > default directory is a URL. > Btw, I don't see any other use of "~/" in ffap.el. What do you mean with > "what the other code does"? I meant the defaulting use in the call to get_current_directory in callproc.c > I didn't follow closely the bug discussion. Is there something left to > be done, before closing? Speaking for myself: no. I'm a bit dissapointed that the setq doesn't get fixed, but I think the main problem has been addressed. From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 09 03:17:39 2024 Received: (at 74208-done) by debbugs.gnu.org; 9 Dec 2024 08:17:40 +0000 Received: from localhost ([127.0.0.1]:52798 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKYxX-0006jZ-Eh for submit@debbugs.gnu.org; Mon, 09 Dec 2024 03:17:39 -0500 Received: from mout.gmx.net ([212.227.15.15]:50841) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKYxT-0006jE-VV for 74208-done@debbugs.gnu.org; Mon, 09 Dec 2024 03:17:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1733732246; x=1734337046; i=michael.albinus@gmx.de; bh=omP0mrXkt/0wPPJPIcC7MmGVwvkTfliY6zaopGs5SrY=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=WT4BUGlC4ElX8k9AGWqLN/Br6Af093goc6lAZHQad7HnyGStS7iZHyD+w/pexHMn RxcV0i9+a8i5H0pGen6oB0acO9NiTyR66edlsudBZYX0g6eN2rtHs9IkkXCoNOByt b9aTd05uo1W+ah46Pj8rvt59sP6uhJCFSvxpD3ooc7qYSy+SJS6MyNb0FxEi5qhkg AvrZ3EtnB9NRr2BHAhij/0NUOf4b4FdEX+jqEQhY0Ngp21leGoNFC7cpfaAZ8SRGm FZx45IFYNM6xrGGOWvRICIvJC07IZ53JDMdz4jTMR6FfDsNDIaNLQWW2tz1OdDJUX xRK8ocglS8UADMMe8A== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from gandalf.gmx.de ([185.89.38.155]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MVNAr-1tAPpp0KwB-00IXUG; Mon, 09 Dec 2024 09:17:26 +0100 From: Michael Albinus To: Madhu Subject: Re: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly In-Reply-To: <20241209.051240.1641477245108615749.enometh@meer.net> (Madhu's message of "Mon, 09 Dec 2024 05:12:40 +0530 (IST)") References: <87jzcaus0j.fsf@gmx.de> <20241208.215657.808667871380904989.enometh@meer.net> <87ed2iulrd.fsf@gmx.de> <20241209.051240.1641477245108615749.enometh@meer.net> Date: Mon, 09 Dec 2024 09:17:20 +0100 Message-ID: <878qspuv73.fsf@gmx.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:gB6MJuJUhABNxQQ27zTCrSYzgZzIK4DWKNZBiv7iHQqwEamROn1 P3e4djl/s/bUr10zeGJ0ZPuNo0WWGP2Rif7z90yqgAV466oMBNU//0rjMBdxZAcJaIPXQ17 rg9v7EHRKYo3IlI5aG2cZiCi+1+i2g7L0mu9u0teiH6UQkRoeaFrfzk3MBmDa5KQ7sUu1uJ Us9ISb7xn1zQ9Ginrl96Q== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:Tsulu/DyCRc=;Ns+Z5a4Xn1gJ3slhrwtyqyaslZi nCpxpfVKXUf6XMWbNd8SqL9PhTOzmQDP5e52aTD7K3exsiRbqSH+PtvPY9dJj2uq3tp7zy3OM C/Br5nB55p3vkygFlp5JhtdcLmP+kXtwqSR4yMHlWi1BAilQzxw0FWI4OOVSXVBH1jhOCjiZ1 DowZ15Uq73ZWZI/mg8hmcwoqM1Pm8OC9Is9gaMqZNlj8CnaLfAKY6EAG7a1LbUMXOoz6/Oflg ldlc7bb6gYQObiE2BnxIEb0nBGpkbQVmle2/rr8/3qJ6phuOQG7j/5nq0BC68qbgig0frEOVD O/ry9Or0EbQfk9fHKtRhaQ6GvEh8+HWQrgevZ3STVmUDiflYb5psoKfztgNCS5Ohxk5B0lU6p BBPRhb6PTkOGNxwqV7Pyhp1PmNPvL2td8dzsXJwFX4PX3opWJblyVzqYbGalBSUf06NYK7LjV xmNVzhdAoe+iw+KSeMp9jptriwff+mnwqVK1z+ClprMChhlz2VvDSihVOCi7kms2QZlEW7ta7 5s0zGcuYjRcwGtMzfobp2dzM5U1YUYmeyyjU77SBxGi8vJafGqGndYb69rxBC4xegzCyUzhmK lsLv6DYdLyN8u51pIL+nmh7Zy+90m3A4wHR3Ne5SVXAJZX1GyroYoICmHPNzuexWwWX5dECyu iE0w71iRayD3QvuSrbERYxIiVecofvrSByaKcIqQVTaaZZwHLlJncXFqY2i/WkRrNZALHzexH +AugcYMWuHbYi7xqT5uSQnBhhdtAV3cVBw4amezvuEbzQ9lOuk8SKDeHt3kRhheMM6bGPQ2dP VY+jEziB7iNg7c8DKRzzxwnJ3kJ4sL5MAO0lY1INZaYDbsWWPCgLtA57mVHFICfuWwFi+4gg8 MDfUzjk7nQXs1ywzeU539D0Ic+YyIEx6SIa+rtsbtwSYsmGFGBbPMUWKLerf4pGHfjVtuWshn PSBUp4btgma4lEfgvvuVVGg6KdJq7rjfy7IBnR7K5dZxRvllR27pdk0MflK7Umr+EBBhI48Mk iHIpc1xZwVtdJQeBp2m3EVLLmB/a5j96E70lZGYlbv4Aomog2D4JV/VYGWskONx/WugQQX0jB nhUCEiB+Ayi5wypzJxTVnOXKkTbCvf X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 74208-done Cc: 74208-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Version: 31.1 Madhu writes: Hi Madhu, > I meant the defaulting use in the call to get_current_directory in > callproc.c I see. But as said, it isn't a robust setting: --8<---------------cut here---------------start------------->8--- # env HOME=/foo emacs -Q --batch --eval '(let ((default-directory (expand-file-name "~"))) (shell-command "ls"))' Error: file-missing ("Setting current directory" "No such file or directory" "/foo") call-shell-region(1 1 "ls" nil #) shell-command-on-region(1 1 "ls" nil nil nil) shell-command("ls") (let ((default-directory (expand-file-name "~"))) (shell-command "ls")) eval((let ((default-directory (expand-file-name "~"))) (shell-command "ls")) t) command-line-1(("--eval" "(let ((default-directory (expand-file-name \"~\"))) (shell-command \"ls\"))")) command-line() normal-top-level() (Shell command failed with error) Setting current directory: No such file or directory, /foo --8<---------------cut here---------------end--------------->8--- > Speaking for myself: no. I'm a bit dissapointed that the setq doesn't > get fixed, but I think the main problem has been addressed. Thanks, so I'm closing the bug. Best regards, Michael. From unknown Sat Jun 14 03:55:40 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 06 Jan 2025 12:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator