diff options
| author | Richard M. Stallman | 1996-12-15 20:52:40 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1996-12-15 20:52:40 +0000 |
| commit | ebeb898f46fd7df6d1814e0c5a3043ccb2d88c2c (patch) | |
| tree | c9a8c7821bcfce7db6cf7a7818bb6569e363a270 | |
| parent | 3347526ce7af0facc2a10c346b7f65880cd9f684 (diff) | |
| download | emacs-ebeb898f46fd7df6d1814e0c5a3043ccb2d88c2c.tar.gz 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.
| -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.") | |||
| 115 | The truename of a file is found by chasing all links | 115 | The truename of a file is found by chasing all links |
| 116 | both at the file level and at the levels of the containing directories.") | 116 | both at the file level and at the levels of the containing directories.") |
| 117 | 117 | ||
| 118 | (defconst find-file-revert-without-query | ||
| 119 | '("/out$" "/traces/.*\.log$") | ||
| 120 | "*Specify which files should be reverted without query. | ||
| 121 | The value is a list of regular expressions. | ||
| 122 | If the file name matches one of these regular expressions, | ||
| 123 | then `find-file' reverts the file without querying | ||
| 124 | if the file has changed on disk and you have not edited the buffer.") | ||
| 125 | |||
| 118 | (defvar buffer-file-number nil | 126 | (defvar buffer-file-number nil |
| 119 | "The device number and file number of the file visited in the current buffer. | 127 | "The device number and file number of the file visited in the current buffer. |
| 120 | The value is a list of the form (FILENUM DEVNUM). | 128 | The value is a list of the form (FILENUM DEVNUM). |
| @@ -772,6 +780,20 @@ The buffer is not selected, just returned to the caller." | |||
| 772 | (verify-visited-file-modtime buf) | 780 | (verify-visited-file-modtime buf) |
| 773 | (cond ((not (file-exists-p filename)) | 781 | (cond ((not (file-exists-p filename)) |
| 774 | (error "File %s no longer exists!" filename)) | 782 | (error "File %s no longer exists!" filename)) |
| 783 | ;; Certain files should be reverted automatically | ||
| 784 | ;; if they have changed on disk and not in the buffer. | ||
| 785 | ((and (not (buffer-modified-p buf)) | ||
| 786 | (let ((tail find-file-revert-without-query) | ||
| 787 | (found nil)) | ||
| 788 | (while tail | ||
| 789 | (if (string-match (car tail) filename) | ||
| 790 | (setq found t)) | ||
| 791 | (setq tail (cdr tail))) | ||
| 792 | found)) | ||
| 793 | (with-current-buffer buf | ||
| 794 | (message "Reverting file %s..." filename) | ||
| 795 | (revert-buffer t t) | ||
| 796 | (message "Reverting file %s...done" filename))) | ||
| 775 | ((yes-or-no-p | 797 | ((yes-or-no-p |
| 776 | (if (string= (file-name-nondirectory filename) | 798 | (if (string= (file-name-nondirectory filename) |
| 777 | (buffer-name buf)) | 799 | (buffer-name buf)) |
| @@ -786,8 +808,7 @@ The buffer is not selected, just returned to the caller." | |||
| 786 | "File %s changed on disk. Reread from disk into %s? ") | 808 | "File %s changed on disk. Reread from disk into %s? ") |
| 787 | (file-name-nondirectory filename) | 809 | (file-name-nondirectory filename) |
| 788 | (buffer-name buf)))) | 810 | (buffer-name buf)))) |
| 789 | (save-excursion | 811 | (with-current-buffer buf |
| 790 | (set-buffer buf) | ||
| 791 | (revert-buffer t t))))) | 812 | (revert-buffer t t))))) |
| 792 | (save-excursion | 813 | (save-excursion |
| 793 | ;;; The truename stuff makes this obsolete. | 814 | ;;; The truename stuff makes this obsolete. |