unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* PR: dired-do-create-files now checks for trailing slashes in the target
@ 2021-09-28 17:50 Rudi C
  2021-09-28 18:17 ` Stefan Kangas
  0 siblings, 1 reply; 55+ messages in thread
From: Rudi C @ 2021-09-28 17:50 UTC (permalink / raw)
  To: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 503 bytes --]

With this patch, we can move directories into new directories if we
explicitly end the new name with a trailing slash.

So `/new_name` renames `/old_name` to `/new_name`, while `/new_name/`
renames `/old_name` to `/new_name/old_name`.

Without this feature, one has to first create the new directory and then
move the old directory into it, which is so unpleasant I currently just
copy the path and use my shell's move functions.

PS: Please use reply-to-all, I am currently not subscribed to the list.

[-- Attachment #1.2: Type: text/html, Size: 625 bytes --]

[-- Attachment #2: 0001-dired-do-create-files-now-checks-for-trailing-slashe.patch --]
[-- Type: application/octet-stream, Size: 992 bytes --]

From 002984ab26573ce560a4dd7ec3f9a9aab600abbf Mon Sep 17 00:00:00 2001
From: NightMachinary <rudiwillalwaysloveyou@gmail.com>
Date: Tue, 28 Sep 2021 21:14:05 +0330
Subject: [PATCH] dired-do-create-files now checks for trailing slashes in the
 target

---
 lisp/dired-aux.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 397c5c67cb..72cee2c485 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -2157,7 +2157,9 @@ Optional arg HOW-TO determines how to treat the target.
 		     target-dir op-symbol arg rfn-list default))))
 	 (into-dir
           (progn
-            (unless dired-one-file (dired-maybe-create-dirs target))
+            (when (or (not dired-one-file)
+                      (string= (substring target -1) "/"))
+              (dired-maybe-create-dirs target))
             (cond ((null how-to)
 		   ;; Allow users to change the letter case of
 		   ;; a directory on a case-insensitive
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-28 17:50 PR: dired-do-create-files now checks for trailing slashes in the target Rudi C
@ 2021-09-28 18:17 ` Stefan Kangas
  2021-09-28 18:42   ` Rudi C
  2021-09-28 18:42   ` Eli Zaretskii
  0 siblings, 2 replies; 55+ messages in thread
From: Stefan Kangas @ 2021-09-28 18:17 UTC (permalink / raw)
  To: Rudi C, emacs-devel

Rudi C <rudiwillalwaysloveyou@gmail.com> writes:

> With this patch, we can move directories into new directories if we
> explicitly end the new name with a trailing slash.
>
> So `/new_name` renames `/old_name` to `/new_name`, while `/new_name/`
> renames `/old_name` to `/new_name/old_name`.

Isn't that backwards-incompatible?

> Without this feature, one has to first create the new directory and then
> move the old directory into it, which is so unpleasant I currently just
> copy the path and use my shell's move functions.

IIRC, if you use e.g. `ido', you can create a directory from the prompt
with M-m.  I'm not sure about the default completion, but there are
similar features in other completion frameworks.  Isn't that a better
way to go about this?



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-28 18:17 ` Stefan Kangas
@ 2021-09-28 18:42   ` Rudi C
  2021-09-28 19:03     ` Stefan Kangas
  2021-09-28 18:42   ` Eli Zaretskii
  1 sibling, 1 reply; 55+ messages in thread
From: Rudi C @ 2021-09-28 18:42 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1601 bytes --]

> Isn't that backwards-incompatible?

This is an interactive function, I think, so backward compatibility is a
loose concept here. I can add a configuration variable if you think this
matters.

> similar features in other completion frameworks
I don't know if `ivy` has this, but anyway, I try to keep this kind of
hotkeys to a minimum; They are easy to forget, they are not ergonomic, and
I have only five fingers from birth, which doesn't help. Why would I want a
hotkey when I can perfectly achieve what I need without one, and without
losing any functionality?

Besides, the point is moot, as dired already exposes
`dired-create-destination-dirs', so it is not delegating this feature. So
it might as well do it right.

On Tue, Sep 28, 2021 at 9:47 PM Stefan Kangas <stefankangas@gmail.com>
wrote:

> Rudi C <rudiwillalwaysloveyou@gmail.com> writes:
>
> > With this patch, we can move directories into new directories if we
> > explicitly end the new name with a trailing slash.
> >
> > So `/new_name` renames `/old_name` to `/new_name`, while `/new_name/`
> > renames `/old_name` to `/new_name/old_name`.
>
> Isn't that backwards-incompatible?
>
> > Without this feature, one has to first create the new directory and then
> > move the old directory into it, which is so unpleasant I currently just
> > copy the path and use my shell's move functions.
>
> IIRC, if you use e.g. `ido', you can create a directory from the prompt
> with M-m.  I'm not sure about the default completion, but there are
> similar features in other completion frameworks.  Isn't that a better
> way to go about this?
>

[-- Attachment #2: Type: text/html, Size: 2169 bytes --]

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-28 18:17 ` Stefan Kangas
  2021-09-28 18:42   ` Rudi C
@ 2021-09-28 18:42   ` Eli Zaretskii
  2021-09-28 19:29     ` Tassilo Horn
  1 sibling, 1 reply; 55+ messages in thread
From: Eli Zaretskii @ 2021-09-28 18:42 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: rudiwillalwaysloveyou, emacs-devel

> From: Stefan Kangas <stefankangas@gmail.com>
> Date: Tue, 28 Sep 2021 11:17:32 -0700
> 
> Rudi C <rudiwillalwaysloveyou@gmail.com> writes:
> 
> > With this patch, we can move directories into new directories if we
> > explicitly end the new name with a trailing slash.
> >
> > So `/new_name` renames `/old_name` to `/new_name`, while `/new_name/`
> > renames `/old_name` to `/new_name/old_name`.
> 
> Isn't that backwards-incompatible?

It may or may not be, but I'd suggest first to have a reproducible
recipe that demonstrates the problem.  Because I don't think I
understand what this is trying to solve.

In any case, testing the last character for a literal slash is not
TRT; we have functions for distinguishing between a file's name as
directory and the directory's file name.



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-28 18:42   ` Rudi C
@ 2021-09-28 19:03     ` Stefan Kangas
  2021-09-28 19:38       ` Tassilo Horn
  2021-09-28 20:23       ` Rudi C
  0 siblings, 2 replies; 55+ messages in thread
From: Stefan Kangas @ 2021-09-28 19:03 UTC (permalink / raw)
  To: Rudi C; +Cc: emacs-devel

Rudi C <rudiwillalwaysloveyou@gmail.com> writes:

>> Isn't that backwards-incompatible?
>
> This is an interactive function, I think, so backward compatibility is a
> loose concept here. I can add a configuration variable if you think this
> matters.

I don't have an opinion on that yet.

>> similar features in other completion frameworks
> I don't know if `ivy` has this, but anyway, I try to keep this kind of
> hotkeys to a minimum; They are easy to forget, they are not ergonomic, and
> I have only five fingers from birth, which doesn't help. Why would I want a
> hotkey when I can perfectly achieve what I need without one, and without
> losing any functionality?

It feels surprising that if I rename something to "/foo/" my file
suddenly gets moved into a new directory "foo", though.  Maybe it's just
me.  Does this have some precedent elsewhere?  Is this something users
would expect?



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-28 18:42   ` Eli Zaretskii
@ 2021-09-28 19:29     ` Tassilo Horn
  2021-09-28 19:55       ` Eli Zaretskii
  0 siblings, 1 reply; 55+ messages in thread
From: Tassilo Horn @ 2021-09-28 19:29 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: rudiwillalwaysloveyou, Stefan Kangas, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> > With this patch, we can move directories into new directories if we
>> > explicitly end the new name with a trailing slash.
>> >
>> > So `/new_name` renames `/old_name` to `/new_name`, while `/new_name/`
>> > renames `/old_name` to `/new_name/old_name`.
>> 
>> Isn't that backwards-incompatible?
>
> It may or may not be, but I'd suggest first to have a reproducible
> recipe that demonstrates the problem.  Because I don't think I
> understand what this is trying to solve.

It solves the problem of moving/copying a file or directory into a
not-yet-existing directory.  So with the above example, you can do

  R /new_name/ RET

if point is on /old_name or /old_name is marked to move /old_name into
/new_name/.  Right now, you need to do

  + /new_name RET   ;; create the new directory
  R /new_name RET   ;; then move /old_name

FWIW, I would find it very convenient if dired would create the target
directory if I indicate it as directory by specifying a trailing /.

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-28 19:03     ` Stefan Kangas
@ 2021-09-28 19:38       ` Tassilo Horn
  2021-09-28 20:07         ` Stefan Kangas
  2021-09-28 20:23       ` Rudi C
  1 sibling, 1 reply; 55+ messages in thread
From: Tassilo Horn @ 2021-09-28 19:38 UTC (permalink / raw)
  To: emacs-devel

Stefan Kangas <stefankangas@gmail.com> writes:

> It feels surprising that if I rename something to "/foo/" my file
> suddenly gets moved into a new directory "foo", though.  Maybe it's
> just me.  Does this have some precedent elsewhere?  Is this something
> users would expect?

Consider that this only triggers if "foo" doesn't exist yet.  In such a
case, filename completion won't suggest anything, especially no trailing
/.  So it doesn't feel very likely that someone wants to rename a file
or directory ~/bar to "foo" and then specifies ~/foo/ (with trailing
slash) as the target by accident.

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-28 19:29     ` Tassilo Horn
@ 2021-09-28 19:55       ` Eli Zaretskii
  2021-09-29  4:46         ` Tassilo Horn
  0 siblings, 1 reply; 55+ messages in thread
From: Eli Zaretskii @ 2021-09-28 19:55 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: rudiwillalwaysloveyou, stefankangas, emacs-devel

> From: Tassilo Horn <tsdh@gnu.org>
> Cc: Stefan Kangas <stefankangas@gmail.com>, rudiwillalwaysloveyou@gmail.com,
>  emacs-devel@gnu.org
> Date: Tue, 28 Sep 2021 21:29:04 +0200
> 
> > It may or may not be, but I'd suggest first to have a reproducible
> > recipe that demonstrates the problem.  Because I don't think I
> > understand what this is trying to solve.
> 
> It solves the problem of moving/copying a file or directory into a
> not-yet-existing directory.  So with the above example, you can do
> 
>   R /new_name/ RET

So the behavior will now differ depending on whether new_name already
exists or not?  because if the user types

  R /new_ TAB

Emacs will complete it to "/new_name/", including the trailing slash.



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-28 19:38       ` Tassilo Horn
@ 2021-09-28 20:07         ` Stefan Kangas
  0 siblings, 0 replies; 55+ messages in thread
From: Stefan Kangas @ 2021-09-28 20:07 UTC (permalink / raw)
  To: Tassilo Horn, emacs-devel

Tassilo Horn <tsdh@gnu.org> writes:

> Consider that this only triggers if "foo" doesn't exist yet.  In such a
> case, filename completion won't suggest anything, especially no trailing
> /.  So it doesn't feel very likely that someone wants to rename a file
> or directory ~/bar to "foo" and then specifies ~/foo/ (with trailing
> slash) as the target by accident.

That's true.



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-28 19:03     ` Stefan Kangas
  2021-09-28 19:38       ` Tassilo Horn
@ 2021-09-28 20:23       ` Rudi C
  1 sibling, 0 replies; 55+ messages in thread
From: Rudi C @ 2021-09-28 20:23 UTC (permalink / raw)
  To: Stefan Kangas, Eli Zaretskii, tsdh; +Cc: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 2387 bytes --]

> we have functions for distinguishing between a file's name as directory
and the directory's file name.

Ah, you're right. I have attached a new patch that uses `directory-name-p`.

> Does this have some precedent elsewhere?

