GNU bug report logs -
#79293
[PATCH] Pass dired default filenames via defaults argument
Previous Next
To reply to this bug, email your comments to 79293 AT debbugs.gnu.org.
There is no need to reopen the bug first.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
juri <at> linkov.net, bug-gnu-emacs <at> gnu.org
:
bug#79293
; Package
emacs
.
(Fri, 22 Aug 2025 21:21:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Spencer Baugh <sbaugh <at> janestreet.com>
:
New bug report received and forwarded. Copy sent to
juri <at> linkov.net, bug-gnu-emacs <at> gnu.org
.
(Fri, 22 Aug 2025 21:21:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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/'
[0001-Pass-dired-default-filenames-via-defaults-argument.patch (text/patch, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#79293
; Package
emacs
.
(Sat, 23 Aug 2025 07:03:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 79293 <at> debbugs.gnu.org (full text, mbox):
> 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.
Thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#79293
; Package
emacs
.
(Sat, 23 Aug 2025 14:41:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 79293 <at> debbugs.gnu.org (full text, mbox):
[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
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#79293
; Package
emacs
.
(Sat, 23 Aug 2025 14:45:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 79293 <at> debbugs.gnu.org (full text, mbox):
> From: Spencer Baugh <sbaugh <at> janestreet.com>
> Cc: 79293 <at> debbugs.gnu.org, juri <at> linkov.net
> Date: Sat, 23 Aug 2025 10:40:17 -0400
>
> 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
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.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#79293
; Package
emacs
.
(Sat, 23 Aug 2025 14:54:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 79293 <at> debbugs.gnu.org (full text, mbox):
> Cc: 79293 <at> debbugs.gnu.org, juri <at> linkov.net
> Date: Sat, 23 Aug 2025 17:44:41 +0300
> From: Eli Zaretskii <eliz <at> gnu.org>
>
> > From: Spencer Baugh <sbaugh <at> janestreet.com>
> > Cc: 79293 <at> debbugs.gnu.org, juri <at> linkov.net
> > Date: Sat, 23 Aug 2025 10:40:17 -0400
> >
> > 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
>
> 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?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#79293
; Package
emacs
.
(Sat, 23 Aug 2025 14:56:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 79293 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Spencer Baugh <sbaugh <at> janestreet.com>
>> Cc: 79293 <at> debbugs.gnu.org, juri <at> linkov.net
>> Date: Sat, 23 Aug 2025 10:40:17 -0400
>>
>> 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
>
> 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.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#79293
; Package
emacs
.
(Sat, 23 Aug 2025 14:59:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 79293 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> Cc: 79293 <at> debbugs.gnu.org, juri <at> linkov.net
>> Date: Sat, 23 Aug 2025 17:44:41 +0300
>> From: Eli Zaretskii <eliz <at> gnu.org>
>>
>> > From: Spencer Baugh <sbaugh <at> janestreet.com>
>> > Cc: 79293 <at> debbugs.gnu.org, juri <at> linkov.net
>> > Date: Sat, 23 Aug 2025 10:40:17 -0400
>> >
>> > 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
>>
>> 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.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#79293
; Package
emacs
.
(Sun, 24 Aug 2025 17:28:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 79293 <at> debbugs.gnu.org (full text, mbox):
> 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.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#79293
; Package
emacs
.
(Wed, 27 Aug 2025 17:42:02 GMT)
Full text and
rfc822 format available.
Message #29 received at 79293 <at> debbugs.gnu.org (full text, mbox):
> 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.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#79293
; Package
emacs
.
(Wed, 27 Aug 2025 20:27:02 GMT)
Full text and
rfc822 format available.
Message #32 received at 79293 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Juri Linkov <juri <at> linkov.net> 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.
[0001-Pass-dired-default-filenames-via-defaults-argument.patch (text/x-patch, inline)]
From 388b1855afd2252431c8b44e6674362c6219c18d 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.
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
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#79293
; Package
emacs
.
(Thu, 28 Aug 2025 06:23:04 GMT)
Full text and
rfc822 format available.
Message #35 received at 79293 <at> debbugs.gnu.org (full text, mbox):
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.
bug marked as fixed in version 31.0.50, send any further explanations to
79293 <at> debbugs.gnu.org and Spencer Baugh <sbaugh <at> janestreet.com>
Request was from
Juri Linkov <juri <at> linkov.net>
to
control <at> debbugs.gnu.org
.
(Thu, 28 Aug 2025 06:24:02 GMT)
Full text and
rfc822 format available.
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.