From: David Capello <davidcapello@gmail.com>
To: help-gnu-emacs@gnu.org
Cc: monnier@iro.umontreal.ca
Subject: Re: Avoid asking to user for lock (ask-user-about-lock)
Date: Thu, 24 Sep 2015 17:42:13 -0300 [thread overview]
Message-ID: <CA+hc8b5=aQ8=enZ-Ky-xLxNykb9Zi7Fxu1iJt4nth66a2jxfug@mail.gmail.com> (raw)
In-Reply-To: <CA+hc8b4PgZWDYrK3+mpMVDBrPQP8Pa-5qeMT0cH-=rQhyj4f2w@mail.gmail.com>
> > The problem is here:
> > https://github.com/dacap/keyfreq/blob/master/keyfreq.el#L427
>
> I think rather than override ask-user-about-lock you want to use the
> MUSTBENEW argument:
>
> (write-region (number-to-string (emacs-pid)) nil
> keyfreq-file-lock nil 'nomessage nil nil 'excl)
I think there is one extra nil, so I've used
(write-region (number-to-string (emacs-pid)) nil
keyfreq-file-lock nil 'nomessage nil 'excl)
And it seems to work, but I still getting some messages like:
.../.emacs.keyfreq.lock locked by david@pc (pid 9076): (s, q, p, ?)?
in the minibuf.
PS: Please CC me because I'm not subscribed to the list.
- David
On Thu, Sep 24, 2015 at 9:39 AM, David Capello <davidcapello@gmail.com>
wrote:
> Hi there,
>
> I've a package (keyfreq) that tries to add data to a file each X seconds.
> To do this it has to create a lock file, write the file, and release/delete
> the lock. If two instances of Emacs are running, both instances will try
> to write in the file at certain point. And here is where I'm having
> troubles
> (this was not a problem in Emacs 24.3, but now it is on 24.5).
>
> The problem is here:
> https://github.com/dacap/keyfreq/blob/master/keyfreq.el#L427
>
> I'm trying to redefine ask-user-about-lock temporarily so it doesn't
> ask to overwrite the .lock file if it already exists (if the lock already
> exist, we just "do nothing"/"wait next timeout", because the file is
> locked).
> Anyway it looks that sometimes, this redefinition doesn't work correctly.
>
> I would like to know if there is a way/common pattern to handle
> this kind of situations where two or more instances of Emacs are trying
> to add data to a file, and if they cannot get the lock, they just do
> nothing and can try it later.
>
> - David
>
next prev parent reply other threads:[~2015-09-24 20:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-24 12:39 Avoid asking to user for lock (ask-user-about-lock) David Capello
2015-09-24 15:52 ` Stefan Monnier
2015-09-24 20:42 ` David Capello [this message]
2015-09-24 21:10 ` Stefan Monnier
2015-09-24 21:33 ` David Capello
2015-09-25 1:22 ` Stefan Monnier
2015-09-25 2:08 ` David Capello
2015-09-25 11:05 ` Fwd: " David Capello
2015-10-20 14:20 ` Stefan Monnier
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='CA+hc8b5=aQ8=enZ-Ky-xLxNykb9Zi7Fxu1iJt4nth66a2jxfug@mail.gmail.com' \
--to=davidcapello@gmail.com \
--cc=help-gnu-emacs@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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.
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).