bug#47119: 28.0.50; [patch][Dired] new user option for compressing dir suffix

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

bug#47119: 28.0.50; [patch][Dired] new user option for compressing dir suffix

Emacs - Bugs mailing list
Hi,

A new user option `dired-compress-files-default-suffix' for
controlling the default format for compressing directory.

0001-dired-new-user-option-dired-compress-files-default-suffix.patch (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#47119: 28.0.50; [patch][Dired] new user option for compressing dir suffix

Eli Zaretskii
> Date: Sat, 13 Mar 2021 11:55:48 +0800
> From:  Lin Sun via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <[hidden email]>
>
> A new user option `dired-compress-files-default-suffix' for
> controlling the default format for compressing directory.

Thanks, but wouldn't it be better to use symbols instead of strings?
That way, we could prevent typos easier, and also offer completion for
setting the option interactively.

Also, doesn't the user manual need to be changed as well?



Reply | Threaded
Open this post in threaded view
|

bug#47119: 28.0.50; [patch][Dired] new user option for compressing dir suffix

Emacs - Bugs mailing list
Hi Eli,

Thanks for your comments, I add the ":type 'string" for this new
option, and the manual change is reverted now. New patch is attached.

On Sat, Mar 13, 2021 at 3:37 PM Eli Zaretskii <[hidden email]> wrote:

>
> > Date: Sat, 13 Mar 2021 11:55:48 +0800
> > From:  Lin Sun via "Bug reports for GNU Emacs,
> >  the Swiss army knife of text editors" <[hidden email]>
> >
> > A new user option `dired-compress-files-default-suffix' for
> > controlling the default format for compressing directory.
>
> Thanks, but wouldn't it be better to use symbols instead of strings?
> That way, we could prevent typos easier, and also offer completion for
> setting the option interactively.
>
> Also, doesn't the user manual need to be changed as well?

0001-dired-new-user-option-dired-compress-files-default-suffix.patch (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#47119: Re: bug#47119: 28.0.50; [patch][Dired] new user option for compressing dir suffix

Emacs - Bugs mailing list
In reply to this post by Emacs - Bugs mailing list

Hi Eli,

 

Sorry for my misunderstanding for your preview comments.

 

> but wouldn't it be better to use symbols instead of strings?

The new option `dired-compress-files-default-suffix` can be “.tar.gz” or “.tar.xz”… and it should work with variable ` dired-compress-file-suffixes` while this variable maybe extended by user. So the type:string is simple for implementation.

 

And yes, the document need update, changes are available in the attachment.

 

Please help to review the new patch. Thanks.


0001-dired-new-user-option-dired-compress-files-default-s.patch (8K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#47119: Re: bug#47119: 28.0.50; [patch][Dired] new user option for compressing dir suffix

Emacs - Bugs mailing list
In reply to this post by Emacs - Bugs mailing list

Hi Eli,

 

Sorry for my misunderstanding for your preview comments.

 

> but wouldn't it be better to use symbols instead of strings?

The new option `dired-compress-files-default-suffix` can be “.tar.gz” or “.tar.xz”… and it should work with variable ` dired-compress-file-suffixes` while this variable maybe extended by user. So the type:string is simple for implementation.

 

And yes, the document need update, changes are available in the attachment.

 

Please help to review the new patch. Thanks.


0001-dired-new-user-option-dired-compress-files-default-s.patch (8K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#47119: 28.0.50; [patch][Dired] new user option for compressing dir suffix

Emacs - Bugs mailing list
In reply to this post by Emacs - Bugs mailing list

Hi Eli,

> > but wouldn't it be better to use symbols instead of strings?

>Getting a string (the name of a symbol) from a symbol is very easy, so

>I'm not sure I understand the reasoning.  But I won't insist.

I had try use the symbol like following code snippet, but there is no option-items in the buffer after executing `customize-variable` on this variable.

(defcustom dired-compress-files-default-suffix nil "..."

  :type '(choice (const :tag ".tar.gz" .tar.gz)

                      (const :tag ".tar.bz2" \.tag\.bz2))

  :group 'dired :version "28.1")

Is there any special syntax request for making it work as a custom selectable variable?

 

> "Refer to the ..."

I’ll correct it in new patch, thanks.

 

>> -    ("\000" ".tar.gz" "tar -cf - %i | gzip -c9 > %o"))

>Why did you remove the "\000" entry?  As the comment explains, it is

>there to allow compressing a directory.  To compress a directory, you

>need to run 'tar' on it first, and the .tar.gz/.tar.xz entries run

>'tar' on the _result_ of gzip/xz instead.  So how will compression of

>directories work after your changes?  I feel that I'm missing

>something here, but what?

The “\000” entry is special for compress directory, if you go through back, other entries in the `dired-compress-file-suffixes` is decompress commands. After apply this patch, the “\000” entry is useless.

 

>> +  "Default suffix for compressing directory.

>                                     ^^^^^^^^^

>"directories", in plural.

I’ll correct it in new patch, thanks.

 

>> +If nil, the \".tar.gz\" will be used.  See `dired-compress-files-alist' for \

