diff options
author | Richard M. Stallman <rms@gnu.org> | 1996-12-15 20:52:40 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1996-12-15 20:52:40 +0000 |
commit | ebeb898f46fd7df6d1814e0c5a3043ccb2d88c2c (patch) | |
tree | c9a8c7821bcfce7db6cf7a7818bb6569e363a270 /lisp | |
parent | 3347526ce7af0facc2a10c346b7f65880cd9f684 (diff) | |
download | emacs-ebeb898f46fd7df6d1814e0c5a3043ccb2d88c2c.tar.gz emacs-ebeb898f46fd7df6d1814e0c5a3043ccb2d88c2c.tar.bz2 emacs-ebeb898f46fd7df6d1814e0c5a3043ccb2d88c2c.zip |
(find-file-revert-without-query): New variable.
(find-file-noselect): Revert certain files without query
if the file has changed and the buffer has not.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/files.el | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/lisp/files.el b/lisp/files.el index bbfd13351f2..691ecaa37e2 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -115,6 +115,14 @@ under another name, you get the existing buffer instead of a new buffer.") The truename of a file is found by chasing all links both at the file level and at the levels of the containing directories.") +(defconst find-file-revert-without-query + '("/out$" "/traces/.*\.log$") + "*Specify which files should be reverted without query. +The value is a list of regular expressions. +If the file name matches one of these regular expressions, +then `find-file' reverts the file without querying +if the file has changed on disk and you have not edited the buffer.") + (defvar buffer-file-number nil "The device number and file number of the file visited in the current buffer. The value is a list of the form (FILENUM DEVNUM). @@ -772,6 +780,20 @@ The buffer is not selected, just returned to the caller." (verify-visited-file-modtime buf) (cond ((not (file-exists-p filename)) (error "File %s no longer exists!" filename)) + ;; Certain files should be reverted automatically + ;; if they have changed on disk and not in the buffer. + ((and (not (buffer-modified-p buf)) + (let ((tail find-file-revert-without-query) + (found nil)) + (while tail + (if (string-match (car tail) filename) + (setq found t)) + (setq tail (cdr tail))) + found)) + (with-current-buffer buf + (message "Reverting file %s..." filename) + (revert-buffer t t) + (message "Reverting file %s...done" filename))) ((yes-or-no-p (if (string= (file-name-nondirectory filename) (buffer-name buf)) @@ -786,8 +808,7 @@ The buffer is not selected, just returned to the caller." "File %s changed on disk. Reread from disk into %s? ") (file-name-nondirectory filename) (buffer-name buf)))) - (save-excursion - (set-buffer buf) + (with-current-buffer buf (revert-buffer t t))))) (save-excursion ;;; The truename stuff makes this obsolete. |