From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Justin Fields Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Add file-ring to dired-aux.el Date: Mon, 21 Oct 2024 05:14:52 -0500 Message-ID: References: <86plnthjms.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000027bb5a0624f9eda5" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14509"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Oct 21 12:31:24 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1t2ph5-0003ZX-IE for ged-emacs-devel@m.gmane-mx.org; Mon, 21 Oct 2024 12:31:23 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2pg9-0002ht-Ex; Mon, 21 Oct 2024 06:30:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t2pRN-0006Mk-QB for emacs-devel@gnu.org; Mon, 21 Oct 2024 06:15:10 -0400 Original-Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t2pRL-0007xO-9o; Mon, 21 Oct 2024 06:15:09 -0400 Original-Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4314a26002bso47467335e9.0; Mon, 21 Oct 2024 03:15:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729505705; x=1730110505; darn=gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=blPSPzRp/RenFtqIY05bMI3yXeFpUCk9nV/ma6VAjpw=; b=B3ym/n0MZB7iqFbCnlPbiknslB/1htiqUMH11KFsYB2OAxMIqGVdn5aeSioGgoh0mk WawhogMyQVRB/ThGpE0JYlvydM12gyHPWTUbUi4fh/C3GtmrRwEK32I1uWML96UGWhrd GFARo1UgmJrIxIC6rB81GrWugQUGfLuVQXc35FSubac5HMxg2w3k6UVppjtSU1psbubJ oQQ0y7DUAqS7K+h0H3H2prMyKSP9kplHgVbBsEyDVUMeI4vt04+mQAvnaTYbvKDuJTAo 4ISzdLdUJ75j2AlRl+bKDTePLx1A6SeN//LDWt6k5IoKCjLntmzNDRLDL7lNoWpwAU+K gjNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729505705; x=1730110505; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=blPSPzRp/RenFtqIY05bMI3yXeFpUCk9nV/ma6VAjpw=; b=W9zdDLFvinK2OSLXwApePkrpsbJXTSphfcVc+4xK/dIEe0vCEdimJZTqxCNWBBhnar UHEfcO8dKErWupQyv+ejAWAdkpz6KV/P8ohwoOjWcVQLv2x5wOTZ/wa+aa4nmoxFa4tJ Kyg4cte3r4GWGGwMbvl58BFYwcDiMZ4GgGvodHvI+WmRdWDMaWU+rOprMR/xAfRBnbtx WOElsnjIw0ZHxluOesj+x+wNbDSaB6Jt97989A9vanBwC/hkhlg3oTdtKRdrlD/jqoy7 1fF1EQe0NcoC3rtwQXv5iizO4ilx2hOP3V3gfUyglTT2dh5wq2XWvZhg9bjP0KQgc+c4 HBwQ== X-Gm-Message-State: AOJu0YzifvYall2V1+4Levb9aBB0TeCPbhZX965NgxPs8BjfCBI+eUOr DGCtplCYdJAEgPOtXqJJ1w0jeKw2eioGEVtZIgEcqRmVRod8qULnNm9eEV+irHDLcxaBSzllqI7 NXjahBo1AApF6DKp7Iyhcqf2pNtBjH2Ua4ww= X-Google-Smtp-Source: AGHT+IGxvcU8ljuSdbwNQxliJFPpWTmUAcMEKM/LjkZgTiaIoxT7IaZBOWiyznjuwJ4vr7C1g2QT+lVG/tr/r+XVHrY= X-Received: by 2002:adf:f209:0:b0:378:fe6e:50ef with SMTP id ffacd0b85a97d-37eab7272damr6532496f8f.5.1729505704522; Mon, 21 Oct 2024 03:15:04 -0700 (PDT) In-Reply-To: <86plnthjms.fsf@gnu.org> Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=justinlime1999@gmail.com; helo=mail-wm1-x336.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 21 Oct 2024 06:30:24 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:324705 Archived-At: --00000000000027bb5a0624f9eda5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi there, Thanks for taking a look. Apologies for the sloppiness you pointed out, this was originally targeted for the MELPA, but I was advised that this could be useful functionality in mainline, so this is my first time attempting to contribute directly to emacs :) > Why do you call this a "ring"? AFAICT, it is a simple list, created > and used as such. To be perfectly honest, it was just the first thing that came to mind to help distinguish this feature. If anybody has any better suggestions I can append accordingly. > Why does this use 'concat' instead of 'expand-file-name'? The (file-name-nondirectory (directory-file-name file)) in the snippet returns a bare filename. I use concat here to set the destination as an identical filename, in the default-directory. > What happens with files in subdirectories, e.g., if the user typed 'i' > before marking files? Does this command create the corresponding > subdirectories in the default-directory when it moves the files? Yes, the files have their actions performed recursively, so all subdirs are created as well. I have noticed just now though, in your example, default-directory remains unchanged, but it looks like if I swap to (dired-current-directory) instead, it should be resolved properly when in a subdir. Thanks for catching that. I'll also work on amending all the documentation mistakes you pointed out as well. > This feature, when installed, will need a NEWS entry. I might just not be looking hard enough, but do you have any resources available that I could look into for this? :) > Finally, to accept a contribution of this size we need you to sign the > copyright assignment agreement. Would you like to start this legal > paperwork rolling at this time? If yes, I will send you the form to > fill and the instructions to go with it. Of course! Very much appreciated. On Mon, Oct 21, 2024 at 4:48=E2=80=AFAM Eli Zaretskii wrote: > > From: Justin Fields > > Date: Mon, 21 Oct 2024 03:11:23 -0500 > > > > From ca8f28008aeb95e74a0b5de28445cc25602ab724 Mon Sep 17 00:00:00 2001 > > From: Justin Fields > > Date: Sun, 20 Oct 2024 22:54:57 -0500 > > Subject: [PATCH] Dired-Aux: add file ring to dired > > Thanks. Some comments below. If someone else has comments, please > post them. > > > +;;; File ring > > +(defvar dired-file-ring nil > > + "Captured dired files.") > > Why do you call this a "ring"? AFAICT, it is a simple list, created > and used as such. > > > +(defun dired-file-ring-execute (action action-name file-list) > > + "Execute a function to run for every item in the FILE-LIST. > > The first line of a doc string should preferably mention all of the > mandatory arguments. > > > +Argument ACTION argument to call with `dired-create-files' with as > > +its' FILE-CREATOR. > > This reads awkwardly due to lack of punctuation. Our usual style is > to say > > ACTION is passed to `dired-create-files' as its FILE-CREATOR > argument. > > Same comment for the other arguments. > > > +Argument ACTION-NAME The name of the action, used for logging. > > This should say "...for error logging by `dired-create-files'.", so > that readers could look up that logging. > > > + (dired-create-files action action-name file-list > > + (lambda (file) (concat default-directory (file-name-nondirectory > (directory-file-name file))))) > > Why does this use 'concat' instead of 'expand-file-name'? > > > +(defun dired-file-ring-capture () > > + "Capture marked Dired files to the file ring." > > + (interactive) > > + (mapc (lambda (file) (add-to-list 'dired-file-ring file)) > (dired-get-marked-files)) > > + (message "Captured %s Files. %s files are present in the file ring" > (length (dired-get-marked-files)) (length dired-file-ring))) > > This will say "Captured 1 Files", which is incorrect English. Please > use ngettext to do this better. > > My suggestion is to rephrase this message to say something like > > %s files now in `file-ring', %s added > > This makes the message much shorter and easier to understand, IMO. > > > +(defun dired-file-ring-move () > > + "Move the file/s from the file ring to current dir. > > By "current dir" do you mean default-directory? We don't use the term > "current directory" in Emacs because Emacs pretends that each buffer > has its own "current directory". > > > +This action clears the file ring." > > + (interactive) > > + (dired-file-ring-execute #'rename-file "MOVE" dired-file-ring) > > + (dired-file-ring-clear)) > > What happens with files in subdirectories, e.g., if the user typed 'i' > before marking files? Does this command create the corresponding > subdirectories in the default-directory when it moves the files? > > > +(defun dired-file-ring-copy () > > + "Copy the file/s from the file ring to current dir." > > + (interactive) > > + (dired-file-ring-execute #'dired-copy-file "COPY" dired-file-ring)) > > Same question here. > > > +(defun dired-file-ring-symlink () > > + "Create a symlink for the the file/s from the file ring to current > dir." > > + (interactive) > > + (dired-file-ring-execute #'make-symbolic-link "SYM-LINK" > dired-file-ring)) > > + > > +(defun dired-file-ring-symlink-relative () > > + "Create a relative symlink for the the file/s from the file ring to > current dir." > > + (interactive) > > + (dired-file-ring-execute #'dired-make-relative-symlink "RELATIVE > SYM-LINK" dired-file-ring)) > > The doc strings of these two commands should be more explicit > regarding which file is the symlink and what will be its target. > > This feature, when installed, will need a NEWS entry. > > Finally, to accept a contribution of this size we need you to sign the > copyright assignment agreement. Would you like to start this legal > paperwork rolling at this time? If yes, I will send you the form to > fill and the instructions to go with it. > --00000000000027bb5a0624f9eda5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi there, Thanks for taking a look.

