comparison lisp/files.el @ 16684:483a15efdf87

(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.
author Richard M. Stallman <rms@gnu.org>
date Sun, 15 Dec 1996 20:52:40 +0000
parents 895dc357b9a2
children 049c87a96dca
comparison
equal deleted inserted replaced
16683:6802dbd07a80 16684:483a15efdf87
112 112
113 (defconst find-file-visit-truename nil 113 (defconst find-file-visit-truename nil
114 "*Non-nil means visit a file under its truename. 114 "*Non-nil means visit a file under its truename.
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
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.")
117 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).
121 This pair of numbers uniquely identifies the file. 129 This pair of numbers uniquely identifies the file.
770 (if buf 778 (if buf
771 (or nowarn 779 (or nowarn
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))
778 (format 800 (format
779 (if (buffer-modified-p buf) 801 (if (buffer-modified-p buf)
784 (if (buffer-modified-p buf) 806 (if (buffer-modified-p buf)
785 "File %s changed on disk. Discard your edits in %s? " 807 "File %s changed on disk. Discard your edits in %s? "
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.
794 ;;; (let* ((link-name (car (file-attributes filename))) 815 ;;; (let* ((link-name (car (file-attributes filename)))
795 ;;; (linked-buf (and (stringp link-name) 816 ;;; (linked-buf (and (stringp link-name)