From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#74208: 31.0.50; minibuffer read-file-name-default mutates global value of default-directory incorrectly Date: Sun, 10 Nov 2024 12:00:48 +0200 Message-ID: <86h68fl86n.fsf@gnu.org> References: <20241110.062700.1848871414792572122.enometh@meer.net> <86msi7ljb0.fsf@gnu.org> <20241110.123007.483734644166546380.enometh@meer.net> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40458"; mail-complaints-to="usenet@ciao.gmane.io" Cc: monnier@iro.umontreal.ca, 74208@debbugs.gnu.org To: Madhu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Nov 10 11:02:23 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tA4lz-000APr-Dp for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 10 Nov 2024 11:02:23 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tA4lh-0002Ip-0o; Sun, 10 Nov 2024 05:02:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tA4lf-0002IH-1r for bug-gnu-emacs@gnu.org; Sun, 10 Nov 2024 05:02:03 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tA4le-0004CR-On for bug-gnu-emacs@gnu.org; Sun, 10 Nov 2024 05:02:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=Jw1NPd0VHdXw93cxM7FR2EQp3ZTVzHiro+Vr4TRKZtU=; b=Vvu2rw4pll/UWcSUZZZtOJwcou5wmpMnNntBDDbQuJxnyk3BhXEwCWRztjxMJVhTLfPducoFKUmJqFYSU4yyeIX7u+hZ1prjxeaGYmaVz5DNq8XzA2ohyXEPYAm9ooe4OyEN6AQ3HacRzlY8HVaeZFxejzok/vw2rJeZ3yN3LGU/MOlvT69AZOqPmujDMIIwHPmgxL6xHepWMud1QruJVHPPVY1qk88pNGw5aLaeN6CIz0JliV64o0emw4mpKzHVvl8THzfDh4qcg4jliU3dWUyMdkLxcaSFAyQWoOnXhsHrmMP7L6IOub2E+jM78/PD90C1jSyvKSUQvOhSWgr6kw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tA4le-0000le-Hx for bug-gnu-emacs@gnu.org; Sun, 10 Nov 2024 05:02:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 10 Nov 2024 10:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74208 X-GNU-PR-Package: emacs Original-Received: via spool by 74208-submit@debbugs.gnu.org id=B74208.17312328702865 (code B ref 74208); Sun, 10 Nov 2024 10:02:02 +0000 Original-Received: (at 74208) by debbugs.gnu.org; 10 Nov 2024 10:01:10 +0000 Original-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 Original-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 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 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==; In-Reply-To: <20241110.123007.483734644166546380.enometh@meer.net> (message from Madhu on Sun, 10 Nov 2024 12:30:07 +0530 (IST)) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:295173 Archived-At: > 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.