From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#18336: 24.4.50; When editing externally changed file, Emacs asks too many questions Date: Sun, 22 Mar 2020 15:46:33 -0400 Message-ID: <87o8sojhpi.fsf@gmail.com> References: <87mwaq74xg.fsf@fencepost.gnu.org> <86v9nooxcg.fsf@gmail.com> <87tv38kp33.fsf@fencepost.gnu.org> <83sgisypbd.fsf@gnu.org> <87pndwklz6.fsf@fencepost.gnu.org> <83o8tgyn1k.fsf@gnu.org> <874kv83pg7.fsf@fencepost.gnu.org> <83lfokylpp.fsf@gnu.org> <87r1yb8kbv.fsf@gmail.com> <87wo8340ct.fsf@stefankangas.se> <874kv7ozf9.fsf@fencepost.gnu.org> <87o8tf7xu3.fsf@gmail.com> <83mu8yyawu.fsf@gnu.org> <874kv299f7.fsf@gmail.com> <87pndqet7k.fsf@fencepost.gnu.org> <8536amk7q6.fsf@gmail.com> <838skevbsn.fsf@gnu.org> <87y2rtjinc.fsf@gmail.com> <83k13ccvah.fsf@gnu.org> <87r1xkjsvf.fsf@gmail.com> <83d094co4s.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="59129"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.90 (gnu/linux) Cc: dak@gnu.org, stefan@marxist.se, 18336@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Mar 22 20:47:13 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jG6Yy-000FFZ-Oc for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 22 Mar 2020 20:47:12 +0100 Original-Received: from localhost ([::1]:49296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jG6Yx-0002DV-Jg for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 22 Mar 2020 15:47:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35376) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jG6Yp-0002DN-QD for bug-gnu-emacs@gnu.org; Sun, 22 Mar 2020 15:47:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jG6Yo-00011F-MV for bug-gnu-emacs@gnu.org; Sun, 22 Mar 2020 15:47:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44959) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jG6Yo-00011A-It for bug-gnu-emacs@gnu.org; Sun, 22 Mar 2020 15:47:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jG6Yo-0003W5-FX for bug-gnu-emacs@gnu.org; Sun, 22 Mar 2020 15:47:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 22 Mar 2020 19:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18336 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 18336-submit@debbugs.gnu.org id=B18336.158490640213489 (code B ref 18336); Sun, 22 Mar 2020 19:47:02 +0000 Original-Received: (at 18336) by debbugs.gnu.org; 22 Mar 2020 19:46:42 +0000 Original-Received: from localhost ([127.0.0.1]:50932 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jG6YU-0003VV-0G for submit@debbugs.gnu.org; Sun, 22 Mar 2020 15:46:42 -0400 Original-Received: from mail-qt1-f178.google.com ([209.85.160.178]:37985) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jG6YS-0003VI-Fb for 18336@debbugs.gnu.org; Sun, 22 Mar 2020 15:46:40 -0400 Original-Received: by mail-qt1-f178.google.com with SMTP id z12so9923762qtq.5 for <18336@debbugs.gnu.org>; Sun, 22 Mar 2020 12:46:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=HKk4SHITqy61AzGEmdDQaWcgvHttd0cQKFWvlzvLenE=; b=O0UG3xEaJVtNsfVOHcudLTNcvXRLVLY6SitmRkxHJ4VrPgXGpuOt5/O95aUJwMFDvZ V7DIxcuxoZDz7Q4/dMZc0/op7rAmaLP5BHnrZX0W3aoOqxExKm4pDv5soeT9DRn/2kvP sS52EtjfFocb8yk0L+UF8x5P0k01Q4sLq7iBFqwMRydpDck3zdiaL93rNK6XQjN8aJV/ Hfdqj9KmxZFFIP8A6resugnPhXEVDhLdVfabMOV5qxlim1R6Z26r95P1RjzUl0gYHqcN n4dqua3TfMJgWPcW913v2YRGQ9w7chyh+mhxwCSnV0by3ZT6NE9P4qkeEkzsbrmm6FSe v1jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=HKk4SHITqy61AzGEmdDQaWcgvHttd0cQKFWvlzvLenE=; b=NRpo1Yeb/z92/VnD0lT59CyQZmfKb81kUxDSRnf8Zu0XYUdSXt/HDWNPvN+rfltVng hYA90hKCac1qtISjZfLQEsjJ9Ym1JixLsZhz+LqK8jVGxhYo2CdAMhkqlwhRZ5WWlJvV /YFY0UwShhJZuEXZWRn9EuyaSTQsLRBufE2gD7jUew0l6k/S0zOv09xSW0GELBWzFnSJ uD2oSwISlb895sg0muuVwzzLoTWWMWSGkGi3uHI34HTKffYA0+3AxivWutQNiTFfxKKx AbJhfAXGFkBBVlzG67Uro0p00JKHPJKYgOxt0YCUHuA9BYIOa1lTPH9/KdNnOg90sprL U4rw== X-Gm-Message-State: ANhLgQ06eAesU8u9r4u38HunL10MXkFDPymuev0sTNOT4iRrf8BPsc0b xxbFs0+GElW43kkJP5NdXhUWJ+vq X-Google-Smtp-Source: ADFU+vudtQgP0asqkZ2KXVuxblBirXe4ebrT5uzbxzxcLXkYjgIRFUlMMZm248DGN74wmyCGgBes6g== X-Received: by 2002:ac8:a8b:: with SMTP id d11mr17569476qti.94.1584906394734; Sun, 22 Mar 2020 12:46:34 -0700 (PDT) Original-Received: from minid (cbl-45-2-119-47.yyz.frontiernetworks.ca. [45.2.119.47]) by smtp.gmail.com with ESMTPSA id z23sm9653221qkg.21.2020.03.22.12.46.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Mar 2020 12:46:33 -0700 (PDT) In-Reply-To: <83d094co4s.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 22 Mar 2020 19:09:39 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:177630 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> > Isn't it better to check whether the file is already locked? That >> > way, we don't need any (error-prone) heuristics for when it's okay to >> > ask the question and when it isn't. >> >> If I understand the code correctly, lock_file() already checks this (the >> '&& !NILP (Ffile_exists_p (fn))' part), but takes the wrong action in >> that case. So I'm not sure what we should do differently. > > AFAIU, 'fn' in lock_file is the file we want to lock, not the file we > create to indicate the lock. Am I missing something? Oh, you're right, I was confused. The patch below seems to work. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Avoid-extra-changed-on-disk-prompt-in-save-buffer-Bu.patch Content-Description: patch >From 036eb17510ab63ce62aa858c9ff825b2ec5b5c7a Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 21 Mar 2020 21:00:08 -0400 Subject: [PATCH] Avoid extra "changed on disk" prompt in save-buffer (Bug#18336) * src/filelock.c (lock_file): Don't query the user if the current session already owns the lock. --- src/filelock.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/filelock.c b/src/filelock.c index b28f16e9b5..5e14731ee8 100644 --- a/src/filelock.c +++ b/src/filelock.c @@ -679,6 +679,9 @@ lock_file (Lisp_Object fn) dostounix_filename (SSDATA (fn)); #endif encoded_fn = ENCODE_FILE (fn); + if (create_lockfiles) + /* Create the name of the lock-file for file fn */ + MAKE_LOCK_NAME (lfname, encoded_fn); /* See if this file is visited and has changed on disk since it was visited. */ @@ -689,7 +692,8 @@ lock_file (Lisp_Object fn) if (!NILP (subject_buf) && NILP (Fverify_visited_file_modtime (subject_buf)) - && !NILP (Ffile_exists_p (fn))) + && !NILP (Ffile_exists_p (fn)) + && (!create_lockfiles || current_lock_owner (NULL, lfname) != -2)) call1 (intern ("userlock--ask-user-about-supersession-threat"), fn); } @@ -697,10 +701,6 @@ lock_file (Lisp_Object fn) /* Don't do locking if the user has opted out. */ if (create_lockfiles) { - - /* Create the name of the lock-file for file fn */ - MAKE_LOCK_NAME (lfname, encoded_fn); - /* Try to lock the lock. FIXME: This ignores errors when lock_if_free returns a positive errno value. */ if (lock_if_free (&lock_info, lfname) < 0) -- 2.11.0 --=-=-=--