GNU bug report logs -
#79293
[PATCH] Pass dired default filenames via defaults argument
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:
>> Cc: Juri Linkov <juri <at> linkov.net>
>> 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" <bug-gnu-emacs <at> gnu.org>
>>
>> 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.
[0001-Pass-dired-default-filenames-via-defaults-argument.patch (text/x-patch, inline)]
From 7e28da2ef1de05d8de46eee7605c8346753406fd Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh <at> janestreet.com>
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
This bug report was last modified 22 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.