From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 22 17:20:33 2025 Received: (at submit) by debbugs.gnu.org; 22 Aug 2025 21:20:33 +0000 Received: from localhost ([127.0.0.1]:37799 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1upZBY-0001gc-T8 for submit@debbugs.gnu.org; Fri, 22 Aug 2025 17:20:33 -0400 Received: from lists.gnu.org ([2001:470:142::17]:33874) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1upZBV-0001gJ-CI for submit@debbugs.gnu.org; Fri, 22 Aug 2025 17:20:30 -0400 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 1upZBO-00077y-P3 for bug-gnu-emacs@gnu.org; Fri, 22 Aug 2025 17:20:23 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1upZBJ-0001fN-VT for bug-gnu-emacs@gnu.org; Fri, 22 Aug 2025 17:20:22 -0400 From: Spencer Baugh To: bug-gnu-emacs@gnu.org Subject: [PATCH] Pass dired default filenames via defaults argument X-Debbugs-Cc: Juri Linkov Date: Fri, 22 Aug 2025 17:20:13 -0400 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1755897613; bh=sLeywCijmHWY6JhLJmTIs355v6Ndj0NnOYzfCpxg3EE=; h=From:To:Subject:Date; b=H+u3CVNu8aVAqwtGLC/mvKSMobm63AU18MsgN2lCodRbQ7RIIucVUaNLHx5lHqarE 3Ay4nWdGkAU8ZPcgWxelA1Ke1mqmgeR3zLqDAgHM0CXlNWw810aClEmvtTXF5x6VqO eE8jdRfybKufP+yALkqDMJKN/v/Q+FFy34Sc8SJj6BDaOEmHr5NusgtXp1xQKhRy2I QdABOI4+VS78ZGaSAiAyshNDQyuwv5Qi+jDV/NUEb7XRAkS3OCYFIHJawxdWrKJwe+ GBlUKl64fmHx4P+tTsCt4DLXZ/eaUR3nqYy+9f3fTrhBOHEHdtiXAMeWCor7HU3ySc iT2MaigvIF0iA== Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@janestreet.com; helo=mxout5.mail.janestreet.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 0.9 (/) 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: -0.1 (/) --=-=-= Content-Type: text/plain Tags: patch Rather than using minibuffer-with-setup-hook and minibuffer-default-add-function, just pass the list of default file names as a regular argument to read-file-name. This behaves better with various customizations, and also allows the normal abbreviate-file-name logic in read-file-name to run. In GNU Emacs 30.1.90 (build 9, x86_64-pc-linux-gnu, X toolkit, cairo version 1.15.12, Xaw scroll bars) of 2025-08-14 built on igm-qws-u22796a Repository revision: 6adc26ffa74aedbd1cfa9a1ee72073ebccea2b96 Repository branch: emacs-30 Windowing system distributor 'The X.Org Foundation', version 11.0.12101016 System Description: Rocky Linux 8.10 (Green Obsidian) Configured using: 'configure --with-x-toolkit=lucid --without-gpm --without-gconf --without-selinux --without-imagemagick --with-modules --with-gif=no --with-cairo --with-rsvg --without-compress-install --with-tree-sitter --with-native-compilation=aot PKG_CONFIG_PATH=/usr/local/home/garnish/libtree-sitter/0.22.6-1/lib/pkgconfig/' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Pass-dired-default-filenames-via-defaults-argument.patch >From d031ccb5df9984930cf6e5bd06fa1ed572ff6359 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Fri, 22 Aug 2025 17:19:09 -0400 Subject: [PATCH] Pass dired default filenames via defaults argument Rather than using minibuffer-with-setup-hook and minibuffer-default-add-function, just pass the list of default file names as a regular argument to read-file-name. This behaves better with various customizations, and also allows the normal abbreviate-file-name logic in read-file-name to run. * lisp/dired-aux.el (dired-do-create-files): Pass default file names as an argument. --- lisp/dired-aux.el | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 049d200f590..92513b8c72f 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -2673,22 +2673,18 @@ dired-do-create-files (expand-file-name (file-name-nondirectory (car fn-list)) target-dir))) - (defaults (dired-dwim-target-defaults fn-list target-dir)) + (defaults (cons default (dired-dwim-target-defaults fn-list target-dir))) (target (expand-file-name ; fluid variable inside dired-create-files - (minibuffer-with-setup-hook - (lambda () - (setq-local minibuffer-default-add-function nil) - (setq minibuffer-default defaults)) - (dired-mark-read-file-name - (format "%s %%s %s: " - (if dired-one-file op1 operation) - (if (memq op-symbol '(symlink hardlink)) - ;; Linking operations create links - ;; from the prompted file name; the - ;; other operations copy (etc) to the - ;; prompted file name. - "from" "to")) - target-dir op-symbol arg rfn-list default)))) + (dired-mark-read-file-name + (format "%s %%s %s: " + (if dired-one-file op1 operation) + (if (memq op-symbol '(symlink hardlink)) + ;; Linking operations create links + ;; from the prompted file name; the + ;; other operations copy (etc) to the + ;; prompted file name. + "from" "to")) + target-dir op-symbol arg rfn-list defaults))) (into-dir (progn (when -- 2.43.7 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 23 03:02:59 2025 Received: (at 79293) by debbugs.gnu.org; 23 Aug 2025 07:02:59 +0000 Received: from localhost ([127.0.0.1]:38523 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1upiHC-0003mM-Qi for submit@debbugs.gnu.org; Sat, 23 Aug 2025 03:02:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52696) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1upiHA-0003m6-As for 79293@debbugs.gnu.org; Sat, 23 Aug 2025 03:02:56 -0400 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 1upiH4-0006KG-KT; Sat, 23 Aug 2025 03:02:50 -0400 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=EAM+wyqudTJI9kgJnDcZDORUbeahIMvF/9dNhh/lQJs=; b=fkkI9u2TtI4V MyFSqzdmdBnd6lGCgpde10NMPYKL5GEMJ11Lzp1JabLhxStypGcKWBoPnQgArX5gP6AJXrju1F4uG R75HUWjfasI9LBLC+qzuAZUI3de4H2HQemOvSzSPyuqls/MV8P86yodfHpK1BsVrVKEFGncHX+9jq NMjEyJysu7z/3eYVYxtMlbE4Q3NopamokvoCQxW/BjX4b8UN+Fvo3i3Fs+wIXrk72K6Z7kZjulAYc 3BqyBf2/8+tBTrW3xuf1TqG9mHaeJa9asSmGAp9QKIv1wJYjBx2HI4iqYDcjrbjM7dNxmCBTK7w3O 9zLHpceim0/573syrJGPXg==; Date: Sat, 23 Aug 2025 10:02:47 +0300 Message-Id: <86bjo6cyg8.fsf@gnu.org> From: Eli Zaretskii To: Spencer Baugh In-Reply-To: (bug-gnu-emacs@gnu.org) Subject: Re: bug#79293: [PATCH] Pass dired default filenames via defaults argument References: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79293 Cc: 79293@debbugs.gnu.org, juri@linkov.net 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: Juri Linkov > Date: Fri, 22 Aug 2025 17:20:13 -0400 > From: Spencer Baugh via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > Rather than using minibuffer-with-setup-hook and > minibuffer-default-add-function, just pass the list of default > file names as a regular argument to read-file-name. This > behaves better with various customizations, and also allows the > normal abbreviate-file-name logic in read-file-name to run. "Behaves better" in what sense? Would you please show examples of commands where the patched version behaves better, including the effect of the abbreviate-file-name logic? Because from your OP it is unclear to me what, if any, will be the user-facing effects of the new behavior in the relevant Dired commands. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 23 10:40:27 2025 Received: (at 79293) by debbugs.gnu.org; 23 Aug 2025 14:40:27 +0000 Received: from localhost ([127.0.0.1]:41302 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uppPu-0003eZ-SO for submit@debbugs.gnu.org; Sat, 23 Aug 2025 10:40:27 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:42455) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uppPr-0003eG-50 for 79293@debbugs.gnu.org; Sat, 23 Aug 2025 10:40:24 -0400 From: Spencer Baugh To: Eli Zaretskii Subject: Re: bug#79293: [PATCH] Pass dired default filenames via defaults argument In-Reply-To: <86bjo6cyg8.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 23 Aug 2025 10:02:47 +0300") References: <86bjo6cyg8.fsf@gnu.org> Date: Sat, 23 Aug 2025 10:40:17 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1755960017; bh=WKULwfm5qFLdB3JVA16Zqhazyizyr/CKx3iqQ1K385w=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=aJFdazDB1ShQQBAVLTVfxt9TZ4yt8U+ErXmMniZo2W/DHFvwfCNZgkIEFL8v4IgSC 6SKFicFhgTCozmRIPZTMSUwOLRsG3u1ptdPohLxN4/mfn4pevZuRP1uE+QFjEHs/Mj uGW9bpCOEGkg8KiRXerBD74mrcAhO9J2LW2GcXtyRHkRlgsI6OwJ4TdPYI/2D2ZW51 2GMhiYaTSoWA+5PiqQoakNsTVPf0EojZCHW1S/1OKixuufugQBnGcRiHrHwwO5fqjk SwyOUoOdzCr05LtQE7g/ZUNGm4TpgbSKkg6YxTFx1HDM/66uOdnPZdSDSkLium43wd /PqIUqqhcJhEQ== X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79293 Cc: 79293@debbugs.gnu.org, juri@linkov.net 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 (---) --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> Cc: Juri Linkov >> Date: Fri, 22 Aug 2025 17:20:13 -0400 >> From: Spencer Baugh via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" >> >> Rather than using minibuffer-with-setup-hook and >> minibuffer-default-add-function, just pass the list of default >> file names as a regular argument to read-file-name. This >> behaves better with various customizations, and also allows the >> normal abbreviate-file-name logic in read-file-name to run. > > "Behaves better" in what sense? > > Would you please show examples of commands where the patched version > behaves better, including the effect of the abbreviate-file-name > logic? Because from your OP it is unclear to me what, if any, will be > the user-facing effects of the new behavior in the relevant Dired > commands. Both before and after my change: 1. M-: (read-file-name ":" nil (expand-file-name "~")) 2. M-n 3. Observe ~/ in the minibuffer This is because read-file-name calls abbreviate-file-name on the default argument. Before my change: 1. C-x C-f ~/ 2. R (or Y or H) 3. M-n 4. Observe the minibuffer starts with /home/user After my change: 1. C-x C-f ~/ 2. R (or Y or H) 3. M-n 4. Observe the minibuffer starts with ~/ as usual for read-file-name Juri may also have some comments about why the code was written in this way, as the original author of both this code and other code in dired which uses minibuffer-with-setup-hook. Also, attached is an updated version of the patch which reflects the fact that the "default" variable actually was unused before, only "defaults" was used. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Pass-dired-default-filenames-via-defaults-argument.patch >From 7e28da2ef1de05d8de46eee7605c8346753406fd Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Fri, 22 Aug 2025 17:19:09 -0400 Subject: [PATCH] Pass dired default filenames via defaults argument Rather than using minibuffer-with-setup-hook, just pass the list of default file names as a regular argument to read-file-name. This allows read-file-name to run abbreviate-file-name on the defaults as it normally does, instead of the defaults appearing in expanded form. * lisp/dired-aux.el (dired-do-create-files): Pass default file names as an argument. (bug#79293) --- lisp/dired-aux.el | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 049d200f590..0f9d28ad7ed 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -2668,17 +2668,12 @@ dired-do-create-files (dired-one-file ; fluid variable inside dired-create-files (and (consp fn-list) (null (cdr fn-list)) (car fn-list))) (target-dir (dired-dwim-target-directory)) - (default (and dired-one-file - (not dired-dwim-target) ; Bug#25609 - (expand-file-name (file-name-nondirectory - (car fn-list)) - target-dir))) (defaults (dired-dwim-target-defaults fn-list target-dir)) (target (expand-file-name ; fluid variable inside dired-create-files (minibuffer-with-setup-hook (lambda () - (setq-local minibuffer-default-add-function nil) - (setq minibuffer-default defaults)) + ;; Don't run `read-file-name--defaults' + (setq-local minibuffer-default-add-function nil)) (dired-mark-read-file-name (format "%s %%s %s: " (if dired-one-file op1 operation) @@ -2688,7 +2683,7 @@ dired-do-create-files ;; other operations copy (etc) to the ;; prompted file name. "from" "to")) - target-dir op-symbol arg rfn-list default)))) + target-dir op-symbol arg rfn-list defaults)))) (into-dir (progn (when -- 2.43.7 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 23 10:44:53 2025 Received: (at 79293) by debbugs.gnu.org; 23 Aug 2025 14:44:53 +0000 Received: from localhost ([127.0.0.1]:41307 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uppUD-0003mM-2j for submit@debbugs.gnu.org; Sat, 23 Aug 2025 10:44:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39192) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uppUA-0003m7-Fm for 79293@debbugs.gnu.org; Sat, 23 Aug 2025 10:44:51 -0400 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 1uppU4-0007yX-9A; Sat, 23 Aug 2025 10:44:44 -0400 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=OCXn1itzxEmDIN3wzEm3QwhlQhy2Gc7eQ34GHtcAQaI=; b=qvfm9aBQIFW+ c8lC+KJpmsOgm2wBc37DMsu4RnEAUyimEstFWFdfv791pZd728NGZE8iUxxdj0oAnetcRjk8HgDks 0BN6P/G8d82tZyf2EowLfFGGO4g7uZ0OuUUO89xVDpkiFSZpw67Qx9eDgvvej8OD6mRfPhsYe3fY4 AZhNSlpTb70ciO3ayHAe63sEY1m6t5Kpw+78BoUxXt1TpXreqMNyIpmClQdgR3RohSLAMCDxTtLl0 jDR6EZ1znwuvIBMZTDwmXMRKChv+JCFyepita7SFkvVwxAWgAf+TQYssk+c6TzO+gd/NjIOchi8bg ToW3+tsHEM1WlitEHq1FvQ==; Date: Sat, 23 Aug 2025 17:44:41 +0300 Message-Id: <86ikie9jxi.fsf@gnu.org> From: Eli Zaretskii To: Spencer Baugh In-Reply-To: (message from Spencer Baugh on Sat, 23 Aug 2025 10:40:17 -0400) Subject: Re: bug#79293: [PATCH] Pass dired default filenames via defaults argument References: <86bjo6cyg8.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79293 Cc: 79293@debbugs.gnu.org, juri@linkov.net 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: Spencer Baugh > Cc: 79293@debbugs.gnu.org, juri@linkov.net > Date: Sat, 23 Aug 2025 10:40:17 -0400 > > Eli Zaretskii writes: > >> Cc: Juri Linkov > >> Date: Fri, 22 Aug 2025 17:20:13 -0400 > >> From: Spencer Baugh via "Bug reports for GNU Emacs, > >> the Swiss army knife of text editors" > >> > >> Rather than using minibuffer-with-setup-hook and > >> minibuffer-default-add-function, just pass the list of default > >> file names as a regular argument to read-file-name. This > >> behaves better with various customizations, and also allows the > >> normal abbreviate-file-name logic in read-file-name to run. > > > > "Behaves better" in what sense? > > > > Would you please show examples of commands where the patched version > > behaves better, including the effect of the abbreviate-file-name > > logic? Because from your OP it is unclear to me what, if any, will be > > the user-facing effects of the new behavior in the relevant Dired > > commands. > > Both before and after my change: > > 1. M-: (read-file-name ":" nil (expand-file-name "~")) > 2. M-n > 3. Observe ~/ in the minibuffer > > This is because read-file-name calls abbreviate-file-name on the default > argument. > > Before my change: > > 1. C-x C-f ~/ > 2. R (or Y or H) > 3. M-n > 4. Observe the minibuffer starts with /home/user > > After my change: > > 1. C-x C-f ~/ > 2. R (or Y or H) > 3. M-n > 4. Observe the minibuffer starts with ~/ as usual for read-file-name So abbreviate-file-name is the only improvement provided by your patch? Your OP seemed to imply that there were others: > Rather than using minibuffer-with-setup-hook and > minibuffer-default-add-function, just pass the list of default > file names as a regular argument to read-file-name. This > behaves better with various customizations, and also allows the > normal abbreviate-file-name logic in read-file-name to run. From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 23 10:53:05 2025 Received: (at 79293) by debbugs.gnu.org; 23 Aug 2025 14:53:05 +0000 Received: from localhost ([127.0.0.1]:41325 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uppc8-0004D5-JG for submit@debbugs.gnu.org; Sat, 23 Aug 2025 10:53:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55230) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uppc5-0004CY-QQ for 79293@debbugs.gnu.org; Sat, 23 Aug 2025 10:53:02 -0400 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 1uppbz-0000og-VY; Sat, 23 Aug 2025 10:52:55 -0400 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=RGH6g7TAD0dnqzC+KqiV+NsvZ7Q/R66ijLvRzVXtsYg=; b=k/hwik9MkxOX BjtYtD2Yw/VQqmT26WQc8ia/OU2Gfaotaq2zFDs4LQrQpSU6TbJ0IUPCKNmd6geUkjWlQ/WMBM10p qShtll1UsjPIJ1o7NDKeKfhaKorNLhu4+sEAZdASoZT701w5VvVUEjau5GUPimjOPq2bHJ66Q9H8H aHSbbk2ts256Gm0HkrwN9RwL+55fV/QX6BWFslbWn+L8nZ7cg7MG64F/c/BnsLhGw1gUob0hLICNB PHwEdnnN7rF4nw5P6e5c2mMsW04aDVrCZK4158ypUWbGawYheYGZvyOBTxR1heWv+zvo2SpgNSFUG 5KjqVEqVTWHBJnq1Ywo6UQ==; Date: Sat, 23 Aug 2025 17:52:53 +0300 Message-Id: <86ect29jju.fsf@gnu.org> From: Eli Zaretskii To: sbaugh@janestreet.com In-Reply-To: <86ikie9jxi.fsf@gnu.org> (message from Eli Zaretskii on Sat, 23 Aug 2025 17:44:41 +0300) Subject: Re: bug#79293: [PATCH] Pass dired default filenames via defaults argument References: <86bjo6cyg8.fsf@gnu.org> <86ikie9jxi.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79293 Cc: 79293@debbugs.gnu.org, juri@linkov.net 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: 79293@debbugs.gnu.org, juri@linkov.net > Date: Sat, 23 Aug 2025 17:44:41 +0300 > From: Eli Zaretskii > > > From: Spencer Baugh > > Cc: 79293@debbugs.gnu.org, juri@linkov.net > > Date: Sat, 23 Aug 2025 10:40:17 -0400 > > > > Eli Zaretskii writes: > > >> Cc: Juri Linkov > > >> Date: Fri, 22 Aug 2025 17:20:13 -0400 > > >> From: Spencer Baugh via "Bug reports for GNU Emacs, > > >> the Swiss army knife of text editors" > > >> > > >> Rather than using minibuffer-with-setup-hook and > > >> minibuffer-default-add-function, just pass the list of default > > >> file names as a regular argument to read-file-name. This > > >> behaves better with various customizations, and also allows the > > >> normal abbreviate-file-name logic in read-file-name to run. > > > > > > "Behaves better" in what sense? > > > > > > Would you please show examples of commands where the patched version > > > behaves better, including the effect of the abbreviate-file-name > > > logic? Because from your OP it is unclear to me what, if any, will be > > > the user-facing effects of the new behavior in the relevant Dired > > > commands. > > > > Both before and after my change: > > > > 1. M-: (read-file-name ":" nil (expand-file-name "~")) > > 2. M-n > > 3. Observe ~/ in the minibuffer > > > > This is because read-file-name calls abbreviate-file-name on the default > > argument. > > > > Before my change: > > > > 1. C-x C-f ~/ > > 2. R (or Y or H) > > 3. M-n > > 4. Observe the minibuffer starts with /home/user > > > > After my change: > > > > 1. C-x C-f ~/ > > 2. R (or Y or H) > > 3. M-n > > 4. Observe the minibuffer starts with ~/ as usual for read-file-name > > So abbreviate-file-name is the only improvement provided by your > patch? Your OP seemed to imply that there were others: Btw, I don't quite follow your recipes. What does R (or Y or H) do in this sequence: > 1. C-x C-f ~/ > 2. R (or Y or H) > 3. M-n > 4. Observe the minibuffer starts with /home/user In my case these are self-inserting characters, so after step 2 I have "Find file: ~/R" in the minibuffer. And then M-n signals an error. is something missing from the recipe? Btw, in my case, this recipe: > 1. M-: (read-file-name ":" nil (expand-file-name "~")) > 2. M-n > 3. Observe ~/ in the minibuffer produces "~" in the minibuffer, not "~/". Again, is something missing from the recipe? From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 23 10:55:18 2025 Received: (at 79293) by debbugs.gnu.org; 23 Aug 2025 14:55:18 +0000 Received: from localhost ([127.0.0.1]:41337 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uppeI-0004Lz-8D for submit@debbugs.gnu.org; Sat, 23 Aug 2025 10:55:18 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:38703) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uppeF-0004HX-JM for 79293@debbugs.gnu.org; Sat, 23 Aug 2025 10:55:16 -0400 From: Spencer Baugh To: Eli Zaretskii Subject: Re: bug#79293: [PATCH] Pass dired default filenames via defaults argument In-Reply-To: <86ikie9jxi.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 23 Aug 2025 17:44:41 +0300") References: <86bjo6cyg8.fsf@gnu.org> <86ikie9jxi.fsf@gnu.org> Date: Sat, 23 Aug 2025 10:55:10 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1755960910; bh=rGzzoYd5vplN/Hr4ng9eDn1mYbi62J+Nx0dv7kpNlRg=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=WoiB1+W7JGDlXiQl8hT8rrwK6Kj3MJvVq2OoqWGiqpwjH6y+r4RlYVRz/4P0fVnk8 lahbxMbqj+ZrGKeFMZxD4FXZ/LAcFxz9VPSOEu2c/NaPQMbPkUrD2kI/a22e7PZGpm CqM1+q4/kiCxuKeYnkJTQUNcYgi+KnaDYJQGZ9yIZxesc7IWVsqPARCBMIovc+6ujy dFqgAYvLPhAwGuIY0+XUaQsxXq0vmJSNvDKO8DBIcOnncEmP2FzY5o9XytRLjUVQS4 c0LeaIqQLoviukeEXi39uX4WquDF3NM45Gx1Gn9GVxMZ1+Utfna0CW+qo1kJv2NVNs vIihFBYtMJd3A== X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79293 Cc: 79293@debbugs.gnu.org, juri@linkov.net 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 (---) Eli Zaretskii writes: >> From: Spencer Baugh >> Cc: 79293@debbugs.gnu.org, juri@linkov.net >> Date: Sat, 23 Aug 2025 10:40:17 -0400 >> >> Eli Zaretskii writes: >> >> Cc: Juri Linkov >> >> Date: Fri, 22 Aug 2025 17:20:13 -0400 >> >> From: Spencer Baugh via "Bug reports for GNU Emacs, >> >> the Swiss army knife of text editors" >> >> >> >> Rather than using minibuffer-with-setup-hook and >> >> minibuffer-default-add-function, just pass the list of default >> >> file names as a regular argument to read-file-name. This >> >> behaves better with various customizations, and also allows the >> >> normal abbreviate-file-name logic in read-file-name to run. >> > >> > "Behaves better" in what sense? >> > >> > Would you please show examples of commands where the patched version >> > behaves better, including the effect of the abbreviate-file-name >> > logic? Because from your OP it is unclear to me what, if any, will be >> > the user-facing effects of the new behavior in the relevant Dired >> > commands. >> >> Both before and after my change: >> >> 1. M-: (read-file-name ":" nil (expand-file-name "~")) >> 2. M-n >> 3. Observe ~/ in the minibuffer >> >> This is because read-file-name calls abbreviate-file-name on the default >> argument. >> >> Before my change: >> >> 1. C-x C-f ~/ >> 2. R (or Y or H) >> 3. M-n >> 4. Observe the minibuffer starts with /home/user >> >> After my change: >> >> 1. C-x C-f ~/ >> 2. R (or Y or H) >> 3. M-n >> 4. Observe the minibuffer starts with ~/ as usual for read-file-name > > So abbreviate-file-name is the only improvement provided by your > patch? Your OP seemed to imply that there were others: > >> Rather than using minibuffer-with-setup-hook and >> minibuffer-default-add-function, just pass the list of default >> file names as a regular argument to read-file-name. This >> behaves better with various customizations, and also allows the >> normal abbreviate-file-name logic in read-file-name to run. I suspect this behaves better with custom read-file-name-function values. But I don't have a specific example. My motivation is just the abbreviate-file-name improvement. From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 23 10:58:23 2025 Received: (at 79293) by debbugs.gnu.org; 23 Aug 2025 14:58:23 +0000 Received: from localhost ([127.0.0.1]:41350 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1upphG-0004TN-9G for submit@debbugs.gnu.org; Sat, 23 Aug 2025 10:58:22 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:47663) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1upph7-0004Sr-Ku for 79293@debbugs.gnu.org; Sat, 23 Aug 2025 10:58:14 -0400 From: Spencer Baugh To: Eli Zaretskii Subject: Re: bug#79293: [PATCH] Pass dired default filenames via defaults argument In-Reply-To: <86ect29jju.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 23 Aug 2025 17:52:53 +0300") References: <86bjo6cyg8.fsf@gnu.org> <86ikie9jxi.fsf@gnu.org> <86ect29jju.fsf@gnu.org> Date: Sat, 23 Aug 2025 10:58:08 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1755961088; bh=MerI23w5ukudBITwRyBu4uEmRy7PAlVPl5eD9KcOGDw=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=3nUfCMg17TkaU0DYkpY0DZMus5/alOfSuqN3FLG9kXX1TFDyf5iBQ3vvBTHey+TVK f0GQMPt8ks9BELuA+WRsOuI2nygH9vStKE4rA2pMFm6P7tFURWuhDx5di9kSJy2bkP 8+MdLVPZv9UzGD2ZzMC9Vbd/qznpudQfWbsZ0hAUMswl7ezdB2hwZCjgvSqU/H5qsr HaEegaz7S2T244RLm/DSFlAUVPPtybvOGkaxAEnnUK96Cg+TOP9id8FCYs3hVSjgEu MQCZQBSOfnNUGZ2ZsfPaccb7pAkik7dpTmpYC3ahD/CssPCpwepHufPtwPz1pmRDDn vOdW9z73GNReg== X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79293 Cc: 79293@debbugs.gnu.org, juri@linkov.net 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 (---) Eli Zaretskii writes: >> Cc: 79293@debbugs.gnu.org, juri@linkov.net >> Date: Sat, 23 Aug 2025 17:44:41 +0300 >> From: Eli Zaretskii >> >> > From: Spencer Baugh >> > Cc: 79293@debbugs.gnu.org, juri@linkov.net >> > Date: Sat, 23 Aug 2025 10:40:17 -0400 >> > >> > Eli Zaretskii writes: >> > >> Cc: Juri Linkov >> > >> Date: Fri, 22 Aug 2025 17:20:13 -0400 >> > >> From: Spencer Baugh via "Bug reports for GNU Emacs, >> > >> the Swiss army knife of text editors" >> > >> >> > >> Rather than using minibuffer-with-setup-hook and >> > >> minibuffer-default-add-function, just pass the list of default >> > >> file names as a regular argument to read-file-name. This >> > >> behaves better with various customizations, and also allows the >> > >> normal abbreviate-file-name logic in read-file-name to run. >> > > >> > > "Behaves better" in what sense? >> > > >> > > Would you please show examples of commands where the patched version >> > > behaves better, including the effect of the abbreviate-file-name >> > > logic? Because from your OP it is unclear to me what, if any, will be >> > > the user-facing effects of the new behavior in the relevant Dired >> > > commands. >> > >> > Both before and after my change: >> > >> > 1. M-: (read-file-name ":" nil (expand-file-name "~")) >> > 2. M-n >> > 3. Observe ~/ in the minibuffer >> > >> > This is because read-file-name calls abbreviate-file-name on the default >> > argument. >> > >> > Before my change: >> > >> > 1. C-x C-f ~/ >> > 2. R (or Y or H) >> > 3. M-n >> > 4. Observe the minibuffer starts with /home/user >> > >> > After my change: >> > >> > 1. C-x C-f ~/ >> > 2. R (or Y or H) >> > 3. M-n >> > 4. Observe the minibuffer starts with ~/ as usual for read-file-name >> >> So abbreviate-file-name is the only improvement provided by your >> patch? Your OP seemed to imply that there were others: > > Btw, I don't quite follow your recipes. What does R (or Y or H) do in > this sequence: > >> 1. C-x C-f ~/ >> 2. R (or Y or H) >> 3. M-n >> 4. Observe the minibuffer starts with /home/user > > In my case these are self-inserting characters, so after step 2 I have > "Find file: ~/R" in the minibuffer. And then M-n signals an error. > is something missing from the recipe? Er, yes, it should be: 1. C-x C-f ~/ RET (just missing a trailing RET) > Btw, in my case, this recipe: > >> 1. M-: (read-file-name ":" nil (expand-file-name "~")) >> 2. M-n >> 3. Observe ~/ in the minibuffer > > produces "~" in the minibuffer, not "~/". Again, is something missing > from the recipe? No, just a typo, indeed it produces just "~". Same difference either way: the point is just to demonstrate that read-file-name calls abbreviate-file-name on DEFAULT-FILENAME. From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 24 13:27:48 2025 Received: (at 79293) by debbugs.gnu.org; 24 Aug 2025 17:27:48 +0000 Received: from localhost ([127.0.0.1]:46364 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uqEVQ-0008JQ-EB for submit@debbugs.gnu.org; Sun, 24 Aug 2025 13:27:48 -0400 Received: from mout-p-101.mailbox.org ([2001:67c:2050:0:465::101]:42858) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uqEVN-0008J4-Sd for 79293@debbugs.gnu.org; Sun, 24 Aug 2025 13:27:46 -0400 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (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) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4c918P5LDdz9sr2; Sun, 24 Aug 2025 19:27:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linkov.net; s=MBO0001; t=1756056453; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Hcm7ZC7D+DgYk9ZroXtM1ARDVZFR9fy26jlys7uAv90=; b=2AASVXKWZBalBDLJmfBwhj954FGF79jWcZ0jQzrPmGq08MZeudmWQbTlb7PF8iwqmyekMx Rmj2gknPgm5//x0GBipeTomTv57wiPgZZoYcpzBnHncZ762KQ57neZWYahtjn+HmLKNE3C SBazUbN2xlnhjUlQn8MnEY/ddGfPGwIvSK2N0sFxEZXCK7nSqhbgPMkFsuW41J+Jg/pK6C g9PAmy9WB20Rn3V/oXjI1KSsal/wogFNuTT3YKG6llAGkFK3ndMPicrjk+mPk2S/yLdU+P KtULEHKRCBIDYvLT2N+A6hBjWhzK/n5lPaFks2ow9DtLzqC61qPbDKCsX5ZO3Q== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of juri@linkov.net designates 2001:67c:2050:b231:465::1 as permitted sender) smtp.mailfrom=juri@linkov.net From: Juri Linkov To: Spencer Baugh Subject: Re: bug#79293: [PATCH] Pass dired default filenames via defaults argument In-Reply-To: Organization: LINKOV.NET References: <86bjo6cyg8.fsf@gnu.org> Date: Sun, 24 Aug 2025 20:25:21 +0300 Message-ID: <87349g7htq.fsf@mail.linkov.net> MIME-Version: 1.0 Content-Type: text/plain X-Rspamd-Queue-Id: 4c918P5LDdz9sr2 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 79293 Cc: Eli Zaretskii , 79293@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 (-) > Before my change: > > 1. C-x C-f ~/ > 2. R (or Y or H) > 3. M-n > 4. Observe the minibuffer starts with /home/user > > After my change: > > 1. C-x C-f ~/ > 2. R (or Y or H) > 3. M-n > 4. Observe the minibuffer starts with ~/ as usual for read-file-name > > Juri may also have some comments about why the code was written in this > way, as the original author of both this code and other code in dired > which uses minibuffer-with-setup-hook. It was just a common coding pattern shared between all similar functions: (minibuffer-with-setup-hook (lambda () (setq-local minibuffer-default-add-function nil) (setq minibuffer-default defaults)) But when one function uses another like 'dired-do-create-files' using 'read-file-name', it's fine to pass the default list via its argument. From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 27 13:41:59 2025 Received: (at 79293) by debbugs.gnu.org; 27 Aug 2025 17:41:59 +0000 Received: from localhost ([127.0.0.1]:34577 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1urK9n-0006xs-5E for submit@debbugs.gnu.org; Wed, 27 Aug 2025 13:41:59 -0400 Received: from mout-p-103.mailbox.org ([80.241.56.161]:53288) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1urK9j-0006xL-VI for 79293@debbugs.gnu.org; Wed, 27 Aug 2025 13:41:56 -0400 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (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) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4cBsKS0JsPz9tcg; Wed, 27 Aug 2025 19:41:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linkov.net; s=MBO0001; t=1756316508; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=dhvThV1gp69vgr2Z5G04a9iRowxk17Vfpt9nrSBLBbA=; b=NSFAMfF9N/1NefThLroYQkgWhw52tTZMO47dAYYRgl7DeJuRGlcWUQ8MbkJK7qdhJ0Kv1C XOvq1x05WEcY5kYLYRKCTQzZX6KEE73+7LzQRwddGvxeLt0ujmdTy9bgvIr0w8Tsfm1Jva ClLw8OGLmtoz8IoMbaQJHL/BSm37vXydlS/+620o46AsFq+dDlYvFmE/AbAnsRQItIxby1 cfREgUNiUfJMUa6DSESwKX8guXzgWcAm7x3UDFNk/rZbD4twIMM/ZAfaNWzyw4nYu5u4N4 9w58HuZfIJ/TK5CgQDoNmrH3uZOyw+V1LQ3iH7zAMMGa8i0DreBtlTD8S9XgUA== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of juri@linkov.net designates 2001:67c:2050:b231:465::2 as permitted sender) smtp.mailfrom=juri@linkov.net From: Juri Linkov To: Spencer Baugh Subject: Re: bug#79293: [PATCH] Pass dired default filenames via defaults argument In-Reply-To: Organization: LINKOV.NET References: <86bjo6cyg8.fsf@gnu.org> Date: Wed, 27 Aug 2025 20:40:12 +0300 Message-ID: <87frdc8xz7.fsf@mail.linkov.net> MIME-Version: 1.0 Content-Type: text/plain X-Rspamd-Queue-Id: 4cBsKS0JsPz9tcg X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 79293 Cc: Eli Zaretskii , 79293@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 (-) > Also, attached is an updated version of the patch which reflects the > fact that the "default" variable actually was unused before, only > "defaults" was used. > [...] > - (default (and dired-one-file > - (not dired-dwim-target) ; Bug#25609 Removing these lines breaks dired-tests added in the same commit 841e3e377c97 for Bug#25609 above. Wouldn't it be safer just to add abbreviate-file-name in the existing minibuffer-with-setup-hook? This means code duplication, but avoids the risk of breaking something. From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 27 16:26:28 2025 Received: (at 79293) by debbugs.gnu.org; 27 Aug 2025 20:26:28 +0000 Received: from localhost ([127.0.0.1]:36375 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1urMix-0006hS-Fl for submit@debbugs.gnu.org; Wed, 27 Aug 2025 16:26:28 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:33825) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1urMit-0006hC-KE for 79293@debbugs.gnu.org; Wed, 27 Aug 2025 16:26:24 -0400 From: Spencer Baugh To: Juri Linkov Subject: Re: bug#79293: [PATCH] Pass dired default filenames via defaults argument In-Reply-To: <87frdc8xz7.fsf@mail.linkov.net> (Juri Linkov's message of "Wed, 27 Aug 2025 20:40:12 +0300") References: <86bjo6cyg8.fsf@gnu.org> <87frdc8xz7.fsf@mail.linkov.net> Date: Wed, 27 Aug 2025 16:26:17 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1756326377; bh=AKEJagLN4a1VJwjt2Fd5TV7girfUJl+NM9FzD2RLxTU=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=jKODcjarFXYNmjlmY1HtiUkYHV4Pr0IW8YWbWosO1FbaFnpRC3am8ko6czgujTi92 gK1661N/K7A58gTav7OrKAyDQQOENpIR7u9cShVDuOkpSAqQxVB2q17uCQ0d3qX2az eq9F5xrbikahi1Mmfhbjeb2zGlYa0lv+nAeAL+1oeqlhJ/sFl3ZOKi3dT5vIau/Q7l wm+E2crg3i+Fu43fxVZTB3zY9DeWOLlc5E6Vv5ZIpMXMAsEcRO5BPj0o2nybTjf65f DvTG7K5a9mjkHDHn/3tSAG5qHz1i8TbFEAhP6j9+5blwuP9Rh4FjH1WAmVzbT8VJfL HuAjTOqSZg6ig== X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79293 Cc: Eli Zaretskii , 79293@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 (---) --=-=-= Content-Type: text/plain Juri Linkov writes: >> Also, attached is an updated version of the patch which reflects the >> fact that the "default" variable actually was unused before, only >> "defaults" was used. >> [...] >> - (default (and dired-one-file >> - (not dired-dwim-target) ; Bug#25609 > > Removing these lines breaks dired-tests added > in the same commit 841e3e377c97 for Bug#25609 above. Ah, sorry, I guess I forgot to run dired-tests. But this is great news, this means this code is covered by at least one test. The real issue in bug#25609 is that the minibuffer default didn't have the correct value when dired-dwim-target is non-nil. From my analysis of the code, the default should always be the same as the initial input in the minibuffer (TARGET-DIR), but that wasn't happening with non-nil dired-dwim-target. With my change, this is fixed easily enough by just making sure TARGET-DIR is the first element of the defaults list. This doesn't change observable behavior because read-file-name explicitly handles the case where the initial input matches the first default: ;; When the first default in `minibuffer-default' ;; duplicates initial input `insdef', ;; reset `minibuffer-default' to nil. (when (equal (or (car-safe insdef) insdef) (or (car-safe minibuffer-default) minibuffer-default)) (setq minibuffer-default (cdr-safe minibuffer-default))) This also fixes bug#25609, with even less code, and dired-tests and dired-aux-tests both once again all pass. This version of the patch also extends the change to dired-compare-directories, so it gets the abbreviate-file-name benefits too. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Pass-dired-default-filenames-via-defaults-argument.patch >From 388b1855afd2252431c8b44e6674362c6219c18d Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Fri, 22 Aug 2025 17:19:09 -0400 Subject: [PATCH] Pass dired default filenames via defaults argument Rather than using minibuffer-with-setup-hook, just pass the list of default file names as a regular argument to read-file-name. This allows read-file-name to run abbreviate-file-name on the defaults as it normally does, instead of the defaults appearing in expanded form. dired-dwim-target-defaults changes slightly to return the correct default at the start of the list. * lisp/dired-aux.el (dired-do-create-files) (dired-compare-directories): Pass default file names as an argument. (bug#79293) (dired-dwim-target-defaults): Return the correct default at the start of the list. --- lisp/dired-aux.el | 51 +++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 049d200f590..e28106d9865 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -330,14 +330,13 @@ dired-compare-directories (interactive (list (let* ((target-dir (dired-dwim-target-directory)) - (defaults (dired-dwim-target-defaults nil target-dir))) + (defaults (dired-dwim-target-defaults nil target-dir))) (minibuffer-with-setup-hook (lambda () - (setq-local minibuffer-default-add-function nil) - (setq minibuffer-default defaults)) + (setq-local minibuffer-default-add-function nil)) (read-directory-name (format "Compare %s with: " (dired-current-directory)) - target-dir target-dir t))) + target-dir defaults t))) (read-from-minibuffer "Mark if (lisp expr or RET): " nil nil t nil "nil")) dired-mode) (let* ((dir1 (dired-current-directory)) @@ -2668,17 +2667,12 @@ dired-do-create-files (dired-one-file ; fluid variable inside dired-create-files (and (consp fn-list) (null (cdr fn-list)) (car fn-list))) (target-dir (dired-dwim-target-directory)) - (default (and dired-one-file - (not dired-dwim-target) ; Bug#25609 - (expand-file-name (file-name-nondirectory - (car fn-list)) - target-dir))) (defaults (dired-dwim-target-defaults fn-list target-dir)) (target (expand-file-name ; fluid variable inside dired-create-files (minibuffer-with-setup-hook (lambda () - (setq-local minibuffer-default-add-function nil) - (setq minibuffer-default defaults)) + ;; Don't run `read-file-name--defaults' + (setq-local minibuffer-default-add-function nil)) (dired-mark-read-file-name (format "%s %%s %s: " (if dired-one-file op1 operation) @@ -2688,7 +2682,7 @@ dired-do-create-files ;; other operations copy (etc) to the ;; prompted file name. "from" "to")) - target-dir op-symbol arg rfn-list default)))) + target-dir op-symbol arg rfn-list defaults)))) (into-dir (progn (when @@ -2813,28 +2807,26 @@ dired-dwim-target-directory this-dir))) (defun dired-dwim-target-defaults (fn-list target-dir) - ;; Return a list of default values for file-reading functions in Dired. - ;; This list may contain directories from Dired buffers in other windows. - ;; `fn-list' is a list of file names used to build a list of defaults. - ;; When nil or more than one element, a list of defaults will - ;; contain only directory names. `target-dir' is a directory name - ;; to exclude from the returned list, for the case when this - ;; directory name is already presented in initial input. - ;; For Dired operations that support `dired-dwim-target', - ;; the argument `target-dir' should have the value returned - ;; from `dired-dwim-target-directory'. + "Return a list of default values for file-reading functions in Dired. + +This list may contain directories from Dired buffers in other windows. +FN-LIST is a list of file names used to build a list of defaults. +When nil or more than one element, a list of defaults will +contain only directory names. + +TARGET-DIR should be the initial input in the minibuffer for the +file-reading function. For Dired operations that support +`dired-dwim-target', TARGET-DIR should have the value returned from +`dired-dwim-target-directory'." (let ((dired-one-file (and (consp fn-list) (null (cdr fn-list)) (car fn-list))) (current-dir (and (eq major-mode 'dired-mode) (dired-current-directory))) ;; Get a list of directories of visible buffers in dired-mode. (dired-dirs (dired-dwim-target-directories))) - ;; Force the current dir to be the first in the list. + ;; Force TARGET-DIR then CURRENT-DIR to be first in the list. (setq dired-dirs - (delete-dups (delq nil (cons current-dir dired-dirs)))) - ;; Remove the target dir (if specified) or the current dir from - ;; default values, because it should be already in initial input. - (setq dired-dirs (delete (or target-dir current-dir) dired-dirs)) + (delete-dups (delq nil (cons target-dir (cons current-dir dired-dirs))))) ;; Return a list of default values. (if dired-one-file ;; For one file operation, provide a list that contains @@ -2847,10 +2839,7 @@ dired-dwim-target-defaults (mapcar (lambda (dir) (expand-file-name (file-name-nondirectory (car fn-list)) dir)) - (reverse dired-dirs)) - (list (expand-file-name - (file-name-nondirectory (car fn-list)) - (or target-dir current-dir)))) + (reverse dired-dirs))) ;; For multi-file operation, return only a list of other directories. dired-dirs))) -- 2.43.7 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 28 02:23:00 2025 Received: (at 79293) by debbugs.gnu.org; 28 Aug 2025 06:23:00 +0000 Received: from localhost ([127.0.0.1]:38054 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1urW2G-0003Cn-3g for submit@debbugs.gnu.org; Thu, 28 Aug 2025 02:23:00 -0400 Received: from mout-p-102.mailbox.org ([80.241.56.152]:51202) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1urW2D-0003BS-SA; Thu, 28 Aug 2025 02:22:58 -0400 Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (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) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4cCBCX36q5z9v7Z; Thu, 28 Aug 2025 08:22:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linkov.net; s=MBO0001; t=1756362168; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=tRbQp9NMY5RwhUso7s9ek+1JuVBARpa6Q+J2AL6iugs=; b=PX27jmZliQQUl5C3c63eLKFPnRK65IRoQYE0GFnbw46dxroHUhXYVoBeGPjNtnvLpdT/1t hC/OuZ3T/osHqA2zZQvIWRQJf42Dk+v6JVi79U7TVD98T08WBYwkBnTQZBcx6qXmKLZTFQ 5bmyCiBsiU/MDzdiNnGAx82ThhWljt0XVcHibWrjoh0VJxO+Hu3yayDtp0SsQ+ZTKHaxik bV5jnE7k7T0JB0j2xUl6wLkX5r3t8m3UIjWowB1uy2P0jwa9AOA0vc/dC8B3O7CVp83mjL 9GFZy247N5sldJVmSxWlUkgHpiGfE1xQugtiMnSZeGE+hXt2EI+BeXt+zKXLUQ== From: Juri Linkov To: Spencer Baugh Subject: Re: bug#79293: [PATCH] Pass dired default filenames via defaults argument In-Reply-To: Organization: LINKOV.NET References: <86bjo6cyg8.fsf@gnu.org> <87frdc8xz7.fsf@mail.linkov.net> Date: Thu, 28 Aug 2025 09:21:41 +0300 Message-ID: <87iki8klu2.fsf@mail.linkov.net> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 79293 Cc: Eli Zaretskii , 79293@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 (-) close 79293 31.0.50 thanks > This also fixes bug#25609, with even less code, and dired-tests and > dired-aux-tests both once again all pass. > > This version of the patch also extends the change to > dired-compare-directories, so it gets the abbreviate-file-name benefits > too. Thanks, I tested it, and everything works correctly, so now pushed. > - (setq-local minibuffer-default-add-function nil) > - (setq minibuffer-default defaults)) > + ;; Don't run `read-file-name--defaults' > + (setq-local minibuffer-default-add-function nil)) Thanks for adding this comment, now I remember this was intentional to prevent running this function in read-file-name-default.