The most famous example is rsync, I guess. Doom's `doom/move-this-file'
also does this. (Well, I contributed the directory creation patch to
`doom/move-this-file', so make of that what you will.)

Also note that `dired-create-destination-dirs' is by default `nil', which
means this patch is irrelevant if someone uses the default settings.
`dired-create-destination-dirs' being `'ask' will also ask you to confirm
creating a new directory. If only you put it to `'always' will it do this
"surprising" thing. You also won't lose any data by this surprise, unlike
the current behavior that loses the old name of the directory.

I am copying tsdh@gnu.org's response here, as I think it might not have
gotten to the mailing list.

  > a reproducible recipe that demonstrates the problem.

 It solves the problem of moving/copying a file or directory into a
 not-yet-existing directory.  So with the above example, you can do

   R /new_name/ RET
So the behavior will now differ depending on whether new_name already
exists or not?  because if the user types
  R /new_ TAB
Emacs will complete it to "/new_name/", including the trailing slash.

On Tue, Sep 28, 2021 at 10:33 PM Stefan Kangas <stefankangas@gmail.com>
wrote:

> Rudi C <rudiwillalwaysloveyou@gmail.com> writes:
>
> >> Isn't that backwards-incompatible?
> >
> > This is an interactive function, I think, so backward compatibility is a
> > loose concept here. I can add a configuration variable if you think this
> > matters.
>
> I don't have an opinion on that yet.
>
> >> similar features in other completion frameworks
> > I don't know if `ivy` has this, but anyway, I try to keep this kind of
> > hotkeys to a minimum; They are easy to forget, they are not ergonomic,
> and
> > I have only five fingers from birth, which doesn't help. Why would I
> want a
> > hotkey when I can perfectly achieve what I need without one, and without
> > losing any functionality?
>
> It feels surprising that if I rename something to "/foo/" my file
> suddenly gets moved into a new directory "foo", though.  Maybe it's just
> me.  Does this have some precedent elsewhere?  Is this something users
> would expect?
>

[-- Attachment #1.2: Type: text/html, Size: 3322 bytes --]

[-- Attachment #2: 0001-dired-do-create-files-now-checks-for-trailing-slashe.patch --]
[-- Type: application/octet-stream, Size: 982 bytes --]

From 951e12f352b783b15edbabb4623a5c721425bd25 Mon Sep 17 00:00:00 2001
From: NightMachinary <rudiwillalwaysloveyou@gmail.com>
Date: Tue, 28 Sep 2021 21:14:05 +0330
Subject: [PATCH] dired-do-create-files now checks for trailing slashes in the
 target

---
 lisp/dired-aux.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 397c5c67cb..fcaa8dd008 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -2157,7 +2157,9 @@ Optional arg HOW-TO determines how to treat the target.
 		     target-dir op-symbol arg rfn-list default))))
 	 (into-dir
           (progn
-            (unless dired-one-file (dired-maybe-create-dirs target))
+            (when (or (not dired-one-file)
+                      (directory-name-p target))
+              (dired-maybe-create-dirs target))
             (cond ((null how-to)
 		   ;; Allow users to change the letter case of
 		   ;; a directory on a case-insensitive
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-28 19:55       ` Eli Zaretskii
@ 2021-09-29  4:46         ` Tassilo Horn
  2021-09-29 13:09           ` Eli Zaretskii
  0 siblings, 1 reply; 55+ messages in thread
From: Tassilo Horn @ 2021-09-29  4:46 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: rudiwillalwaysloveyou, stefankangas, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

Hi Eli,

>> It solves the problem of moving/copying a file or directory into a
>> not-yet-existing directory.  So with the above example, you can do
>> 
>>   R /new_name/ RET
>
> So the behavior will now differ depending on whether new_name already
> exists or not?

Right.  And also `dired-create-destination-dirs' has to be non-nil for
the new behavior which conforms to its documentation.  I have that set
to 'ask, and when I apply Rudi's patch and do the recipe, it'll ask if a
new directory new_name/ should be created.

> because if the user types
>
>   R /new_ TAB
>
> Emacs will complete it to "/new_name/", including the trailing slash.

But only if it exists, and then the patch makes no difference in
behavior.  You explicitly need to type non_existing_dir/ with trailing
slash for the new behavior which will surely never be completed because
of its non-existence.

FWIW, I've applied the patch locally and like it very much.  Of course,
if we agree on including it, it will need to be documented somewhere.
I'm not sure where the best place is.  It's concerned with possibly
creating a new target directory which happens not only with our
renaming/moving example but also with copying, symlinking, etc.  Maybe a
good spot would be the docstring/texinfo docs for
`dired-create-destination-dirs'.  It basically needs another sentence
that when specifying a target of a dired operation, one can add a
trailing / to inform dired that the target is a directory which should
be created if non-existent.

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-29  4:46         ` Tassilo Horn
@ 2021-09-29 13:09           ` Eli Zaretskii
  2021-09-29 13:20             ` Rudi C
  2021-09-29 13:23             ` Tassilo Horn
  0 siblings, 2 replies; 55+ messages in thread
From: Eli Zaretskii @ 2021-09-29 13:09 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: rudiwillalwaysloveyou, stefankangas, emacs-devel

> From: Tassilo Horn <tsdh@gnu.org>
> Cc: rudiwillalwaysloveyou@gmail.com, stefankangas@gmail.com,
>  emacs-devel@gnu.org
> Date: Wed, 29 Sep 2021 06:46:04 +0200
> 
> > So the behavior will now differ depending on whether new_name already
> > exists or not?
> 
> Right.  And also `dired-create-destination-dirs' has to be non-nil for
> the new behavior which conforms to its documentation.  I have that set
> to 'ask, and when I apply Rudi's patch and do the recipe, it'll ask if a
> new directory new_name/ should be created.
> 
> > because if the user types
> >
> >   R /new_ TAB
> >
> > Emacs will complete it to "/new_name/", including the trailing slash.
> 
> But only if it exists, and then the patch makes no difference in
> behavior.

Isn't that exactly the problem?  If both old_name and new_name exist,
how do I rename old_name into new_name so that it overwrites new_name
instead of becoming its subdirectory?  I must carefully type new_name
RET so as to avoid having a slash at its end.

I would support such a change only if it had an explicit defcustom to
control it.  (It could be a new value of
dired-create-destination-dirs, if that makes sense.)



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-29 13:09           ` Eli Zaretskii
@ 2021-09-29 13:20             ` Rudi C
  2021-09-29 13:34               ` Eli Zaretskii
                                 ` (2 more replies)
  2021-09-29 13:23             ` Tassilo Horn
  1 sibling, 3 replies; 55+ messages in thread
From: Rudi C @ 2021-09-29 13:20 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel, stefankangas, Tassilo Horn

[-- Attachment #1: Type: text/plain, Size: 1731 bytes --]

> how do I rename old_name into new_name so that it overwrites new_name

Overwriting a directory is a highly destructive activity. It would be
better to make the user explicitly delete the old directory, and then do
the rename IMO.

But we can add a new custom variable. I am all for giving everyone options.
I don't think it can integrate with `dired-create-destination-dirs' though;
`dired-create-destination-dirs-trailing-slash-special'?

On Wed, Sep 29, 2021 at 4:39 PM Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Tassilo Horn <tsdh@gnu.org>
> > Cc: rudiwillalwaysloveyou@gmail.com, stefankangas@gmail.com,
> >  emacs-devel@gnu.org
> > Date: Wed, 29 Sep 2021 06:46:04 +0200
> >
> > > So the behavior will now differ depending on whether new_name already
> > > exists or not?
> >
> > Right.  And also `dired-create-destination-dirs' has to be non-nil for
> > the new behavior which conforms to its documentation.  I have that set
> > to 'ask, and when I apply Rudi's patch and do the recipe, it'll ask if a
> > new directory new_name/ should be created.
> >
> > > because if the user types
> > >
> > >   R /new_ TAB
> > >
> > > Emacs will complete it to "/new_name/", including the trailing slash.
> >
> > But only if it exists, and then the patch makes no difference in
> > behavior.
>
> Isn't that exactly the problem?  If both old_name and new_name exist,
> how do I rename old_name into new_name so that it overwrites new_name
> instead of becoming its subdirectory?  I must carefully type new_name
> RET so as to avoid having a slash at its end.
>
> I would support such a change only if it had an explicit defcustom to
> control it.  (It could be a new value of
> dired-create-destination-dirs, if that makes sense.)
>

[-- Attachment #2: Type: text/html, Size: 2524 bytes --]

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-29 13:09           ` Eli Zaretskii
  2021-09-29 13:20             ` Rudi C
@ 2021-09-29 13:23             ` Tassilo Horn
  2021-09-29 13:41               ` Eli Zaretskii
  2021-09-29 13:57               ` Stefan Kangas
  1 sibling, 2 replies; 55+ messages in thread
From: Tassilo Horn @ 2021-09-29 13:23 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: rudiwillalwaysloveyou, stefankangas, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

Hi Eli,

>> > because if the user types
>> >
>> >   R /new_ TAB
>> >
>> > Emacs will complete it to "/new_name/", including the trailing slash.
>> 
>> But only if it exists, and then the patch makes no difference in
>> behavior.
>
> Isn't that exactly the problem?  If both old_name and new_name exist,
> how do I rename old_name into new_name so that it overwrites new_name
> instead of becoming its subdirectory?  I must carefully type new_name
> RET so as to avoid having a slash at its end.

That's already the case without this patch and emacs 27.2 started with
"emacs -Q".  I have both foo and bar directories in my dired buffer,
then hit R on foo and complete bar/.  It will move foo inside of bar.
The very same happens if I just complete to bar without trailing /.

IMHO, that makes sense because you usually don't want to rename a
directory so that it gets a name which already exists.  And its also
consistent with "mv" from GNU coreutils 9.0 where "mv foo bar" also
moves foo into bar if both exist and at least bar is a directory.

That makes the proposed patch a very natural extension of what we
already have, i.e., it just ensures `dired-create-destination-dirs' is
obeyed.

> I would support such a change only if it had an explicit defcustom to
> control it.  (It could be a new value of
> dired-create-destination-dirs, if that makes sense.)

I disagree based on above observations.  Is the behavior different on
Windows?

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-29 13:20             ` Rudi C
@ 2021-09-29 13:34               ` Eli Zaretskii
  2021-09-29 13:37               ` Tassilo Horn
  2021-09-29 13:42               ` Stefan Kangas
  2 siblings, 0 replies; 55+ messages in thread
From: Eli Zaretskii @ 2021-09-29 13:34 UTC (permalink / raw)
  To: Rudi C; +Cc: emacs-devel, stefankangas, tsdh

> From: Rudi C <rudiwillalwaysloveyou@gmail.com>
> Date: Wed, 29 Sep 2021 16:50:50 +0330
> Cc: Tassilo Horn <tsdh@gnu.org>, stefankangas@gmail.com, emacs-devel@gnu.org
> 
> > how do I rename old_name into new_name so that it overwrites new_name
> 
> Overwriting a directory is a highly destructive activity.

True, but it isn't invalid or nonsensical.  And it was possible before
the change, right?

> But we can add a new custom variable. I am all for giving everyone options. I don't think it can integrate with
> `dired-create-destination-dirs' though; `dired-create-destination-dirs-trailing-slash-special'?

I leave this to you guys.



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-29 13:20             ` Rudi C
  2021-09-29 13:34               ` Eli Zaretskii
@ 2021-09-29 13:37               ` Tassilo Horn
  2021-09-29 13:42               ` Stefan Kangas
  2 siblings, 0 replies; 55+ messages in thread
From: Tassilo Horn @ 2021-09-29 13:37 UTC (permalink / raw)
  To: Rudi C; +Cc: Eli Zaretskii, stefankangas, emacs-devel

Rudi C <rudiwillalwaysloveyou@gmail.com> writes:

>> how do I rename old_name into new_name so that it overwrites new_name
>
> Overwriting a directory is a highly destructive activity. It would be
> better to make the user explicitly delete the old directory, and then
> do the rename IMO.

I would agree.  And while it could made work for the target being an
empty directory, hopefully nobody will assume this to be a sensible
operation if the target is a non-empty directory.

> But we can add a new custom variable. I am all for giving everyone
> options.  I don't think it can integrate with
> `dired-create-destination-dirs' though;
> `dired-create-destination-dirs-trailing-slash-special'?

Have a look at my reply to Eli.  AFAICS, dired doesn't overwrite a
directory even without your patch when you rename a directory foo to bar
which already exists.  It also moves foo into bar.

So from my POV, no new defcustom is needed.

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-29 13:23             ` Tassilo Horn
@ 2021-09-29 13:41               ` Eli Zaretskii
  2021-09-29 13:42                 ` Tassilo Horn
  2021-09-29 13:57               ` Stefan Kangas
  1 sibling, 1 reply; 55+ messages in thread
From: Eli Zaretskii @ 2021-09-29 13:41 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: rudiwillalwaysloveyou, stefankangas, emacs-devel

> From: Tassilo Horn <tsdh@gnu.org>
> Cc: rudiwillalwaysloveyou@gmail.com, stefankangas@gmail.com,
>  emacs-devel@gnu.org
> Date: Wed, 29 Sep 2021 15:23:39 +0200
> 
> > Isn't that exactly the problem?  If both old_name and new_name exist,
> > how do I rename old_name into new_name so that it overwrites new_name
> > instead of becoming its subdirectory?  I must carefully type new_name
> > RET so as to avoid having a slash at its end.
> 
> That's already the case without this patch and emacs 27.2 started with
> "emacs -Q".  I have both foo and bar directories in my dired buffer,
> then hit R on foo and complete bar/.  It will move foo inside of bar.
> The very same happens if I just complete to bar without trailing /.

And with the proposed change, the last sentence will no longer happen,
right?  That's the change in behavior I was talking about.  Or am I
missing something?



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-29 13:20             ` Rudi C
  2021-09-29 13:34               ` Eli Zaretskii
  2021-09-29 13:37               ` Tassilo Horn
@ 2021-09-29 13:42               ` Stefan Kangas
  2021-09-29 13:53                 ` Tassilo Horn
  2 siblings, 1 reply; 55+ messages in thread
From: Stefan Kangas @ 2021-09-29 13:42 UTC (permalink / raw)
  To: Rudi C, Eli Zaretskii; +Cc: emacs-devel, Tassilo Horn

Rudi C <rudiwillalwaysloveyou@gmail.com> writes:

> But we can add a new custom variable. I am all for giving everyone options.
> I don't think it can integrate with `dired-create-destination-dirs' though;
> `dired-create-destination-dirs-trailing-slash-special'?

I have been convinced that this feature is generally useful, just as it
is useful in rsync (as Tassilo reminded us).

I also don't see any situation where this could lead to a problem, as
you will never complete to "foo/" unless that directory already exists:

1. If there is a file "foo", you complete to "foo" and presumably you
  just get an error if you type a "/" to get "foo/" and then RET.

2. If there is a directory "foo", you complete to "foo/" and you get the
   current behavior which is to move the file into that already existing
   directory.

BTW, in rsync I can't do "foo/bar/".  Does it make sense to support
that, perhaps optionally?  Much like "mkdir -p".



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-29 13:41               ` Eli Zaretskii
@ 2021-09-29 13:42                 ` Tassilo Horn
  2021-09-29 13:57                   ` Eli Zaretskii
  2021-09-29 17:01                   ` [External] : " Drew Adams
  0 siblings, 2 replies; 55+ messages in thread
From: Tassilo Horn @ 2021-09-29 13:42 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: rudiwillalwaysloveyou, stefankangas, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> That's already the case without this patch and emacs 27.2 started
>> with "emacs -Q".  I have both foo and bar directories in my dired
>> buffer, then hit R on foo and complete bar/.  It will move foo inside
>> of bar.  The very same happens if I just complete to bar without
>> trailing /.
>
> And with the proposed change, the last sentence will no longer happen,
> right?  That's the change in behavior I was talking about.

It still happens the very same way.  The only thing this patch is
concerned with is that if bar (specified as bar/) does not exist yet, it
will be created as directory before doing the operation (i.e., the
rename or copy).

So basically we have those Rename/Copy semantics:

  file -> 2.txt (renames plain file no matter if 2.txt already exists)
  file -> foo   (move into foo if that's an existing dir, otherwise rename)
  file -> foo/  (move into directory foo, creating if not existing
                 and dired-create-destination-dirs is non-nil)

The first 2 are unchanged, the third one is the new one.

> Or am I missing something?

The above. :-)

And Rudi, please correct me if I'm wrong.  But I think I've tested quite
thoroughly.

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-29 13:42               ` Stefan Kangas
@ 2021-09-29 13:53                 ` Tassilo Horn
  2021-09-29 14:31                   ` Rudi C
  0 siblings, 1 reply; 55+ messages in thread
From: Tassilo Horn @ 2021-09-29 13:53 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: Rudi C, Eli Zaretskii, emacs-devel

Hi Stefan,

> BTW, in rsync I can't do "foo/bar/".  Does it make sense to support
> that, perhaps optionally?  Much like "mkdir -p".

That does already work with Rudi's patch and
dired-create-destination-dirs set to a non-nil value. ;-)

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-29 13:42                 ` Tassilo Horn
@ 2021-09-29 13:57                   ` Eli Zaretskii
  2021-09-29 14:21                     ` Lars Ingebrigtsen
  2021-09-29 17:01                   ` [External] : " Drew Adams
  1 sibling, 1 reply; 55+ messages in thread
From: Eli Zaretskii @ 2021-09-29 13:57 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: rudiwillalwaysloveyou, stefankangas, emacs-devel

> From: Tassilo Horn <tsdh@gnu.org>
> Cc: rudiwillalwaysloveyou@gmail.com, stefankangas@gmail.com,
>  emacs-devel@gnu.org
> Date: Wed, 29 Sep 2021 15:42:50 +0200
> 
> So basically we have those Rename/Copy semantics:
> 
>   file -> 2.txt (renames plain file no matter if 2.txt already exists)
>   file -> foo   (move into foo if that's an existing dir, otherwise rename)
>   file -> foo/  (move into directory foo, creating if not existing
>                  and dired-create-destination-dirs is non-nil)
> 
> The first 2 are unchanged, the third one is the new one.

I'm against unconditionally changing the behavior based on the obscure
fact of whether the directory name ends in a slash or doesn't.  That
slash is ephemeral and users may not be aware to its importance, since
the semantics of foo/ and foo is the same more or less.  So if you
want me to agree to the change, please make this behavior optional.



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-29 13:23             ` Tassilo Horn
  2021-09-29 13:41               ` Eli Zaretskii
@ 2021-09-29 13:57               ` Stefan Kangas
  1 sibling, 0 replies; 55+ messages in thread
From: Stefan Kangas @ 2021-09-29 13:57 UTC (permalink / raw)
  To: Tassilo Horn, Eli Zaretskii; +Cc: rudiwillalwaysloveyou, emacs-devel

Tassilo Horn <tsdh@gnu.org> writes:

> [...] "mv" from GNU coreutils 9.0 where "mv foo bar" also
> moves foo into bar if both exist and at least bar is a directory.

This has been the case with mv since at least 1971:

    If the new name is a directory, the file is moved to that directory
    under its old name.

    http://man.cat-v.org/unix-1st/1/mv



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-29 13:57                   ` Eli Zaretskii
@ 2021-09-29 14:21                     ` Lars Ingebrigtsen
  2021-09-29 15:04                       ` Stefan Kangas
  2021-09-29 15:44                       ` Eli Zaretskii
  0 siblings, 2 replies; 55+ messages in thread
From: Lars Ingebrigtsen @ 2021-09-29 14:21 UTC (permalink / raw)
  To: Eli Zaretskii
  Cc: rudiwillalwaysloveyou, emacs-devel, stefankangas, Tassilo Horn

Eli Zaretskii <eliz@gnu.org> writes:

> I'm against unconditionally changing the behavior based on the obscure
> fact of whether the directory name ends in a slash or doesn't.  That
> slash is ephemeral and users may not be aware to its importance, since
> the semantics of foo/ and foo is the same more or less.

Yes, we're extremely sloppy (in a good way) when handling foo/ and foo,
so it might be surprising behaviour to make this one command assign
different semantics to the two forms.

But it's nice functionality.  Is there some other way we could get this
without relying on the difference between foo and foo/?  A separate
command, perhaps?  Or some extra prompting?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-29 13:53                 ` Tassilo Horn
@ 2021-09-29 14:31                   ` Rudi C
  0 siblings, 0 replies; 55+ messages in thread
From: Rudi C @ 2021-09-29 14:31 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: Eli Zaretskii, Stefan Kangas, emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 1311 bytes --]

Everything Tassilo said seems correct to me, too.

> slash is ephemeral and users may not be aware

Even if they are not aware, they won't lose anything, do they? They will
also probably pick it up easily enough (I learned this after I observed
"inconsistent" behavior in rsync.).

I have attached a new patch that adds a custom option. While I do like
having the option, IMO it should be on by default.

> Is there some other way we could get this
> without relying on the difference between foo and foo/?  A separate
> command, perhaps?  Or some extra prompting?

I think we can add an `'ask' choice to this custom variable I introduced in
this patch, but that really seems like overkill to me; You can just set
`dired-create-destination-dirs' to `'ask', and if you refuse to create the
new directory, you will still have your previous behavior: `old_name` ->
`new_name/` -> user refuses dired' prompt to create a new directory ->
fired moves `old_name` -> `new_name`



On Wed, Sep 29, 2021 at 5:24 PM Tassilo Horn <tsdh@gnu.org> wrote:

> Hi Stefan,
>
> > BTW, in rsync I can't do "foo/bar/".  Does it make sense to support
> > that, perhaps optionally?  Much like "mkdir -p".
>
> That does already work with Rudi's patch and
> dired-create-destination-dirs set to a non-nil value. ;-)
>
> Bye,
> Tassilo
>

[-- Attachment #1.2: Type: text/html, Size: 1923 bytes --]

[-- Attachment #2: 0002-Added-option-dired-create-destination-dirs-trailing-.patch --]
[-- Type: application/octet-stream, Size: 2312 bytes --]

From 7a680d06e4b6ecf9e88e1c309f214d4e1a7f8700 Mon Sep 17 00:00:00 2001
From: NightMachinary <rudiwillalwaysloveyou@gmail.com>
Date: Wed, 29 Sep 2021 17:54:29 +0330
Subject: [PATCH 2/2] Added option
 dired-create-destination-dirs-trailing-separator-special

---
 lisp/dired-aux.el | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index fcaa8dd008..ee727ec5cc 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -1789,6 +1789,17 @@ If `ask', ask for user confirmation."
   :group 'dired
   :version "27.1")
 
+(defcustom dired-create-destination-dirs-trailing-separator-special nil
+  "If t, when selecting a single destination in Dired, paths that end in a path separator will be treated as a non-existent directory, and acted on according to `dired-create-destination-dirs'.
+
+This option is only relevant if `dired-create-destination-dirs' is not `nil', and you are moving/copying a single directory.
+
+For example, when renaming a directory named `old_name' to `new_name/' (note the trailing path separator), `new_name' might be created depending on `dired-create-destination-dirs' and `old_name' will be moved into it if it is created; Otherwise `old_name' will be directly renamed to `new_name'."
+  :type '(choice (const :tag "Do not treat paths with a trailing path separator specially" nil)
+                 (const :tag "Treat paths with a trailing path separator specially" t))
+  :group 'dired
+  :version "28.1")
+
 (defun dired-maybe-create-dirs (dir)
   "Create DIR if doesn't exist according to `dired-create-destination-dirs'."
   (when (and dired-create-destination-dirs (not (file-exists-p dir)))
@@ -2157,8 +2168,11 @@ Optional arg HOW-TO determines how to treat the target.
 		     target-dir op-symbol arg rfn-list default))))
 	 (into-dir
           (progn
-            (when (or (not dired-one-file)
-                      (directory-name-p target))
+            (when
+                (or
+                 (not dired-one-file)
+                 (and dired-create-destination-dirs-trailing-separator-special
+                      (directory-name-p target)))
               (dired-maybe-create-dirs target))
             (cond ((null how-to)
 		   ;; Allow users to change the letter case of
-- 
2.32.0


[-- Attachment #3: 0001-dired-do-create-files-now-checks-for-trailing-slashe.patch --]
[-- Type: application/octet-stream, Size: 986 bytes --]

From 951e12f352b783b15edbabb4623a5c721425bd25 Mon Sep 17 00:00:00 2001
From: NightMachinary <rudiwillalwaysloveyou@gmail.com>
Date: Tue, 28 Sep 2021 21:14:05 +0330
Subject: [PATCH 1/2] dired-do-create-files now checks for trailing slashes in
 the target

---
 lisp/dired-aux.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 397c5c67cb..fcaa8dd008 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -2157,7 +2157,9 @@ Optional arg HOW-TO determines how to treat the target.
 		     target-dir op-symbol arg rfn-list default))))
 	 (into-dir
           (progn
-            (unless dired-one-file (dired-maybe-create-dirs target))
+            (when (or (not dired-one-file)
+                      (directory-name-p target))
+              (dired-maybe-create-dirs target))
             (cond ((null how-to)
 		   ;; Allow users to change the letter case of
 		   ;; a directory on a case-insensitive
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-29 14:21                     ` Lars Ingebrigtsen
@ 2021-09-29 15:04                       ` Stefan Kangas
  2021-09-29 15:17                         ` Tassilo Horn
  2021-09-29 15:44                       ` Eli Zaretskii
  1 sibling, 1 reply; 55+ messages in thread
From: Stefan Kangas @ 2021-09-29 15:04 UTC (permalink / raw)
  To: Lars Ingebrigtsen, Eli Zaretskii
  Cc: rudiwillalwaysloveyou, emacs-devel, Tassilo Horn

Lars Ingebrigtsen <larsi@gnus.org> writes:

> But it's nice functionality.  Is there some other way we could get this
> without relying on the difference between foo and foo/?  A separate
> command, perhaps?  Or some extra prompting?

How about a prompt by default (e.g. "Do you want to create directory
`foo' and move the file into it?"), with a user option to disable it for
those that want it?

The option values could be t for "do it, no prompt", nil for "turn this
feature off", and 'prompt for the default "enable but prompt first".



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-29 15:04                       ` Stefan Kangas
@ 2021-09-29 15:17                         ` Tassilo Horn
  2021-09-30  6:06                           ` Lars Ingebrigtsen
  0 siblings, 1 reply; 55+ messages in thread
From: Tassilo Horn @ 2021-09-29 15:17 UTC (permalink / raw)
  To: Stefan Kangas
  Cc: Lars Ingebrigtsen, emacs-devel, Eli Zaretskii,
	rudiwillalwaysloveyou

Stefan Kangas <stefankangas@gmail.com> writes:

>> But it's nice functionality.  Is there some other way we could get
>> this without relying on the difference between foo and foo/?  A
>> separate command, perhaps?  Or some extra prompting?

Lars, note that we are not talking about a specific command like
`dired-do-rename'.  The change is to `dired-do-create-files' which is a
workhorse for many dired commands that need some target directory or
file, e.g., renaming/moving, copying, symlinking, etc.

> How about a prompt by default (e.g. "Do you want to create directory
> `foo' and move the file into it?"), with a user option to disable it
> for those that want it?

There already is `dired-create-destination-dirs'.  Only if that is
non-nil, Rudi's patch has an effect.  And if it is 'ask, you'll be
prompted if foo/ should be created already.

Of course, it won't explain the "move the marked/current file(s) into
it" part.  (Note that while we are talking about just a single source
file, it could be many.)

We could also let-bind `dired-create-destination-dirs' around the one
specific place Rudi touched so that it gets a special value
'ask-because-of-trailing-slash-in-target if it's non-nil already which
would allow `dired-maybe-create-dirs' to issue a more explanatory
message.  But then again, this could also happen with copying or
symlinking, so that message couldn't really say "move into" without
moving more context into down to `dired-maybe-create-dirs' so that it
can distinguish "move into" from "create a new symlink into" or what
else.

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-29 14:21                     ` Lars Ingebrigtsen
  2021-09-29 15:04                       ` Stefan Kangas
@ 2021-09-29 15:44                       ` Eli Zaretskii
  1 sibling, 0 replies; 55+ messages in thread
From: Eli Zaretskii @ 2021-09-29 15:44 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: rudiwillalwaysloveyou, emacs-devel, stefankangas, tsdh

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: Tassilo Horn <tsdh@gnu.org>,  rudiwillalwaysloveyou@gmail.com,
>   stefankangas@gmail.com,  emacs-devel@gnu.org
> Date: Wed, 29 Sep 2021 16:21:50 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > I'm against unconditionally changing the behavior based on the obscure
> > fact of whether the directory name ends in a slash or doesn't.  That
> > slash is ephemeral and users may not be aware to its importance, since
> > the semantics of foo/ and foo is the same more or less.
> 
> Yes, we're extremely sloppy (in a good way) when handling foo/ and foo,
> so it might be surprising behaviour to make this one command assign
> different semantics to the two forms.
> 
> But it's nice functionality.  Is there some other way we could get this
> without relying on the difference between foo and foo/?  A separate
> command, perhaps?  Or some extra prompting?

I suggested a new defcustom to turn this on.  A separate command would
also be okay.  Extra prompting is less nice, because it will also
affect those who don't want the new behavior.



^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [External] : Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-29 13:42                 ` Tassilo Horn
  2021-09-29 13:57                   ` Eli Zaretskii
@ 2021-09-29 17:01                   ` Drew Adams
  2021-09-29 19:09                     ` Tassilo Horn
  1 sibling, 1 reply; 55+ messages in thread
From: Drew Adams @ 2021-09-29 17:01 UTC (permalink / raw)
  To: Tassilo Horn, Eli Zaretskii
  Cc: rudiwillalwaysloveyou@gmail.com, stefankangas@gmail.com,
	emacs-devel@gnu.org

>   file -> 2.txt (renames plain file no matter if 2.txt already exists)
>   file -> foo   (move into foo if that's an existing dir, otherwise
>                  rename)
>   file -> foo/  (move into directory foo, creating if not existing
>                  and dired-create-destination-dirs is non-nil)
> 
> The first 2 are unchanged, the third one is the new one.

What about:  foo -> foo/

Does that move file foo to directory foo, as
foo/foo, creating directory foo if it doesn't
exist?  If not, does the doc call out that
inconsistency?  Or does it raise an error?
What does it do?



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [External] : Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-29 17:01                   ` [External] : " Drew Adams
@ 2021-09-29 19:09                     ` Tassilo Horn
  2021-09-29 19:35                       ` Drew Adams
  0 siblings, 1 reply; 55+ messages in thread
From: Tassilo Horn @ 2021-09-29 19:09 UTC (permalink / raw)
  To: Drew Adams
  Cc: Eli Zaretskii, emacs-devel, rudiwillalwaysloveyou@gmail.com,
	stefankangas@gmail.com

Drew Adams <drew.adams@oracle.com> writes:

>>   file -> 2.txt (renames plain file no matter if 2.txt already exists)
>>   file -> foo   (move into foo if that's an existing dir, otherwise
>>                  rename)
>>   file -> foo/  (move into directory foo, creating if not existing
>>                  and dired-create-destination-dirs is non-nil)
>> 
>> The first 2 are unchanged, the third one is the new one.
>
> What about:  foo -> foo/
>
> Does that move file foo to directory foo, as
> foo/foo, creating directory foo if it doesn't
> exist?

No, it errors in the same way as it does without the patch.

  Move: ‘/home/horn/tmp/foo’ to ‘/home/horn/tmp/foo/foo’ failed:
  (file-error Renaming Invalid argument /home/horn/tmp/foo /home/horn/tmp/foo/foo)

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [External] : Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-29 19:09                     ` Tassilo Horn
@ 2021-09-29 19:35                       ` Drew Adams
  0 siblings, 0 replies; 55+ messages in thread
From: Drew Adams @ 2021-09-29 19:35 UTC (permalink / raw)
  To: Tassilo Horn
  Cc: Eli Zaretskii, emacs-devel@gnu.org,
	rudiwillalwaysloveyou@gmail.com, stefankangas@gmail.com

> >>   file -> 2.txt (renames plain file no matter if 2.txt already
> >>                  exists)
> >>   file -> foo   (move into foo if that's an existing dir, otherwise
> >>                  rename)
> >>   file -> foo/  (move into directory foo, creating if not existing
> >>                  and dired-create-destination-dirs is non-nil)
> >>
> >> The first 2 are unchanged, the third one is the new one.
> >
> > What about:  foo -> foo/
> >
> > Does that move file foo to directory foo, as
> > foo/foo, creating directory foo if it doesn't
> > exist?
> 
> No, it errors in the same way as it does without the patch.

OK, good.

>   Move: ‘/home/horn/tmp/foo’ to ‘/home/horn/tmp/foo/foo’ failed:
>   (file-error Renaming Invalid argument /home/horn/tmp/foo
> /home/horn/tmp/foo/foo)

That error msg isn't so great, FWIW.  This is
a design choice.  What's the invalid argument
(which)?  It could at least say that the dir
to move to doesn't exist.

The doc should at least call this case out
where it talks about this (optional) feature
of an appended `/' creating a missing dir.

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-29 15:17                         ` Tassilo Horn
@ 2021-09-30  6:06                           ` Lars Ingebrigtsen
  2021-09-30  7:29                             ` Lars Ingebrigtsen
                                               ` (2 more replies)
  0 siblings, 3 replies; 55+ messages in thread
From: Lars Ingebrigtsen @ 2021-09-30  6:06 UTC (permalink / raw)
  To: Tassilo Horn
  Cc: Eli Zaretskii, rudiwillalwaysloveyou, Stefan Kangas, emacs-devel

Tassilo Horn <tsdh@gnu.org> writes:

> Lars, note that we are not talking about a specific command like
> `dired-do-rename'.  The change is to `dired-do-create-files' which is a
> workhorse for many dired commands that need some target directory or
> file, e.g., renaming/moving, copying, symlinking, etc.

Right.  Then it's more invasive than I thought...

Re-skimming this thread, the suggestion is that if the destination
directory ends with a slash, then that directory is created, and the
contents of the source is copied (etc) over to it?

Isn't that just about the opposite of the syntax in rsync?  That is,
"rsync foo/ bar" will copy the files in foo over to bad, while "rsync
foo bar" will copy the directory itself into bar.  (Whether you have a
slash or not at the end of the destination directory doesn't make a
difference.)

So rsync has put semantics on a trailing slash on the source dir, while
the proposal here is to add semantics in Dired to the trailing slash of
the destination dir?

I guess I'm concerned that the semantics here are too subtle (even if
we add a user option to switch between behaviours).

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-30  6:06                           ` Lars Ingebrigtsen
@ 2021-09-30  7:29                             ` Lars Ingebrigtsen
  2021-09-30  8:32                             ` Tassilo Horn
  2021-09-30 13:54                             ` Stefan Kangas
  2 siblings, 0 replies; 55+ messages in thread
From: Lars Ingebrigtsen @ 2021-09-30  7:29 UTC (permalink / raw)
  To: Tassilo Horn
  Cc: Eli Zaretskii, emacs-devel, rudiwillalwaysloveyou, Stefan Kangas

Lars Ingebrigtsen <larsi@gnus.org> writes:

> I guess I'm concerned that the semantics here are too subtle (even if
> we add a user option to switch between behaviours).

On the other hand, perhaps it does make sense.  There's some precedence
for this behaviour in Emacs -- `C-x C-w /tmp' will query you if you wish
to overwrite /tmp, while `C-x C-w /tmp/' will write to a file in /tmp/
(with the same name as the buffer name), and that seems to work without
confusing people.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-30  6:06                           ` Lars Ingebrigtsen
  2021-09-30  7:29                             ` Lars Ingebrigtsen
@ 2021-09-30  8:32                             ` Tassilo Horn
  2021-09-30 13:33                               ` Lars Ingebrigtsen
  2021-09-30 15:45                               ` [External] : " Drew Adams
  2021-09-30 13:54                             ` Stefan Kangas
  2 siblings, 2 replies; 55+ messages in thread
From: Tassilo Horn @ 2021-09-30  8:32 UTC (permalink / raw)
  To: Lars Ingebrigtsen
  Cc: Eli Zaretskii, emacs-devel, rudiwillalwaysloveyou, Stefan Kangas

Lars Ingebrigtsen <larsi@gnus.org> writes:

Hi Lars,

>> Lars, note that we are not talking about a specific command like
>> `dired-do-rename'.  The change is to `dired-do-create-files' which is a
>> workhorse for many dired commands that need some target directory or
>> file, e.g., renaming/moving, copying, symlinking, etc.
>
> Right.  Then it's more invasive than I thought...
>
> Re-skimming this thread, the suggestion is that if the destination
> directory ends with a slash, then that directory is created, and the
> contents of the source is copied (etc) over to it?

Right.  And the creation of a target directory is nothing new but
already exists if `dired-create-destination-dirs' is non-nil.  For
example, when you now (without the patch) copy file.txt to bar/foo where
bar/ doesn't exist, you'll be queried if dired should create it if the
variable is 'ask.  If it is 'always, dired just creates it.  Finally
bar/foo is a normal file, i.e., a copy of file.txt.

With Rudi's patch, it's exactly the same when the destination is
foo/bar.  But if you specify foo/bar/ as destination, dired will create
foo/bar/ (maybe after asking as controlled by
`dired-create-destination-dirs') and you get foo/bar/file.txt.

So basically the trailing / is an indicator to tell dired that the
target must be a directory, and then the `dired-create-destination-dirs'
semantics can apply.  Without the /, dired cannot know.

Therefore, the feature seems very natural to me.  I'm fine with guarding
it with a defcustom if you all feel that many users would type a
trailing / out of habit.  But since the change only triggers if the
directory does not exist yet, the only scenario where it can bite you is
when renaming or copying a directory to a new one and you specify the
new one with trailing / (which completion will never do because there's
no completion for non-existing directories).

> Isn't that just about the opposite of the syntax in rsync?

Sorry, I don't have a lot of rsync experience.  And to me, it's not
really important that dired conforms to rsync conventions.  Instead it
should conform to its own documentation we already have right now.

--8<---------------cut here---------------start------------->8---
dired-create-destination-dirs is a variable defined in ‘dired-aux.el’.

Its value is ‘ask’
Original value was nil

Whether Dired should create destination dirs when copying/removing files.
If nil, don’t create them.
If ‘always’, create them without asking.
If ‘ask’, ask for user confirmation.
--8<---------------cut here---------------end--------------->8---

So when I copy/rename something to the non-existent bar/foo/baz/ where
it's absolutely clear that it's a directory, why on earth should dired
not create it?  I would argue that with Rudi's patch the behavior
conforms more to the current docs than the non-patched dired.

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-30  8:32                             ` Tassilo Horn
@ 2021-09-30 13:33                               ` Lars Ingebrigtsen
  2021-09-30 14:10                                 ` Tassilo Horn
  2021-09-30 15:45                               ` [External] : " Drew Adams
  1 sibling, 1 reply; 55+ messages in thread
From: Lars Ingebrigtsen @ 2021-09-30 13:33 UTC (permalink / raw)
  To: Tassilo Horn
  Cc: Eli Zaretskii, emacs-devel, rudiwillalwaysloveyou, Stefan Kangas

Tassilo Horn <tsdh@gnu.org> writes:

> With Rudi's patch, it's exactly the same when the destination is
> foo/bar.  But if you specify foo/bar/ as destination, dired will create
> foo/bar/ (maybe after asking as controlled by
> `dired-create-destination-dirs') and you get foo/bar/file.txt.

That does seem quite intuitive and attractive (and is somewhat analogous
to what Emacs does with `C-x C-w' today).

OK, you've convinced me.  Adding a user option like
`dired-create-destination-dirs' (as Eli said) is probably the best,
though.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-30  6:06                           ` Lars Ingebrigtsen
  2021-09-30  7:29                             ` Lars Ingebrigtsen
  2021-09-30  8:32                             ` Tassilo Horn
@ 2021-09-30 13:54                             ` Stefan Kangas
  2021-09-30 13:59                               ` Lars Ingebrigtsen
  2 siblings, 1 reply; 55+ messages in thread
From: Stefan Kangas @ 2021-09-30 13:54 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Eli Zaretskii, Emacs developers, Rudi C, Tassilo Horn

Den tors 30 sep. 2021 kl 08:06 skrev Lars Ingebrigtsen <larsi@gnus.org>:

> Isn't that just about the opposite of the syntax in rsync?  That is,
> "rsync foo/ bar" will copy the files in foo over to bad, while "rsync
> foo bar" will copy the directory itself into bar.  (Whether you have a
> slash or not at the end of the destination directory doesn't make a
> difference.)

Having a slash at the end of the destination directory *is*
significant with rsync:

$ touch foo
$ ls bar
ls: bar: No such file or directory
$ rsync foo bar/
$ ls -al bar
total 0
drwxr-xr-x  3 skangas  wheel   96 Sep 30 15:50 .
drwxr-xr-x  4 skangas  wheel  128 Sep 30 15:50 ..
-rw-r--r--  1 skangas  wheel    0 Sep 30 15:50 foo



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-30 13:54                             ` Stefan Kangas
@ 2021-09-30 13:59                               ` Lars Ingebrigtsen
  0 siblings, 0 replies; 55+ messages in thread
From: Lars Ingebrigtsen @ 2021-09-30 13:59 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: Eli Zaretskii, Emacs developers, Rudi C, Tassilo Horn

Stefan Kangas <stefankangas@gmail.com> writes:

> Having a slash at the end of the destination directory *is*
> significant with rsync:
>
> $ touch foo
> $ ls bar
> ls: bar: No such file or directory
> $ rsync foo bar/
> $ ls -al bar
> total 0
> drwxr-xr-x  3 skangas  wheel   96 Sep 30 15:50 .
> drwxr-xr-x  4 skangas  wheel  128 Sep 30 15:50 ..
> -rw-r--r--  1 skangas  wheel    0 Sep 30 15:50 foo

I was thinking of the "rsync -a" thing.  "rsync -a d1 d2" and
"rsync -a d1 d2/" does the same.  (d1 is a directory and d2 doesn't
exist in this scenario.)

(Adding a slash to d1 does change what's happening.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-30 13:33                               ` Lars Ingebrigtsen
@ 2021-09-30 14:10                                 ` Tassilo Horn
  2021-09-30 16:03                                   ` Eli Zaretskii
  0 siblings, 1 reply; 55+ messages in thread
From: Tassilo Horn @ 2021-09-30 14:10 UTC (permalink / raw)
  To: Lars Ingebrigtsen
  Cc: Eli Zaretskii, emacs-devel, rudiwillalwaysloveyou, Stefan Kangas

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Tassilo Horn <tsdh@gnu.org> writes:
>
>> With Rudi's patch, it's exactly the same when the destination is
>> foo/bar.  But if you specify foo/bar/ as destination, dired will create
>> foo/bar/ (maybe after asking as controlled by
>> `dired-create-destination-dirs') and you get foo/bar/file.txt.
>
> That does seem quite intuitive and attractive (and is somewhat
> analogous to what Emacs does with `C-x C-w' today).

Right.

> OK, you've convinced me.  Adding a user option like
> `dired-create-destination-dirs' (as Eli said) is probably the best,
> though.

`dired-create-destination-dirs' already exists.  But in Rudi's most
recent patch version, he added a new one.

--8<---------------cut here---------------start------------->8---
+(defcustom dired-create-destination-dirs-trailing-separator-special nil
+  "If t, when selecting a single destination in Dired, paths that end in a path separator will be treated as a non-existent directory, and acted on according to `dired-create-destination-dirs'.
+
+This option is only relevant if `dired-create-destination-dirs' is not `nil', and you are moving/copying a single directory.
+
+For example, when renaming a directory named `old_name' to `new_name/' (note the trailing path separator), `new_name' might be created depending on `dired-create-destination-dirs' and `old_name' will be moved into it if it is created; Otherwise `old_name' will be directly renamed to `new_name'."
+  :type '(choice (const :tag "Do not treat paths with a trailing path separator specially" nil)
+                 (const :tag "Treat paths with a trailing path separator specially" t))
+  :group 'dired
+  :version "28.1")
--8<---------------cut here---------------end--------------->8---

I still think that this is not really necessary but won't object.

Rudi proposed that the default value should probably be `t' given that
this feels so intuitive and the only gotcha is renaming/moving or
copying a directory source/ to a non-existent target or target/ where
the former has rename/make a copy semantics and the latter has move/copy
*into* the to be created target/ directory.

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [External] : Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-30  8:32                             ` Tassilo Horn
  2021-09-30 13:33                               ` Lars Ingebrigtsen
@ 2021-09-30 15:45                               ` Drew Adams
  1 sibling, 0 replies; 55+ messages in thread
From: Drew Adams @ 2021-09-30 15:45 UTC (permalink / raw)
  To: Tassilo Horn, Lars Ingebrigtsen
  Cc: Eli Zaretskii, Stefan Kangas, rudiwillalwaysloveyou@gmail.com,
	emacs-devel@gnu.org

> With Rudi's patch, it's exactly the same when the destination is
> foo/bar.  But if you specify foo/bar/ as destination, dired will create
> foo/bar/ (maybe after asking as controlled by
> `dired-create-destination-dirs') and you get foo/bar/file.txt.
> 
> So basically the trailing / is an indicator to tell dired that the
> target must be a directory, and then the `dired-create-destination-
> dirs' semantics can apply.  Without the /, dired cannot know.

Except for the case where the "missing directory" part has the
same name as the file to be acted on (for the proposed feature
apparently, and also for the existing behavior of
`dired-create-destination-dirs').

You've confirmed that Emacs just raises an error in that case
for the new feature, and that's also what it does anyway for
the existing case of trying to copy (or move or whatever) file
`aaa' in dir `foo' to `foo/aaa/aaa/', where subdir `foo/aaa'
doesn't exist.  Emacs doesn't ask you to create the subdir if
`dired-create-destination-dirs' is `ask', and it doesn't create
it if that option value is t.  It always raises an error.

Whether such behavior is good, or the best, is another
question. But at least (IIUC) the proposed behavior is the
consistent with what we already have.

(However, the error message isn't ideal: "Cannot copy to same
file: ABS-DIR-FOR/foo/aaa".  Since, by the convention, the user
has specified a missing dir, the message should say that that
dir, .../foo/aaa, is missing, or something similar.)

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-30 14:10                                 ` Tassilo Horn
@ 2021-09-30 16:03                                   ` Eli Zaretskii
  2021-09-30 16:48                                     ` Tassilo Horn
  0 siblings, 1 reply; 55+ messages in thread
From: Eli Zaretskii @ 2021-09-30 16:03 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: larsi, stefankangas, rudiwillalwaysloveyou, emacs-devel

> From: Tassilo Horn <tsdh@gnu.org>
> Date: Thu, 30 Sep 2021 16:10:02 +0200
> Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org,
>  rudiwillalwaysloveyou@gmail.com, Stefan Kangas <stefankangas@gmail.com>
> 
> `dired-create-destination-dirs' already exists.  But in Rudi's most
> recent patch version, he added a new one.
> 
> --8<---------------cut here---------------start------------->8---
> +(defcustom dired-create-destination-dirs-trailing-separator-special nil

That's a mouthful, IMO.  How about

  dired-create-dirs-with-trailing-slash

instead?

> Rudi proposed that the default value should probably be `t' given that
> this feels so intuitive and the only gotcha is renaming/moving or
> copying a directory source/ to a non-existent target or target/ where
> the former has rename/make a copy semantics and the latter has move/copy
> *into* the to be created target/ directory.

Please don't make it t by default.  I'm quite sure you didn't consider
all the use cases.  E.g., what about foo -> Foo on case-insensitive
filesystems?  That is a valid use case where the user wants a
directory renamed with a different letter-case.

We should only turn it on by default after it has been tested by
enough users for long enough.



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-30 16:03                                   ` Eli Zaretskii
@ 2021-09-30 16:48                                     ` Tassilo Horn
  2021-09-30 17:47                                       ` Eli Zaretskii
  0 siblings, 1 reply; 55+ messages in thread
From: Tassilo Horn @ 2021-09-30 16:48 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: larsi, emacs-devel, stefankangas, rudiwillalwaysloveyou

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Tassilo Horn <tsdh@gnu.org>
>> Date: Thu, 30 Sep 2021 16:10:02 +0200
>> Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org,
>>  rudiwillalwaysloveyou@gmail.com, Stefan Kangas <stefankangas@gmail.com>
>> 
>> `dired-create-destination-dirs' already exists.  But in Rudi's most
>> recent patch version, he added a new one.
>> 
>> --8<---------------cut here---------------start------------->8---
>> +(defcustom dired-create-destination-dirs-trailing-separator-special nil
>
> That's a mouthful, IMO.  How about
>
>   dired-create-dirs-with-trailing-slash
>
> instead?

Fine with me.  Rudi, could you please rework that suggestion into your
latest patch?

And please also adjust the docstring of the new option so that it
conforms to our conventions, i.e., first line is a complete sentence
(try M-x checkdoc RET), and everything is filled at column 70.

>> Rudi proposed that the default value should probably be `t' given
>> that this feels so intuitive and the only gotcha is renaming/moving
>> or copying a directory source/ to a non-existent target or target/
>> where the former has rename/make a copy semantics and the latter has
>> move/copy *into* the to be created target/ directory.
>
> Please don't make it t by default.

Ok.

> I'm quite sure you didn't consider all the use cases.  E.g., what
> about foo -> Foo on case-insensitive filesystems?  That is a valid use
> case where the user wants a directory renamed with a different
> letter-case.

You mean, you'd TAB-complete to the same name foo/ and then capitalize
the already completed input so that you then have Foo/ with the slash?
I can see that one might do that if the name is quite long.  And that
use-case would also apply to case-sensitive filesystems.

So fine, let's have if off by default.

> We should only turn it on by default after it has been tested by
> enough users for long enough.

Allright.

BTW, do we need a copyright assignment for this patch?  The actual
change is about 5 lines (including reformatting) but the new defcustom
is about a dozen of lines with docstring, and stuff.

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-30 16:48                                     ` Tassilo Horn
@ 2021-09-30 17:47                                       ` Eli Zaretskii
  2021-09-30 18:52                                         ` Rudi C
  2021-11-01 15:37                                         ` Rudi C
  0 siblings, 2 replies; 55+ messages in thread
From: Eli Zaretskii @ 2021-09-30 17:47 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: larsi, emacs-devel, stefankangas, rudiwillalwaysloveyou

> From: Tassilo Horn <tsdh@gnu.org>
> Cc: larsi@gnus.org, stefankangas@gmail.com, rudiwillalwaysloveyou@gmail.com,
>  emacs-devel@gnu.org
> Date: Thu, 30 Sep 2021 18:48:13 +0200
> 
> > I'm quite sure you didn't consider all the use cases.  E.g., what
> > about foo -> Foo on case-insensitive filesystems?  That is a valid use
> > case where the user wants a directory renamed with a different
> > letter-case.
> 
> You mean, you'd TAB-complete to the same name foo/ and then capitalize
> the already completed input so that you then have Foo/ with the slash?
> I can see that one might do that if the name is quite long.  And that
> use-case would also apply to case-sensitive filesystems.

On case-sensitive filesystems, the new directory would not exist.

> So fine, let's have if off by default.

Thanks.

> BTW, do we need a copyright assignment for this patch?  The actual
> change is about 5 lines (including reformatting) but the new defcustom
> is about a dozen of lines with docstring, and stuff.

No, we can accept it without an assignment, but that about exhausts
our ability to accept more contributions from Rudi, so I recommend
starting the paperwork now.



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-30 17:47                                       ` Eli Zaretskii
@ 2021-09-30 18:52                                         ` Rudi C
  2021-09-30 19:02                                           ` Eli Zaretskii
  2021-11-01 15:37                                         ` Rudi C
  1 sibling, 1 reply; 55+ messages in thread
From: Rudi C @ 2021-09-30 18:52 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: larsi, emacs-devel, stefankangas, Tassilo Horn

[-- Attachment #1: Type: text/plain, Size: 1543 bytes --]

> starting the paperwork now.

As I'm in my early twenties, I will hopefully have more contributions down
the line, so that's a good idea.

I am an Iranian citizen, if that matters. Is it all doable with email, or
is physical mailing also required?


On Thu, Sep 30, 2021 at 9:17 PM Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Tassilo Horn <tsdh@gnu.org>
> > Cc: larsi@gnus.org, stefankangas@gmail.com,
> rudiwillalwaysloveyou@gmail.com,
> >  emacs-devel@gnu.org
> > Date: Thu, 30 Sep 2021 18:48:13 +0200
> >
> > > I'm quite sure you didn't consider all the use cases.  E.g., what
> > > about foo -> Foo on case-insensitive filesystems?  That is a valid use
> > > case where the user wants a directory renamed with a different
> > > letter-case.
> >
> > You mean, you'd TAB-complete to the same name foo/ and then capitalize
> > the already completed input so that you then have Foo/ with the slash?
> > I can see that one might do that if the name is quite long.  And that
> > use-case would also apply to case-sensitive filesystems.
>
> On case-sensitive filesystems, the new directory would not exist.
>
> > So fine, let's have if off by default.
>
> Thanks.
>
> > BTW, do we need a copyright assignment for this patch?  The actual
> > change is about 5 lines (including reformatting) but the new defcustom
> > is about a dozen of lines with docstring, and stuff.
>
> No, we can accept it without an assignment, but that about exhausts
> our ability to accept more contributions from Rudi, so I recommend
> starting the paperwork now.
>

[-- Attachment #2: Type: text/html, Size: 2359 bytes --]

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-30 18:52                                         ` Rudi C
@ 2021-09-30 19:02                                           ` Eli Zaretskii
  0 siblings, 0 replies; 55+ messages in thread
From: Eli Zaretskii @ 2021-09-30 19:02 UTC (permalink / raw)
  To: Rudi C; +Cc: larsi, emacs-devel, stefankangas, tsdh

> From: Rudi C <rudiwillalwaysloveyou@gmail.com>
> Date: Thu, 30 Sep 2021 22:22:32 +0330
> Cc: Tassilo Horn <tsdh@gnu.org>, larsi@gnus.org, stefankangas@gmail.com, 
> 	emacs-devel@gnu.org
> 
> > starting the paperwork now.
> 
> As I'm in my early twenties, I will hopefully have more contributions down the line, so that's a good idea.
> 
> I am an Iranian citizen, if that matters. Is it all doable with email, or is physical mailing also required?

I think nowadays everything is done in email.

I will send you the form off-list.



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-09-30 17:47                                       ` Eli Zaretskii
  2021-09-30 18:52                                         ` Rudi C
@ 2021-11-01 15:37                                         ` Rudi C
  2021-11-02 14:44                                           ` Lars Ingebrigtsen
  1 sibling, 1 reply; 55+ messages in thread
From: Rudi C @ 2021-11-01 15:37 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Lars Ingebrigtsen, emacs-devel, Stefan Kangas, Tassilo Horn

[-- Attachment #1: Type: text/plain, Size: 1355 bytes --]

My copyright assignment is now done, so we can merge this in.

On Thu, Sep 30, 2021 at 9:17 PM Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Tassilo Horn <tsdh@gnu.org>
> > Cc: larsi@gnus.org, stefankangas@gmail.com,
> rudiwillalwaysloveyou@gmail.com,
> >  emacs-devel@gnu.org
> > Date: Thu, 30 Sep 2021 18:48:13 +0200
> >
> > > I'm quite sure you didn't consider all the use cases.  E.g., what
> > > about foo -> Foo on case-insensitive filesystems?  That is a valid use
> > > case where the user wants a directory renamed with a different
> > > letter-case.
> >
> > You mean, you'd TAB-complete to the same name foo/ and then capitalize
> > the already completed input so that you then have Foo/ with the slash?
> > I can see that one might do that if the name is quite long.  And that
> > use-case would also apply to case-sensitive filesystems.
>
> On case-sensitive filesystems, the new directory would not exist.
>
> > So fine, let's have if off by default.
>
> Thanks.
>
> > BTW, do we need a copyright assignment for this patch?  The actual
> > change is about 5 lines (including reformatting) but the new defcustom
> > is about a dozen of lines with docstring, and stuff.
>
> No, we can accept it without an assignment, but that about exhausts
> our ability to accept more contributions from Rudi, so I recommend
> starting the paperwork now.
>

[-- Attachment #2: Type: text/html, Size: 2098 bytes --]

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-11-01 15:37                                         ` Rudi C
@ 2021-11-02 14:44                                           ` Lars Ingebrigtsen
  2021-11-02 15:08                                             ` Rudi C
  0 siblings, 1 reply; 55+ messages in thread
From: Lars Ingebrigtsen @ 2021-11-02 14:44 UTC (permalink / raw)
  To: Rudi C; +Cc: Eli Zaretskii, emacs-devel, Stefan Kangas, Tassilo Horn

Rudi C <rudiwillalwaysloveyou@gmail.com> writes:

> My copyright assignment is now done, so we can merge this in.

Can you re-send the current version of the patch (there were several
versions, if I remember correctly)?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-11-02 14:44                                           ` Lars Ingebrigtsen
@ 2021-11-02 15:08                                             ` Rudi C
  2021-11-02 15:15                                               ` Eli Zaretskii
  0 siblings, 1 reply; 55+ messages in thread
From: Rudi C @ 2021-11-02 15:08 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Eli Zaretskii, emacs-devel, Stefan Kangas, Tassilo Horn


[-- Attachment #1.1: Type: text/plain, Size: 678 bytes --]

Well, there are two commits, the first one adds the new behavior, and the
second one moves the new behavior behind a new option. I can't find any way
to merge the patch files without the original repo, and I no longer have
the emacs git source on my computer.


On Tue, Nov 2, 2021 at 6:14 PM Lars Ingebrigtsen <larsi@gnus.org> wrote:

> Rudi C <rudiwillalwaysloveyou@gmail.com> writes:
>
> > My copyright assignment is now done, so we can merge this in.
>
> Can you re-send the current version of the patch (there were several
> versions, if I remember correctly)?
>
> --
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no
>

[-- Attachment #1.2: Type: text/html, Size: 1180 bytes --]

[-- Attachment #2: 0001-dired-do-create-files-now-checks-for-trailing-slashe.patch --]
[-- Type: application/octet-stream, Size: 986 bytes --]

From 951e12f352b783b15edbabb4623a5c721425bd25 Mon Sep 17 00:00:00 2001
From: NightMachinary <rudiwillalwaysloveyou@gmail.com>
Date: Tue, 28 Sep 2021 21:14:05 +0330
Subject: [PATCH 1/2] dired-do-create-files now checks for trailing slashes in
 the target

---
 lisp/dired-aux.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 397c5c67cb..fcaa8dd008 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -2157,7 +2157,9 @@ Optional arg HOW-TO determines how to treat the target.
 		     target-dir op-symbol arg rfn-list default))))
 	 (into-dir
           (progn
-            (unless dired-one-file (dired-maybe-create-dirs target))
+            (when (or (not dired-one-file)
+                      (directory-name-p target))
+              (dired-maybe-create-dirs target))
             (cond ((null how-to)
 		   ;; Allow users to change the letter case of
 		   ;; a directory on a case-insensitive
-- 
2.32.0


[-- Attachment #3: 0002-Added-option-dired-create-destination-dirs-trailing-.patch --]
[-- Type: application/octet-stream, Size: 2312 bytes --]

From 7a680d06e4b6ecf9e88e1c309f214d4e1a7f8700 Mon Sep 17 00:00:00 2001
From: NightMachinary <rudiwillalwaysloveyou@gmail.com>
Date: Wed, 29 Sep 2021 17:54:29 +0330
Subject: [PATCH 2/2] Added option
 dired-create-destination-dirs-trailing-separator-special

---
 lisp/dired-aux.el | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index fcaa8dd008..ee727ec5cc 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -1789,6 +1789,17 @@ If `ask', ask for user confirmation."
   :group 'dired
   :version "27.1")
 
+(defcustom dired-create-destination-dirs-trailing-separator-special nil
+  "If t, when selecting a single destination in Dired, paths that end in a path separator will be treated as a non-existent directory, and acted on according to `dired-create-destination-dirs'.
+
+This option is only relevant if `dired-create-destination-dirs' is not `nil', and you are moving/copying a single directory.
+
+For example, when renaming a directory named `old_name' to `new_name/' (note the trailing path separator), `new_name' might be created depending on `dired-create-destination-dirs' and `old_name' will be moved into it if it is created; Otherwise `old_name' will be directly renamed to `new_name'."
+  :type '(choice (const :tag "Do not treat paths with a trailing path separator specially" nil)
+                 (const :tag "Treat paths with a trailing path separator specially" t))
+  :group 'dired
+  :version "28.1")
+
 (defun dired-maybe-create-dirs (dir)
   "Create DIR if doesn't exist according to `dired-create-destination-dirs'."
   (when (and dired-create-destination-dirs (not (file-exists-p dir)))
@@ -2157,8 +2168,11 @@ Optional arg HOW-TO determines how to treat the target.
 		     target-dir op-symbol arg rfn-list default))))
 	 (into-dir
           (progn
-            (when (or (not dired-one-file)
-                      (directory-name-p target))
+            (when
+                (or
+                 (not dired-one-file)
+                 (and dired-create-destination-dirs-trailing-separator-special
+                      (directory-name-p target)))
               (dired-maybe-create-dirs target))
             (cond ((null how-to)
 		   ;; Allow users to change the letter case of
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-11-02 15:08                                             ` Rudi C
@ 2021-11-02 15:15                                               ` Eli Zaretskii
  2021-11-09 12:52                                                 ` Rudi C
  0 siblings, 1 reply; 55+ messages in thread
From: Eli Zaretskii @ 2021-11-02 15:15 UTC (permalink / raw)
  To: Rudi C; +Cc: larsi, emacs-devel, stefankangas, tsdh

> From: Rudi C <rudiwillalwaysloveyou@gmail.com>
> Date: Tue, 2 Nov 2021 18:38:08 +0330
> Cc: Eli Zaretskii <eliz@gnu.org>, Tassilo Horn <tsdh@gnu.org>, Stefan Kangas <stefankangas@gmail.com>, 
> 	emacs-devel@gnu.org
> 
> +(defcustom dired-create-destination-dirs-trailing-separator-special nil

This variable's name is a mouthful; please let's find a shorter name.

> +  "If t, when selecting a single destination in Dired, paths that end in a path separator will be treated as a non-existent directory, and acted on according to `dired-create-destination-dirs'.
> +
> +This option is only relevant if `dired-create-destination-dirs' is not `nil', and you are moving/copying a single directory.
> +
> +For example, when renaming a directory named `old_name' to `new_name/' (note the trailing path separator), `new_name' might be created depending on `dired-create-destination-dirs' and `old_name' will be moved into it if it is created; Otherwise `old_name' will be directly renamed to `new_name'."
> +  :type '(choice (const :tag "Do not treat paths with a trailing path separator specially" nil)

These lines are too long; please divide them into shorter lines.



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-11-02 15:15                                               ` Eli Zaretskii
@ 2021-11-09 12:52                                                 ` Rudi C
  2021-11-09 13:47                                                   ` Eli Zaretskii
  2021-12-05 12:12                                                   ` Tassilo Horn
  0 siblings, 2 replies; 55+ messages in thread
From: Rudi C @ 2021-11-09 12:52 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: larsi, emacs-devel, stefankangas, tsdh


[-- Attachment #1.1: Type: text/plain, Size: 1578 bytes --]

Okay, I have attached a new patch (no need for the previous patches).

PS: I inserted newlines into the docstring to make the lines shorter, but
this makes the docstring ugly to view (as it is essentially hardwrapping
based on an arbitrary column size that the user's screen will not share).

On Tue, Nov 2, 2021 at 6:45 PM Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Rudi C <rudiwillalwaysloveyou@gmail.com>
> > Date: Tue, 2 Nov 2021 18:38:08 +0330
> > Cc: Eli Zaretskii <eliz@gnu.org>, Tassilo Horn <tsdh@gnu.org>, Stefan
> Kangas <stefankangas@gmail.com>,
> >       emacs-devel@gnu.org
> >
> > +(defcustom dired-create-destination-dirs-trailing-separator-special nil
>
> This variable's name is a mouthful; please let's find a shorter name.
>
> > +  "If t, when selecting a single destination in Dired, paths that end
> in a path separator will be treated as a non-existent directory, and acted
> on according to `dired-create-destination-dirs'.
> > +
> > +This option is only relevant if `dired-create-destination-dirs' is not
> `nil', and you are moving/copying a single directory.
> > +
> > +For example, when renaming a directory named `old_name' to `new_name/'
> (note the trailing path separator), `new_name' might be created depending
> on `dired-create-destination-dirs' and `old_name' will be moved into it if
> it is created; Otherwise `old_name' will be directly renamed to `new_name'."
> > +  :type '(choice (const :tag "Do not treat paths with a trailing path
> separator specially" nil)
>
> These lines are too long; please divide them into shorter lines.
>

[-- Attachment #1.2: Type: text/html, Size: 2363 bytes --]

[-- Attachment #2: 0001-Added-dired-create-dirs-trailing-separator.patch --]
[-- Type: application/octet-stream, Size: 2294 bytes --]

From 3dfea8f43a45473138d9d3d9716658390957b494 Mon Sep 17 00:00:00 2001
From: NightMachinary <rudiwillalwaysloveyou@gmail.com>
Date: Tue, 9 Nov 2021 16:19:45 +0330
Subject: [PATCH] Added: dired-create-dirs-trailing-separator

---
 lisp/dired-aux.el | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index ef299b21fd..064d9eba8d 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -1789,6 +1789,25 @@ If `ask', ask for user confirmation."
   :group 'dired
   :version "27.1")
 
+(defcustom dired-create-dirs-trailing-separator nil
+  "If t, when selecting a single destination in Dired,
+paths that end in a path separator will be treated as a non-existent directory,
+and acted on according to `dired-create-destination-dirs'.
+
+This option is only relevant if `dired-create-destination-dirs' is not `nil',
+and you are moving/copying a single directory.
+
+For example, when renaming a directory named `old_name' to `new_name/'
+(note the trailing path separator), `new_name' might be created depending on
+`dired-create-destination-dirs' and `old_name' will be moved into it
+if it is created; Otherwise `old_name' will be directly renamed to `new_name'."
+  :type '(choice
+          (const :tag
+                 "Do not treat paths with a trailing path separator specially" nil)
+          (const :tag "Treat paths with a trailing path separator specially" t))
+  :group 'dired
+  :version "28.1")
+
 (defun dired-maybe-create-dirs (dir)
   "Create DIR if doesn't exist according to `dired-create-destination-dirs'."
   (when (and dired-create-destination-dirs (not (file-exists-p dir)))
@@ -2157,7 +2176,12 @@ Optional arg HOW-TO determines how to treat the target.
 		     target-dir op-symbol arg rfn-list default))))
 	 (into-dir
           (progn
-            (unless dired-one-file (dired-maybe-create-dirs target))
+            (when
+                (or
+                 (not dired-one-file)
+                 (and dired-create-dirs-trailing-separator
+                      (directory-name-p target)))
+              (dired-maybe-create-dirs target))
             (cond ((null how-to)
 		   ;; Allow users to change the letter case of
 		   ;; a directory on a case-insensitive
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-11-09 12:52                                                 ` Rudi C
@ 2021-11-09 13:47                                                   ` Eli Zaretskii
  2021-12-05 12:12                                                   ` Tassilo Horn
  1 sibling, 0 replies; 55+ messages in thread
From: Eli Zaretskii @ 2021-11-09 13:47 UTC (permalink / raw)
  To: Rudi C; +Cc: larsi, emacs-devel, stefankangas, tsdh

> From: Rudi C <rudiwillalwaysloveyou@gmail.com>
> Date: Tue, 9 Nov 2021 16:22:59 +0330
> Cc: larsi@gnus.org, tsdh@gnu.org, stefankangas@gmail.com, emacs-devel@gnu.org
> 
> Okay, I have attached a new patch (no need for the previous patches).

Thanks.

> PS: I inserted newlines into the docstring to make the lines shorter, but this makes the docstring ugly to view
> (as it is essentially hardwrapping based on an arbitrary column size that the user's screen will not share). 

No, that's not TRT.  The first line of a doc string should be a
complete sentence, and it should be a summary of what the variable or
the function does.  That's because some Help commands display only
that first line to the user.  See below.

> +(defcustom dired-create-dirs-trailing-separator nil
> +  "If t, when selecting a single destination in Dired,
> +paths that end in a path separator will be treated as a non-existent directory,
> +and acted on according to `dired-create-destination-dirs'.

Here, I'd rephrase:

    "If non-nil, create missing directories when copying or moving in Dired.
  If this variable is non-nil, and the destination of a move or a copy
  operation in Dired is a directory name, i.e. it ends in a slash, Dired
  will create the destination if it doesn't already exist, provided that
  `dired-create-destination-dirs' says so."

Additional comments:

  . we don't use "path" for anything except PATH-style directory
    lists; the GNU Coding Standards frown on using that to mean "file
    name" or "directory name"
  . instead of "path separator" (which could be confused with the
    colon which separates directories in PATH), use "slash" or
    "directory separator"

> +For example, when renaming a directory named `old_name' to `new_name/'
> +(note the trailing path separator), `new_name' might be created depending on

"path separator" again

> +`dired-create-destination-dirs' and `old_name' will be moved into it
> +if it is created; Otherwise `old_name' will be directly renamed to `new_name'."

The "Otherwise" part should not be capitalized here.

> +  :type '(choice
> +          (const :tag
> +                 "Do not treat paths with a trailing path separator specially" nil)
> +          (const :tag "Treat paths with a trailing path separator specially" t))

Once again, "paths" used for file names.  Also, "treat specially" is a
riddle: it doesn't explain the effect of the setting.  I suggest the
following descriptions instead:

  "Create missing destination directories on copy/move."
  "Do not create missing destination directories."

OK?



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-11-09 12:52                                                 ` Rudi C
  2021-11-09 13:47                                                   ` Eli Zaretskii
@ 2021-12-05 12:12                                                   ` Tassilo Horn
  2021-12-05 13:26                                                     ` Rudi C
  2021-12-05 20:24                                                     ` Lars Ingebrigtsen
  1 sibling, 2 replies; 55+ messages in thread
From: Tassilo Horn @ 2021-12-05 12:12 UTC (permalink / raw)
  To: Rudi C; +Cc: Eli Zaretskii, emacs-devel, larsi, stefankangas

[-- Attachment #1: Type: text/plain, Size: 735 bytes --]

Rudi C <rudiwillalwaysloveyou@gmail.com> writes:

Hi all,

> Okay, I have attached a new patch (no need for the previous patches).

since it seems that no progress has been made on this issue and the only
remaining stuff is just adapting the patch to our conventions, I
reworked Rudi's last version of the patch (while keeping him as the
author, of course).

Would the following be acceptable for master?  If so, I'd volunteer to
extend the dired docs wrt. the new feature.  (I have to confess I've
made the new option's name longer again but IMHO a slightly longer but
more descriptive name is no real burden.  Especially since it pairs with
dired-create-destination-dirs, it's good when it's named very
similarly.)

Thanks,
Tassilo


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Added-dired-create-destination-dirs-on-trailing-dirs.patch --]
[-- Type: text/x-patch, Size: 3331 bytes --]

From 8d957061a9cd0e6924558c2634932a8d08a92975 Mon Sep 17 00:00:00 2001
From: NightMachinary <rudiwillalwaysloveyou@gmail.com>
Date: Tue, 9 Nov 2021 16:19:45 +0330
Subject: [PATCH] Added dired-create-destination-dirs-on-trailing-dirsep

* lisp/dired-aux.el
(dired-create-destination-dirs-on-trailing-dirsep): New customization
option.
(dired-do-create-files): Use it.
(dired-create-destination-dirs): Mention the new option in the
docstring.
---
 lisp/dired-aux.el | 42 ++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 40 insertions(+), 2 deletions(-)

diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 588551a641..af7b160c1a 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -1787,13 +1787,46 @@ dired-create-destination-dirs
   "Whether Dired should create destination dirs when copying/removing files.
 If nil, don't create them.
 If `always', create them without asking.
-If `ask', ask for user confirmation."
+If `ask', ask for user confirmation.
+
+Also see `dired-create-destination-dirs-on-trailing-dirsep'."
   :type '(choice (const :tag "Never create non-existent dirs" nil)
 		 (const :tag "Always create non-existent dirs" always)
 		 (const :tag "Ask for user confirmation" ask))
   :group 'dired
   :version "27.1")
 
+(defcustom dired-create-destination-dirs-on-trailing-dirsep nil
+  "If non-nil, treat a trailing slash at queried destination dir specially.
+
+If this variable is non-nil and a single destination filename is
+queried which ends in a directory separator (/), it will be
+treated as a non-existent directory and acted on according to
+`dired-create-destination-dirs'.
+
+This option is only relevant if `dired-create-destination-dirs'
+is non-nil, too.
+
+For example, if both `dired-create-destination-dirs' and this
+option are non-nil, renaming a directory named `old_name' to
+`new_name/' (note the trailing directory separator) where
+`new_name' does not exists already, it will be created and
+`old_name' be moved into it.  If only `new_name' (without the
+trailing /) is given or this option or
+`dired-create-destination-dirs' is `nil', `old_name' will be
+renamed to `new_name'."
+  :type '(choice
+          (const :tag
+                 (concat "Do not treat destination dirs with a "
+                         "trailing directory separator specially")
+                 nil)
+          (const :tag
+                 (concat "Treat destination dirs with trailing "
+                         "directory separator specially")
+                 t))
+  :group 'dired
+  :version "29.1")
+
 (defun dired-maybe-create-dirs (dir)
   "Create DIR if doesn't exist according to `dired-create-destination-dirs'."
   (when (and dired-create-destination-dirs (not (file-exists-p dir)))
@@ -2163,7 +2196,12 @@ dired-do-create-files
 		     target-dir op-symbol arg rfn-list default))))
 	 (into-dir
           (progn
-            (unless dired-one-file (dired-maybe-create-dirs target))
+            (when
+                (or
+                 (not dired-one-file)
+                 (and dired-create-destination-dirs-on-trailing-dirsep
+                      (directory-name-p target)))
+              (dired-maybe-create-dirs target))
             (cond ((null how-to)
 		   ;; Allow users to change the letter case of
 		   ;; a directory on a case-insensitive
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-12-05 12:12                                                   ` Tassilo Horn
@ 2021-12-05 13:26                                                     ` Rudi C
  2021-12-05 17:00                                                       ` Tassilo Horn
  2021-12-06  4:34                                                       ` Richard Stallman
  2021-12-05 20:24                                                     ` Lars Ingebrigtsen
  1 sibling, 2 replies; 55+ messages in thread
From: Rudi C @ 2021-12-05 13:26 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: Eli Zaretskii, emacs-devel, Lars Ingebrigtsen, Stefan Kangas

[-- Attachment #1: Type: text/plain, Size: 974 bytes --]

Thanks!

PS: Are doc/emacs/dired.texi and the docstrings completely separate? I.e.,
any documentation change needs to be duplicated?

On Sun, Dec 5, 2021 at 3:49 PM Tassilo Horn <tsdh@gnu.org> wrote:

> Rudi C <rudiwillalwaysloveyou@gmail.com> writes:
>
> Hi all,
>
> > Okay, I have attached a new patch (no need for the previous patches).
>
> since it seems that no progress has been made on this issue and the only
> remaining stuff is just adapting the patch to our conventions, I
> reworked Rudi's last version of the patch (while keeping him as the
> author, of course).
>
> Would the following be acceptable for master?  If so, I'd volunteer to
> extend the dired docs wrt. the new feature.  (I have to confess I've
> made the new option's name longer again but IMHO a slightly longer but
> more descriptive name is no real burden.  Especially since it pairs with
> dired-create-destination-dirs, it's good when it's named very
> similarly.)
>
> Thanks,
> Tassilo
>
>

[-- Attachment #2: Type: text/html, Size: 1445 bytes --]

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-12-05 13:26                                                     ` Rudi C
@ 2021-12-05 17:00                                                       ` Tassilo Horn
  2021-12-06  4:34                                                       ` Richard Stallman
  1 sibling, 0 replies; 55+ messages in thread
From: Tassilo Horn @ 2021-12-05 17:00 UTC (permalink / raw)
  To: Rudi C; +Cc: Eli Zaretskii, emacs-devel, Lars Ingebrigtsen, Stefan Kangas

Rudi C <rudiwillalwaysloveyou@gmail.com> writes:

Hi Rudi,

> Thanks!

You're welcome.

> PS: Are doc/emacs/dired.texi and the docstrings completely separate?

Yes.

> I.e., any documentation change needs to be duplicated?

Well, kind of.  The manual and the docstrings are written in different
styles, e.g., the docstrings are written as an imperative, the manual in
indicative, docstrings are terse, the manual more explanatory, e.g.,
with examples.

See (info "(elisp) Documentation Tips") for how to write docstrings
fitting our conventions.

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-12-05 12:12                                                   ` Tassilo Horn
  2021-12-05 13:26                                                     ` Rudi C
@ 2021-12-05 20:24                                                     ` Lars Ingebrigtsen
  2021-12-06  6:01                                                       ` Tassilo Horn
  1 sibling, 1 reply; 55+ messages in thread
From: Lars Ingebrigtsen @ 2021-12-05 20:24 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: Rudi C, emacs-devel, Eli Zaretskii, stefankangas

Tassilo Horn <tsdh@gnu.org> writes:

> Would the following be acceptable for master?  If so, I'd volunteer to
> extend the dired docs wrt. the new feature.  (I have to confess I've
> made the new option's name longer again but IMHO a slightly longer but
> more descriptive name is no real burden.  Especially since it pairs with
> dired-create-destination-dirs, it's good when it's named very
> similarly.)

Looks good to me.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-12-05 13:26                                                     ` Rudi C
  2021-12-05 17:00                                                       ` Tassilo Horn
@ 2021-12-06  4:34                                                       ` Richard Stallman
  1 sibling, 0 replies; 55+ messages in thread
From: Richard Stallman @ 2021-12-06  4:34 UTC (permalink / raw)
  To: Rudi C; +Cc: eliz, emacs-devel, stefankangas, larsi, tsdh

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > PS: Are doc/emacs/dired.texi and the docstrings completely separate? I.e.,
  > any documentation change needs to be duplicated?

The documentation is not "duplicated" -- the text in the manual, and
the doc strings, are very different.  They HAVE to be very different
since they do different jobs.

Each one needs to be updated.

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: PR: dired-do-create-files now checks for trailing slashes in the target
  2021-12-05 20:24                                                     ` Lars Ingebrigtsen
@ 2021-12-06  6:01                                                       ` Tassilo Horn
  0 siblings, 0 replies; 55+ messages in thread
From: Tassilo Horn @ 2021-12-06  6:01 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Rudi C, emacs-devel, Eli Zaretskii, stefankangas

Lars Ingebrigtsen <larsi@gnus.org> writes:

Hi Lars,

>> Would the following be acceptable for master?  If so, I'd volunteer to
>> extend the dired docs wrt. the new feature.  (I have to confess I've
>> made the new option's name longer again but IMHO a slightly longer but
>> more descriptive name is no real burden.  Especially since it pairs with
>> dired-create-destination-dirs, it's good when it's named very
>> similarly.)
>
> Looks good to me.

Thanks for checking!  Pushed now.

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 55+ messages in thread

end of thread, other threads:[~2021-12-06  6:01 UTC | newest]

Thread overview: 55+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-28 17:50 PR: dired-do-create-files now checks for trailing slashes in the target Rudi C
2021-09-28 18:17 ` Stefan Kangas
2021-09-28 18:42   ` Rudi C
2021-09-28 19:03     ` Stefan Kangas
2021-09-28 19:38       ` Tassilo Horn
2021-09-28 20:07         ` Stefan Kangas
2021-09-28 20:23       ` Rudi C
2021-09-28 18:42   ` Eli Zaretskii
2021-09-28 19:29     ` Tassilo Horn
2021-09-28 19:55       ` Eli Zaretskii
2021-09-29  4:46         ` Tassilo Horn
2021-09-29 13:09           ` Eli Zaretskii
2021-09-29 13:20             ` Rudi C
2021-09-29 13:34               ` Eli Zaretskii
2021-09-29 13:37               ` Tassilo Horn
2021-09-29 13:42               ` Stefan Kangas
2021-09-29 13:53                 ` Tassilo Horn
2021-09-29 14:31                   ` Rudi C
2021-09-29 13:23             ` Tassilo Horn
2021-09-29 13:41               ` Eli Zaretskii
2021-09-29 13:42                 ` Tassilo Horn
2021-09-29 13:57                   ` Eli Zaretskii
2021-09-29 14:21                     ` Lars Ingebrigtsen
2021-09-29 15:04                       ` Stefan Kangas
2021-09-29 15:17                         ` Tassilo Horn
2021-09-30  6:06                           ` Lars Ingebrigtsen
2021-09-30  7:29                             ` Lars Ingebrigtsen
2021-09-30  8:32                             ` Tassilo Horn
2021-09-30 13:33                               ` Lars Ingebrigtsen
2021-09-30 14:10                                 ` Tassilo Horn
2021-09-30 16:03                                   ` Eli Zaretskii
2021-09-30 16:48                                     ` Tassilo Horn
2021-09-30 17:47                                       ` Eli Zaretskii
2021-09-30 18:52                                         ` Rudi C
2021-09-30 19:02                                           ` Eli Zaretskii
2021-11-01 15:37                                         ` Rudi C
2021-11-02 14:44                                           ` Lars Ingebrigtsen
2021-11-02 15:08                                             ` Rudi C
2021-11-02 15:15                                               ` Eli Zaretskii
2021-11-09 12:52                                                 ` Rudi C
2021-11-09 13:47                                                   ` Eli Zaretskii
2021-12-05 12:12                                                   ` Tassilo Horn
2021-12-05 13:26                                                     ` Rudi C
2021-12-05 17:00                                                       ` Tassilo Horn
2021-12-06  4:34                                                       ` Richard Stallman
2021-12-05 20:24                                                     ` Lars Ingebrigtsen
2021-12-06  6:01                                                       ` Tassilo Horn
2021-09-30 15:45                               ` [External] : " Drew Adams
2021-09-30 13:54                             ` Stefan Kangas
2021-09-30 13:59                               ` Lars Ingebrigtsen
2021-09-29 15:44                       ` Eli Zaretskii
2021-09-29 17:01                   ` [External] : " Drew Adams
2021-09-29 19:09                     ` Tassilo Horn
2021-09-29 19:35                       ` Drew Adams
2021-09-29 13:57               ` Stefan Kangas

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).