Apologies for the sloppiness you pointed out, this was originally t= argeted for the MELPA, but I was advised that this could be useful function= ality in mainline, so this is my first time attempting to contribute direct= ly to emacs :)

> Why do you call this a "r= ing"?=C2=A0 AFAICT, it is a simple list, created
> and used as such.

To be perfectly honest, it = was just the first thing that came to mind to help distinguish this feature= . If anybody has any better suggestions I can append accordingly.

> Why does this use 'concat' instead of 'exp= and-file-name'?
The (file-name-nondirectory (directory-file-n= ame file)) in the snippet returns a bare filename. I use concat here to set= the destination as an identical filename, in the default-directory.
<= div>
> What happens with files in subdirectories, e.g., if the user typed = 9;i'
> before marking files?=C2=A0 Does this command create the corresponding=
> subdirectories in the default-directory when it moves the files?
=
Yes, the files have their actions performed recursively, so all subdir= s are created as well.

I have noticed just now tho= ugh, in your example, default-directory remains unchanged, but it looks lik= e if I swap to (dired-current-directory) instead, it should be resolved pro= perly when in a subdir. Thanks for catching that.

= I'll also work on amending all the documentation mistakes you pointed o= ut as well.

> This feature, when installed, wil= l need a NEWS entry.
I might just not be looking hard enough, but= do you have any resources available that I could look into for this? :)

