emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 9b601d8: Add new user option 'query-about-changed-file'


From: Lars Ingebrigtsen
Subject: master 9b601d8: Add new user option 'query-about-changed-file'
Date: Fri, 16 Jul 2021 08:30:36 -0400 (EDT)

branch: master
commit 9b601d8537422886250588fce22abc4e7ef6b100
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Add new user option 'query-about-changed-file'
    
    * doc/emacs/files.texi (Visiting): Document it.
    * lisp/files.el (query-about-changed-file): New user option (bug#10775).
    (find-file-noselect): Use it.
---
 doc/emacs/files.texi |  8 ++++++++
 etc/NEWS             |  7 +++++++
 lisp/files.el        | 20 ++++++++++++++++++++
 3 files changed, 35 insertions(+)

diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi
index 32a2f1b..b57618f 100644
--- a/doc/emacs/files.texi
+++ b/doc/emacs/files.texi
@@ -227,6 +227,14 @@ File Names}, for information on how to visit a file whose 
name
 actually contains wildcard characters.  You can disable the wildcard
 feature by customizing @code{find-file-wildcards}.
 
+@vindex query-about-changed-file
+  If you're asking to visit a file that's already in a buffer, but the
+file has changed externally, Emacs will ask you whether you want to
+re-load the file or not.  If you set @code{query-about-changed-file}
+to @code{nil}, Emacs won't query you, but instead just display the
+buffer and issue a message telling you how to revert the buffer from
+the file.
+
 @kindex C-x C-v
 @findex find-alternate-file
   If you visit the wrong file unintentionally by typing its name
diff --git a/etc/NEWS b/etc/NEWS
index bec7f9f..cfa6a4e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -309,6 +309,13 @@ about the different options to visit a file, how you can 
disable the
 prompt, and how you can tweak the file size threshold.
 
 +++
+** New user option 'query-about-changed-file'.
+If non-nil (the default), users are prompted as before when
+re-visiting a file that has changed externally.  If nil, the user is
+not prompted, but instead the buffer is opened, and the user is given
+an instruction on how to revert the uffer.
+
++++
 ** Improved support for terminal emulators that encode the Meta flag.
 Some terminal emulators set the 8th bit of Meta characters, and then
 encode the resulting character code as if it were non-ASCII character
diff --git a/lisp/files.el b/lisp/files.el
index 825aa1c..253a289 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -2153,6 +2153,18 @@ think it does, because \"free\" is pretty hard to define 
in practice."
   :version "25.1"
   :type '(choice integer (const :tag "Never issue warning" nil)))
 
+(defcustom query-about-changed-file t
+  "If non-nil, query the user when opening a file that has changed.
+This happens if the file is already visited in a buffer, and the
+file has changed, and the user re-visits the file.
+
+If nil, the user isn't prompted, but instead given a warning
+after switching to the buffer."
+  :group 'files
+  :group 'find-file
+  :version "28.1"
+  :type 'boolean)
+
 (declare-function x-popup-dialog "menu.c" (position contents &optional header))
 
 (defun files--ask-user-about-large-file-help-text (op-type size)
@@ -2335,6 +2347,14 @@ the various files."
                           (message "Reverting file %s..." filename)
                           (revert-buffer t t)
                           (message "Reverting file %s...done" filename)))
+                        ((not query-about-changed-file)
+                         (message
+                          (substitute-command-keys
+                           "File %s changed on disk.  \\[revert-buffer] to 
load new contents%s")
+                          (file-name-nondirectory filename)
+                          (if (buffer-modified-p buf)
+                              " and discard your edits"
+                            "")))
                        ((yes-or-no-p
                          (if (string= (file-name-nondirectory filename)
                                       (buffer-name buf))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]