unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Rudi C <rudiwillalwaysloveyou@gmail.com>
To: Stefan Kangas <stefankangas@gmail.com>,
	Eli Zaretskii <eliz@gnu.org>,
	tsdh@gnu.org
Cc: emacs-devel@gnu.org
Subject: Re: PR: dired-do-create-files now checks for trailing slashes in the target
Date: Tue, 28 Sep 2021 23:53:53 +0330	[thread overview]
Message-ID: <CAE9z9A0i63VWhmLh59wAewka5hrFCeTTtWaZ5AEAVx_FszVnxA@mail.gmail.com> (raw)
In-Reply-To: <CADwFkm=ge8Pkuj10BsFD0W0pMx2TCK+RMgCdgZGkjGiRKdNLTw@mail.gmail.com>


[-- 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


  parent reply	other threads:[~2021-09-28 20:23 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAE9z9A0i63VWhmLh59wAewka5hrFCeTTtWaZ5AEAVx_FszVnxA@mail.gmail.com \
    --to=rudiwillalwaysloveyou@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=stefankangas@gmail.com \
    --cc=tsdh@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).