Subject: Re: bug#66993: [PATCH] project.el: avoid asking user about project-list-file lock

From: Spencer Baugh <[email-masked]>
Date: Wed, 08 Nov 2023 10:25:07 -0500

Dmitry Gutov <[email-masked]> writes:
> On 07/11/2023 23:28, Spencer Baugh wrote:
>> - project-mode-line will call this on mode-line update
>> - My own private project-watch will call this based on file-notify
>>    events.
>> If a user has multiple Emacs instances open using one or more of
>> these
>> features, it's fairly easy for both of the Emacs instances to see a
>> new project at the same time.  In that case, they'll both call
>> project--write-project-list at the same time, which will clash and run
>> ask-user-about-lock.  This will happen frequently if the user is often
>> looking at new projects.
>
> Hmmm. What happens if we just show two buffers from different projects
> in the same Emacs instance? Do the mode-line refreshes trigger the
> changes in the list of remembered projects and subsequent writes to
> disk (e.g. alternating the "current" project between these two,
> potentially many times a second)?
>
> If so, we'll need a way to inhibit these updates, at least from the
> mode-line formatter.

Oh, I spoke too soon, perhaps - when MAYBE-PROMPT=nil in
project-current, we don't call project--write-project-list.

So the issue won't actually happen with project-mode-line or
project-uniquify-dirname-transform.  It will only happen with either:

- Concurrent calls to regular project commands
  (e.g. project-async-shell-command or project-compile) from two
  Emacsen,
  since those set MAYBE-PROMPT=t

- Concurrent calls to project-remember-project/project-forget-project
  and similar functions.  (This is what my project-watch does, since it
  calls project-remember-project when a new project shows up in a
  directory, and if I'm unlucky that will be at the same time as another
  Emacs instance.)

I guess that makes it less of a critical issue, but it still seems to me
that this is worth fixing.