Path: utzoo!utgpu!jarvis.csri.toronto.edu!daemon From: cks@white.toronto.edu (Chris Siebenmann) Newsgroups: gnu.emacs.bug Subject: Re: Problem with reverting a buffer ... Message-ID: <89Jul17.123456edt.30756@snow.white.toronto.edu> Sender: Organization: Ziebmef home away from home References: <8907141502.AA18649@marvin.moncam.uucp> Distribution: gnu Date: 17 Jul 89 16:36:43 GMT moncam!paul@UUNET.UU.NET (Paul Hudson) writes: | Problem: how do I get the contents of the buffer correct without | changing the mode of the file on the disk? This function seems to work fine; I wrote it for my (as yet unposted) RCS package when I needed to do the same thing. It even attempts to preserve point and mark. ;; kill and reload a buffer from a file. (defun buf-kill-and-reload (fn) "Given FILE, cause the current version of that file to be loaded into a buffer. If the file was already in a buffer already, the buffer will be refreshed to contain the latest version of the file. If the buffer has been modified, the file will NOT be saved. Makes some attempt to keep the mark and point the same if the buffer was around before." (let ((buf (get-file-buffer fn))) (if buf (progn (switch-to-buffer buf) (let ((curp (point)) (curm (mark))) (set-buffer-modified-p nil) (kill-buffer buf) (find-file fn) (set-mark curm) (goto-char curp))) (find-file fn)) )) If invoked with (buf-kill-and-reload (buffer-file-name)) it does what you want. -- "I shall clasp my hands together and bow to the corners of the world." Number Ten Ox, "Bridge of Birds" Chris Siebenmann ...!utgpu!{ncrcan,ontmoh!moore}!ziebmef!cks cks@white.toronto.edu or ...!utgpu!{,csri!}cks