>> +the supported suffixes list."                                           ^^^^

>   ^^^^^^^^^^^^^^^^^^^^^^^^^^^

>"for the list of supported suffixes"

I’ll correct it in new patch, thanks.

 

>> +                          (rule (cl-find-if

>> +                                 (lambda (x) (string-match-p (car x) suffix))

>> +                                 dired-compress-files-alist)))

>Do we really need cl-find-if here? what's wrong with assoc?

Yes, `assoc` is more elegant:

(assoc ".tar.gz" dired-compress-files-alist #'string-match-p)

 

Thanks

Reply | Threaded
Open this post in threaded view
|

bug#47119: 28.0.50; [patch][Dired] new user option for compressing dir suffix

Eli Zaretskii
> Date: Mon, 22 Mar 2021 20:28:48 +0800
> From: LinSun <[hidden email]>
> Cc: "[hidden email]" <[hidden email]>,
> "[hidden email]" <[hidden email]>
>
> >> -    ("\000" ".tar.gz" "tar -cf - %i | gzip -c9 > %o"))
>
> >Why did you remove the "\000" entry?  As the comment explains, it is
>
> >there to allow compressing a directory.  To compress a directory, you
>
> >need to run 'tar' on it first, and the .tar.gz/.tar.xz entries run
>
> >'tar' on the _result_ of gzip/xz instead.  So how will compression of
>
> >directories work after your changes?  I feel that I'm missing
>
> >something here, but what?
>
> The “\000” entry is special for compress directory, if you go through back, other entries in the
> `dired-compress-file-suffixes` is decompress commands. After apply this patch, the “\000” entry is useless.

I'm still missing something, I think.  Please describe step by step
how compressing a directory will work after your changes, and in
particular what shell command(s) will Dired run in that case.

Thanks.



Reply | Threaded
Open this post in threaded view
|

bug#47119: 28.0.50; [patch][Dired] new user option for compressing dir suffix

Emacs - Bugs mailing list
In reply to this post by Emacs - Bugs mailing list
There is another user option `compress-file-default-suffix` that allow user custom default suffix for compressing file in dired-mode.

These two patch allow user custom suffix for compressing folder and file in dired-mode by pressing "Z".

Both two patches are attached.
On Tuesday, March 23, 2021, 11:16:13 PM GMT+8, Lin Sun <[hidden email]> wrote:


Hi Eli,

 

Sorry for my misunderstanding for your preview comments.

 

> but wouldn't it be better to use symbols instead of strings?

The new option `dired-compress-files-default-suffix` can be “.tar.gz” or “.tar.xz”… and it should work with variable ` dired-compress-file-suffixes` while this variable maybe extended by user. So the type:string is simple for implementation.

 

And yes, the document need update, changes are available in the attachment.

 

Please help to review the new patch. Thanks.


0001-dired-new-user-option-dired-compress-files-default-s.patch (6K) Download Attachment
0002-dired-new-user-option-dired-compress-file-default-su.patch (7K) Download Attachment