From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: "Ryan C. Thompson" Newsgroups: gmane.emacs.bugs Subject: bug#19412: 24.3; ido-write-file sometimes writes to a different directory than, it says it will Date: Sun, 3 Nov 2019 14:48:15 -0800 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="265294"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 To: 19412@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Nov 03 23:49:18 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iROgP-0016qV-BF for geb-bug-gnu-emacs@m.gmane.org; Sun, 03 Nov 2019 23:49:17 +0100 Original-Received: from localhost ([::1]:56776 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iROgN-0005Nl-OE for geb-bug-gnu-emacs@m.gmane.org; Sun, 03 Nov 2019 17:49:15 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35342) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iROgC-0005Nc-6J for bug-gnu-emacs@gnu.org; Sun, 03 Nov 2019 17:49:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iROgB-0002Ai-31 for bug-gnu-emacs@gnu.org; Sun, 03 Nov 2019 17:49:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55052) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iROgA-0002AY-Le for bug-gnu-emacs@gnu.org; Sun, 03 Nov 2019 17:49:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iROgA-0007q0-Hk for bug-gnu-emacs@gnu.org; Sun, 03 Nov 2019 17:49:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: "Ryan C. Thompson" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 03 Nov 2019 22:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19412 X-GNU-PR-Package: emacs Original-Received: via spool by 19412-submit@debbugs.gnu.org id=B19412.157282130830068 (code B ref 19412); Sun, 03 Nov 2019 22:49:02 +0000 Original-Received: (at 19412) by debbugs.gnu.org; 3 Nov 2019 22:48:28 +0000 Original-Received: from localhost ([127.0.0.1]:35640 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iROfc-0007ou-8O for submit@debbugs.gnu.org; Sun, 03 Nov 2019 17:48:28 -0500 Original-Received: from mail-pf1-f182.google.com ([209.85.210.182]:42168) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iROfa-0007oh-9k for 19412@debbugs.gnu.org; Sun, 03 Nov 2019 17:48:26 -0500 Original-Received: by mail-pf1-f182.google.com with SMTP id s5so2616394pfh.9 for <19412@debbugs.gnu.org>; Sun, 03 Nov 2019 14:48:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thompsonclan-org.20150623.gappssmtp.com; s=20150623; h=to:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language; bh=GiQ14+TiP285QolC7H+4lpByXuCRSIn9B3gWzMbchX4=; b=OK9OC2xZA3Ocg3MpErQD5wPF1/+WGXwGBPXnm9qoS43Hws22ikGoiDaHb8AhEsdFEa OMARrzeiGzsHRqjkX2sKMftNdpdaH5D7klMOcwGoFAwOhtO9a+yIH/3gt5FQ8QrzpK/S ESaO9BSvh5tTSYZ+0EhqnJtkbg8YxpGE3gui/ldlv5S41QARu8Wf4zKEqgcnrEF8Ihpx 3aE8xudW6fRQ7g0RI8TQhkbl0soONJ5iVHX0df0kNaTExjZAgVMlt6dMSIwyj//lrmBG P5fBIFVEP3blP36cHqaJnJJMmRIyY+F6m/UA1GW1RRhHniXEWtDn8aSX4GJhFvm1kpKB 6SFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding:content-language; bh=GiQ14+TiP285QolC7H+4lpByXuCRSIn9B3gWzMbchX4=; b=hu9eiuCQTNqvBajJ/Hah4S3sC2wCCEnGax3wXjwg21YWdh1rIoJsptlXo8nTDILWKT GS1JpOlV5Z278xja/JwTJ2WN9ObD+IexOpR+Z+DOS7d0/2SlXiTr2TPpOCAYQJs3p37C grjPfZI/2wCG52Ss5Xs8ZekMtPY7EmxT5vN5jSaqxaCUReB0P/NCIDSsxQ6eCJw89H0S p9FnOHlDPPGlp1w5YmtkYSFjd8ewPh3qWmgB/av0sH5jT6p/tuh3PqK6YAVEcuiWud90 V3IiM6Rws8kuFjkVvxYLoXWYqUk65kO2y2Hc0z/MfLKZMWKTL8HUCiMu96Rq58Gfxuac wcGw== X-Gm-Message-State: APjAAAWZVH09k4a5CBXPaxuMHleqU5rvd/lhmXW5fW1Yqq6On0uMYjtA VJIAM+4Mlxl5GYphKT+51BuAdrrIIyY= X-Google-Smtp-Source: APXvYqwVWBW+IAHtn8XdSDtM5OgYW4r6PG1+uBFAcNeNtY6Irn88BXwGYQdpxH8BTRtyI+MIFmN2sA== X-Received: by 2002:a63:7158:: with SMTP id b24mr26439200pgn.153.1572821299591; Sun, 03 Nov 2019 14:48:19 -0800 (PST) Original-Received: from urania.lan ([209.134.95.37]) by smtp.gmail.com with ESMTPSA id y8sm5097404pfl.8.2019.11.03.14.48.17 for <19412@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Nov 2019 14:48:18 -0800 (PST) Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:170907 Archived-At: I believe I have discovered the cause of this bug. It can be reproduced by evaluating the following code and then hitting RET: (read-file-name-default "Write file: " "/tmp/" "~/mumble.frotz" nil nil nil) This will return "~/mumble.frotz" rather than "/tmp/". Ido triggers this issue by causing "read-file-name-default" to be called with arguments like the above when triggered to fall back to non-ido completion as described in the inital report. The crux of the issue is that the initial directory, "/tmp/", is treated as *not* user-entered, so pressing RET on it returns the default filename instead (which is populated from the buffer file name). This is not trivial to fix, because ido isn't calling "read-file-name-default" directly. In the example given, it's let-binding "default-directory" to "/tmp/" and then doing: (call-interactively 'write-file) And then the interactive form calls: (read-file-name "Write file: ") which then picks up DIR and DEFAULT-FILENAME from "default-directory" and "buffer-file-name" respectively. So this isn't a case of just fixing a function call somewhere. One possible solution would be to also let-bind "buffer-file-name" to nil, in which case DEFAULT-FILENAME gets set to DIR. That would work for the case of "write-file", but I don't know if it would work for other functions that read file names. Lastly, I'm guessing that the original reporter ran into this issue because they were using C-f RET to select "/tmp/" within ido completion, since RET would just select the first file or subdirectory on the list. They should be using C-j to do that. I might add a hack to my ido-completing-read-plus package to fix this edge case, if I can figure out a reasonably clean way to fix it.