Skip to content

Commit 8f69483

Browse files
committed
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.
1 parent 3b7cb5f commit 8f69483

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/filelock.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,9 @@ lock_file (Lisp_Object fn)
680680
dostounix_filename (SSDATA (fn));
681681
#endif
682682
encoded_fn = ENCODE_FILE (fn);
683+
if (create_lockfiles)
684+
/* Create the name of the lock-file for file fn */
685+
MAKE_LOCK_NAME (lfname, encoded_fn);
683686

684687
/* See if this file is visited and has changed on disk since it was
685688
visited. */
@@ -690,18 +693,15 @@ lock_file (Lisp_Object fn)
690693

691694
if (!NILP (subject_buf)
692695
&& NILP (Fverify_visited_file_modtime (subject_buf))
693-
&& !NILP (Ffile_exists_p (fn)))
696+
&& !NILP (Ffile_exists_p (fn))
697+
&& (!create_lockfiles || current_lock_owner (NULL, lfname) != -2))
694698
call1 (intern ("userlock--ask-user-about-supersession-threat"), fn);
695699

696700
}
697701

698702
/* Don't do locking if the user has opted out. */
699703
if (create_lockfiles)
700704
{
701-
702-
/* Create the name of the lock-file for file fn */
703-
MAKE_LOCK_NAME (lfname, encoded_fn);
704-
705705
/* Try to lock the lock. FIXME: This ignores errors when
706706
lock_if_free returns a positive errno value. */
707707
if (lock_if_free (&lock_info, lfname) < 0)

0 commit comments

Comments
 (0)