From xemacs-m  Fri Mar 14 07:39:02 1997
Received: from frege.math.ethz.ch (root@frege-d-math-north-g-west.math.ethz.ch [129.132.145.3])
	by xemacs.org (8.8.5/8.8.5) with SMTP id HAA09770
	for <xemacs-beta@xemacs.org>; Fri, 14 Mar 1997 07:39:01 -0600 (CST)
Received: from fresnel.math.ethz.ch (vroonhof@fresnel [129.132.145.6]) by frege.math.ethz.ch (8.6.12/Main-STAT-mailer) with ESMTP id OAA07936 for <xemacs-beta@xemacs.org>; Fri, 14 Mar 1997 14:38:34 +0100
Received: (vroonhof@localhost) by fresnel.math.ethz.ch (8.6.9/D-MATH-client) id OAA29642; Fri, 14 Mar 1997 14:36:07 +0100
Sender: vroonhof@math.ethz.ch
To: xemacs-beta@xemacs.org
Subject: [gnu.emacs.help] Re: automating reread from disk with (find-file buffer-file-name)
Mime-Version: 1.0 (generated by tm-edit 7.105)
Content-Type: multipart/mixed;
 boundary="Multipart_Fri_Mar_14_14:36:07_1997-1"
Content-Transfer-Encoding: 7bit
From: Jan Vroonhof <vroonhof@math.ethz.ch>
Date: 14 Mar 1997 14:36:07 +0100
Message-ID: <byvi6uk33s.fsf@math.ethz.ch>
Lines: 80
X-Mailer: Gnus v5.4.25/XEmacs 19.15

--Multipart_Fri_Mar_14_14:36:07_1997-1
Content-Type: text/plain; charset=US-ASCII


Should we make an attempt to fold things like this in 19.15?


--Multipart_Fri_Mar_14_14:36:07_1997-1
Content-Type: message/rfc822

From: Erik Naggum <erik@naggum.no>
Newsgroups: gnu.emacs.help
Subject: Re: automating reread from disk with (find-file buffer-file-name)
Date: 14 Mar 1997 09:42:31 +0000
Organization: Naggum Software; +47 2295 0313; http://www.naggum.no
Message-ID: <3067321351075746@naggum.no>
References: <sywiv2vemwd.fsf@sparky.cs.nyu.edu>
mail-copies-to: never

* Robert Ducharme
| I want to write a reload function that does a find-file of the file in
| the current buffer and automatically answers yes to "File
| buffer-file-name changed on disk. Reread from disk? (yes or no)."  The
| following gets me to the prompt; how can I automate a "yes" answer to the
| prompt?

in the next version of Emacs, this is controlled by a new variable,
`find-file-revert-without-query'.  here's the relevant diff.  the
`with-current-buffer' macro is new.  it can be faked with

    (defmacro with-current-buffer (buffer &rest forms)
      `(save-excursion
	 (set-buffer buffer)
	 ,@forms))

--- files.el;19.34	1996-07-28 06:50:58
+++ files.el;19.35	1997-02-20 04:09:24
@@ -767,6 +807,20 @@
 	      (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))

here's the definition of the new variable:

(defvar find-file-revert-without-query
  nil
  "*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.")

if you don't want to dump a new Emacs, put the modified function and the
variable definition in a new file, and load that.  DO NOT load files.elc
into Emacs again, it will overwrite a lot of variables that have
accumulated useful values.  (also fixed in the next version.)

#\Erik
-- 
hypertext -- too much text.
hypotext -- too little text.

--Multipart_Fri_Mar_14_14:36:07_1997-1--

