~protesilaos/denote

3 3

Request for feedback/testing: Avoid duplicate identifiers

Protesilaos Stavrou <public@protesilaos.com>
Details
Message ID
<87v8emeus0.fsf@protesilaos.com>
DKIM signature
pass
Download raw message
Hello everyone,

I just made a set of changes to make Denote never produce duplicate
identifiers while renaming files.  The code is on the 'main' branch.
Please give it a try.  I am interested in how the interface should look
like and whether the code can be refined further.

The commit:

    commit bbdf36036b683247e2aa8e046709a52e30d791c2
    Author: Protesilaos Stavrou <info@protesilaos.com>
    Date:   Fri Jul 14 11:01:12 2023 +0300

        Make rename operations avoid duplicate identifiers

        Before, it was possible for Denote to create duplicate identifiers
        while renaming non-Denote files that had the same modification date.
        Files can have the same modification date when they are processed by a
        program, such as with Git or the 'touch' command.

        What Denote now does is check for the presence of the given identifier
        and produce a new one that is unique.  Depending on the command, the
        check is done against the 'denote-directory' or the set of marked
        Dired files.

        The command 'denote-dired-rename-marked-files' gains a new optional
        parameter, which is interactively passed by the double prefix
        argument ('C-u C-u' with default key bindings).  I am not sure this is
        the best interface, as we may prefer to always run the check for
        duplicate identifiers.  The reason I am doing it this way with the
        prefix argument is to avoid an unconditional potentially expensive
        operation while renaming a large set of files.

     README.org | 18 ++++++++++++++
     denote.el  | 80 +++++++++++++++++++++++++++++++++++++++++++++++++-------------
     2 files changed, 82 insertions(+), 16 deletions(-)

All the best,
Protesilaos (or simply "Prot")

-- 
Protesilaos Stavrou
https://protesilaos.com
Details
Message ID
<CABzEscajttkg1rzupfaXNkSWsMJFmw0cVOiny8+iBQh0xJxabw@mail.gmail.com>
In-Reply-To
<87v8emeus0.fsf@protesilaos.com> (view parent)
DKIM signature
pass
Download raw message
I accidentally ran into this yesterday and assumed that it was a check
always available inside Denote :D

My use-case was that I was moving a bunch of org-mode subtrees using
`denote ... org-extract-subtree` from the manual, and some of them had
the same timestamp. Denote did not create new notes and explained why
in the Message Buffer! I loved it. Without this check I would have run
into weird errors later and be left wondering about what happened.

Thanks,
Vedang

On Fri, Jul 14, 2023 at 2:26 PM Protesilaos Stavrou
<public@protesilaos.com> wrote:
>
> Hello everyone,
>
> I just made a set of changes to make Denote never produce duplicate
> identifiers while renaming files.  The code is on the 'main' branch.
> Please give it a try.  I am interested in how the interface should look
> like and whether the code can be refined further.
>
> The commit:
>
>     commit bbdf36036b683247e2aa8e046709a52e30d791c2
>     Author: Protesilaos Stavrou <info@protesilaos.com>
>     Date:   Fri Jul 14 11:01:12 2023 +0300
>
>         Make rename operations avoid duplicate identifiers
>
>         Before, it was possible for Denote to create duplicate identifiers
>         while renaming non-Denote files that had the same modification date.
>         Files can have the same modification date when they are processed by a
>         program, such as with Git or the 'touch' command.
>
>         What Denote now does is check for the presence of the given identifier
>         and produce a new one that is unique.  Depending on the command, the
>         check is done against the 'denote-directory' or the set of marked
>         Dired files.
>
>         The command 'denote-dired-rename-marked-files' gains a new optional
>         parameter, which is interactively passed by the double prefix
>         argument ('C-u C-u' with default key bindings).  I am not sure this is
>         the best interface, as we may prefer to always run the check for
>         duplicate identifiers.  The reason I am doing it this way with the
>         prefix argument is to avoid an unconditional potentially expensive
>         operation while renaming a large set of files.
>
>      README.org | 18 ++++++++++++++
>      denote.el  | 80 +++++++++++++++++++++++++++++++++++++++++++++++++-------------
>      2 files changed, 82 insertions(+), 16 deletions(-)
>
> All the best,
> Protesilaos (or simply "Prot")
>
> --
> Protesilaos Stavrou
> https://protesilaos.com



-- 
Cheers,
Vedang

https://vedang.me
@vedang on fosstodon.org
Jean-Charles Bagneris <lists@bagneris.net>
Details
Message ID
<746fd66c-f64b-40a7-a660-183cb69da6ac@app.fastmail.com>
In-Reply-To
<87v8emeus0.fsf@protesilaos.com> (view parent)
DKIM signature
pass
Download raw message
On Fri, Jul 14, 2023, at 08:56, Protesilaos Stavrou wrote:
> Hello everyone,

Hello again Prot and all,

> I just made a set of changes to make Denote never produce duplicate
> identifiers while renaming files.  The code is on the 'main' branch.
> Please give it a try.  I am interested in how the interface should look
> like and whether the code can be refined further.

Regarding the interface, I would favor checking for duplicates as a default,
as a safety feature, and allow to relax it with the double prefix argument 
when/if needed.

I understand that the check might be costly in terms of performance, but I
guess that this would be a minor inconvenience, as one does not rename thousands
of files on a daily basis I suppose.

Have a nice day!
-- 
JcB
Details
Message ID
<87lefdwie3.fsf@protesilaos.com>
In-Reply-To
<746fd66c-f64b-40a7-a660-183cb69da6ac@app.fastmail.com> (view parent)
DKIM signature
pass
Download raw message
> From: "Jean-Charles Bagneris" <lists@bagneris.net>
> Date: Sat, 15 Jul 2023 10:11:31 +0000
>
> On Fri, Jul 14, 2023, at 08:56, Protesilaos Stavrou wrote:
>> Hello everyone,
>
> Hello again Prot and all,

Hello Jean-Charles,

>> I just made a set of changes to make Denote never produce duplicate
>> identifiers while renaming files.  The code is on the 'main' branch.
>> Please give it a try.  I am interested in how the interface should look
>> like and whether the code can be refined further.
>
> Regarding the interface, I would favor checking for duplicates as a default,
> as a safety feature, and allow to relax it with the double prefix argument 
> when/if needed.
>
> I understand that the check might be costly in terms of performance, but I
> guess that this would be a minor inconvenience, as one does not rename thousands
> of files on a daily basis I suppose.
>
> Have a nice day!

Yes, this makes sense.  I also think this is a better default,
especially if we consider that the user is most likely not aware that
the underlying files will produce the same identifier.

I will give it a few more days before making this change.  Then will
make the preparations for version 2.0.0 of Denote.

All the best,
Prot

-- 
Protesilaos Stavrou
https://protesilaos.com
Reply to thread Export thread (mbox)