From: Noam Postavsky <npostavs@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: dak@gnu.org, stefan@marxist.se, 18336@debbugs.gnu.org
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 [thread overview]
Message-ID: <87o8sojhpi.fsf@gmail.com> (raw)
In-Reply-To: <83d094co4s.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 22 Mar 2020 19:09:39 +0200")
[-- Attachment #1: Type: text/plain, Size: 639 bytes --]
Eli Zaretskii <eliz@gnu.org> 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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1666 bytes --]
From 036eb17510ab63ce62aa858c9ff825b2ec5b5c7a Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
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
next prev parent reply other threads:[~2020-03-22 19:46 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-27 7:44 bug#18336: 24.4.50; When editing externally changed file, Emacs asks too many questions David Kastrup
2020-03-01 0:27 ` Stefan Kangas
2020-03-01 16:26 ` Noam Postavsky
2020-03-01 16:38 ` David Kastrup
2020-03-01 17:09 ` Eli Zaretskii
2020-03-01 17:45 ` David Kastrup
2020-03-01 17:58 ` Eli Zaretskii
2020-03-01 18:22 ` David Kastrup
2020-03-01 18:27 ` Eli Zaretskii
2020-03-02 4:14 ` Noam Postavsky
2020-03-02 8:27 ` Eli Zaretskii
2020-03-02 9:42 ` David Kastrup
2020-03-02 11:04 ` Eli Zaretskii
2020-03-02 11:41 ` David Kastrup
2020-03-02 11:51 ` Eli Zaretskii
2020-03-02 8:39 ` Stefan Kangas
2020-03-02 8:55 ` Eli Zaretskii
2020-03-02 9:04 ` Stefan Kangas
2020-03-02 11:01 ` Eli Zaretskii
2020-03-02 9:53 ` David Kastrup
2020-03-02 12:20 ` Noam Postavsky
2020-03-02 16:33 ` Eli Zaretskii
2020-03-05 14:13 ` Noam Postavsky
2020-03-05 15:07 ` David Kastrup
2020-03-05 17:54 ` Noam Postavsky
2020-03-05 19:31 ` Eli Zaretskii
2020-03-22 1:13 ` Noam Postavsky
2020-03-22 14:35 ` Eli Zaretskii
2020-03-22 15:45 ` Noam Postavsky
2020-03-22 17:09 ` Eli Zaretskii
2020-03-22 19:46 ` Noam Postavsky [this message]
2020-03-22 20:16 ` Eli Zaretskii
2020-03-23 3:26 ` Noam Postavsky
2020-03-05 16:02 ` Eli Zaretskii
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87o8sojhpi.fsf@gmail.com \
--to=npostavs@gmail.com \
--cc=18336@debbugs.gnu.org \
--cc=dak@gnu.org \
--cc=eliz@gnu.org \
--cc=stefan@marxist.se \
/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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.