From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Capello Newsgroups: gmane.emacs.help Subject: Re: Avoid asking to user for lock (ask-user-about-lock) Date: Thu, 24 Sep 2015 17:42:13 -0300 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1443127368 5135 80.91.229.3 (24 Sep 2015 20:42:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 24 Sep 2015 20:42:48 +0000 (UTC) Cc: monnier@iro.umontreal.ca To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Sep 24 22:42:48 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZfDLq-0007Xb-Qj for geh-help-gnu-emacs@m.gmane.org; Thu, 24 Sep 2015 22:42:46 +0200 Original-Received: from localhost ([::1]:60658 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfDLq-0007ls-7C for geh-help-gnu-emacs@m.gmane.org; Thu, 24 Sep 2015 16:42:46 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39738) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfDLe-0007lJ-PS for help-gnu-emacs@gnu.org; Thu, 24 Sep 2015 16:42:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfDLd-0007PD-Ly for help-gnu-emacs@gnu.org; Thu, 24 Sep 2015 16:42:34 -0400 Original-Received: from mail-io0-x22d.google.com ([2607:f8b0:4001:c06::22d]:34636) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfDLd-0007P4-GR for help-gnu-emacs@gnu.org; Thu, 24 Sep 2015 16:42:33 -0400 Original-Received: by iofb144 with SMTP id b144so90624720iof.1 for ; Thu, 24 Sep 2015 13:42:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=QwdCWDCcX+uRKhalg7NxO0Vzncy7NzCe3W/jW/qokM4=; b=UP88znVdRdU5HdlYWUou+/9YjL553HtsH4pl0UlsnRKunZBEcYtUMMNxUGoMGu2r/w 6SYiNFjVdGrYupjOoVLAyStPQv5I63nRzhyHaWIkYgzdAJaq091RQBGjJLeCDPsKZqj6 NLFacJ3pudO2VFAxw/z9LVasCRL1Un/uWaUAd/r48geCjCg7Zi1YYteVuUNQuac4QLrQ LOhslCBmkE21w43Dp6e1gzynVnP1+/yOJDFN7TH52iu/Kqf8YrKw3Qjb6SwajCa1eIiP GxNUa0OxYQxyoGkxn3GyAjvBQd3zCB8lU+SOH9c9o50WroIFungKclZa+objosoFGyTu LZvA== X-Received: by 10.107.131.134 with SMTP id n6mr2804592ioi.192.1443127353096; Thu, 24 Sep 2015 13:42:33 -0700 (PDT) Original-Received: by 10.107.58.137 with HTTP; Thu, 24 Sep 2015 13:42:13 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4001:c06::22d X-Content-Filtered-By: Mailman/MimeDel 2.1.14 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:107319 Archived-At: > > 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 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 >