diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2021-07-16 14:30:24 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2021-07-16 14:30:24 +0200 |
commit | 9b601d8537422886250588fce22abc4e7ef6b100 (patch) | |
tree | 816ac7cdb47d5b08ca8dfec67a8c23c7495d5a5a /lisp/files.el | |
parent | 561ef16fd096002860c4f38d93145ee5a9adb82e (diff) | |
download | emacs-9b601d8537422886250588fce22abc4e7ef6b100.tar.gz emacs-9b601d8537422886250588fce22abc4e7ef6b100.tar.bz2 emacs-9b601d8537422886250588fce22abc4e7ef6b100.zip |
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.
Diffstat (limited to 'lisp/files.el')
-rw-r--r-- | lisp/files.el | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lisp/files.el b/lisp/files.el index 825aa1c3e88..253a2891807 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)) |