> Finally, to accept a contribution of this size = we need you to sign the
> copyright assignment agreement.=C2=A0 Would you like to start this leg= al
> paperwork rolling at this time?=C2=A0 If yes, I will send you the form= to
> fill and the instructions to go with it.

Of c= ourse! Very much appreciated.

On Mon, Oct 21, 2024 at 4:48=E2=80= =AFAM Eli Zaretskii <eliz@gnu.org>= ; wrote:
> Fr= om: Justin Fields <justinlime1999@gmail.com>
> Date: Mon, 21 Oct 2024 03:11:23 -0500
>
> From ca8f28008aeb95e74a0b5de28445cc25602ab724 Mon Sep 17 00:00:00 2001=
> From: Justin Fields <justinlime1999@gmail.com>
> Date: Sun, 20 Oct 2024 22:54:57 -0500
> Subject: [PATCH] Dired-Aux: add file ring to dired

Thanks.=C2=A0 Some comments below.=C2=A0 If someone else has comments, plea= se
post them.

> +;;; File ring
> +(defvar dired-file-ring nil
> +=C2=A0 "Captured dired files.")

Why do you call this a "ring"?=C2=A0 AFAICT, it is a simple list,= created
and used as such.

> +(defun dired-file-ring-execute (action action-name file-list)
> +=C2=A0 "Execute a function to run for every item in the FILE-LIS= T.

The first line of a doc string should preferably mention all of the
mandatory arguments.

> +Argument ACTION argument to call with `dired-create-files' with a= s
> +its' FILE-CREATOR.

This reads awkwardly due to lack of punctuation.=C2=A0 Our usual style is to say

=C2=A0 ACTION is passed to `dired-create-files' as its FILE-CREATOR
=C2=A0 argument.

Same comment for the other arguments.

> +Argument ACTION-NAME The name of the action, used for logging.

This should say "...for error logging by `dired-create-files'.&quo= t;, so
that readers could look up that logging.

> +=C2=A0 (dired-create-files action action-name file-list
> +=C2=A0 =C2=A0 (lambda (file) (concat default-directory (file-name-non= directory (directory-file-name file)))))

Why does this use 'concat' instead of 'expand-file-name'?
> +(defun dired-file-ring-capture ()
> +=C2=A0 "Capture marked Dired files to the file ring."
> +=C2=A0 (interactive)
> +=C2=A0 (mapc (lambda (file) (add-to-list 'dired-file-ring file)) = (dired-get-marked-files))
> +=C2=A0 (message "Captured %s Files. %s files are present in the = file ring" (length (dired-get-marked-files)) (length dired-file-ring))= )

This will say "Captured 1 Files", which is incorrect English.=C2= =A0 Please
use ngettext to do this better.

My suggestion is to rephrase this message to say something like

=C2=A0 %s files now in `file-ring', %s added

This makes the message much shorter and easier to understand, IMO.

> +(defun dired-file-ring-move ()
> +=C2=A0 "Move the file/s from the file ring to current dir.

By "current dir" do you mean default-directory?=C2=A0 We don'= t use the term
"current directory" in Emacs because Emacs pretends that each buf= fer
has its own "current directory".

> +This action clears the file ring."
> +=C2=A0 (interactive)
> +=C2=A0 (dired-file-ring-execute #'rename-file "MOVE" di= red-file-ring)
> +=C2=A0 (dired-file-ring-clear))

What happens with files in subdirectories, e.g., if the user typed 'i&#= 39;
before marking files?=C2=A0 Does this command create the corresponding
subdirectories in the default-directory when it moves the files?

> +(defun dired-file-ring-copy ()
> +=C2=A0 "Copy the file/s from the file ring to current dir."=
> +=C2=A0 (interactive)
> +=C2=A0 (dired-file-ring-execute #'dired-copy-file "COPY"= ; dired-file-ring))

Same question here.

> +(defun dired-file-ring-symlink ()
> +=C2=A0 "Create a symlink for the the file/s from the file ring t= o current dir."
> +=C2=A0 (interactive)
> +=C2=A0 (dired-file-ring-execute #'make-symbolic-link "SYM-LI= NK" dired-file-ring))
> +
> +(defun dired-file-ring-symlink-relative ()
> +=C2=A0 "Create a relative symlink for the the file/s from the fi= le ring to current dir."
> +=C2=A0 (interactive)
> +=C2=A0 (dired-file-ring-execute #'dired-make-relative-symlink &qu= ot;RELATIVE SYM-LINK" dired-file-ring))

The doc strings of these two commands should be more explicit
regarding which file is the symlink and what will be its target.

This feature, when installed, will need a NEWS entry.

Finally, to accept a contribution of this size we need you to sign the
copyright assignment agreement.=C2=A0 Would you like to start this legal paperwork rolling at this time?=C2=A0 If yes, I will send you the form to fill and the instructions to go with it.
--00000000000027bb5a0624f9eda5--