From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.help Subject: Re: How to configure emacs to prompt for revert modified buffer at once it was modified Date: Tue, 21 Aug 2007 18:08:39 +0200 Organization: sometimes Message-ID: <87lkc498fs.fsf@ambire.localdomain> References: <87zm0mhzfb.fsf@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1187714432 23936 80.91.229.12 (21 Aug 2007 16:40:32 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 21 Aug 2007 16:40:32 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Aug 21 18:40:31 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1INWmL-0008FJ-B0 for geh-help-gnu-emacs@m.gmane.org; Tue, 21 Aug 2007 18:40:29 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1INWmK-0006zL-Kd for geh-help-gnu-emacs@m.gmane.org; Tue, 21 Aug 2007 12:40:28 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!goblin1!goblin.stu.neva.ru!uio.no!quimby.gnus.org!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 32 Original-NNTP-Posting-Host: ppp-239-33.21-151.libero.it Original-X-Trace: quimby.gnus.org 1187712545 22666 151.21.33.239 (21 Aug 2007 16:09:05 GMT) Original-X-Complaints-To: usenet@quimby.gnus.org Original-NNTP-Posting-Date: Tue, 21 Aug 2007 16:09:05 +0000 (UTC) User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) Cancel-Lock: sha1:xGt0Yo8fvf8PQRIjkSbHhvvfjk8= Original-Xref: shelby.stanford.edu gnu.emacs.help:151146 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:46719 Archived-At: () david@adboyd.com (J. David Boyd) () Tue, 21 Aug 2007 11:02:39 -0400 auto-revert-mode below are some functions i use to monitor the .c file produced by a (cute but buggy) scheme->C compiler. a file visited this way is thus protected against wanton kill-buffer commands (which fly from my fingers regularly w/o conscious thought). one less thing to worry about. of course, you need to explicitly `C-x C-q' at some point, either that or crash the computer. (exiting emacs also works, but who does that?!) thi ____________________________________________ (defun bury-if-read-only () "If buffer is writable, return t, otherwise bury it and return nil. This function is intended to added to `kill-buffer-query-functions'." (cond ((not buffer-read-only)) (t (message "(Burying %s -- make writable to really kill.)" (buffer-name)) (bury-buffer) nil))) (defun watch-file-preciously (filename) (interactive "fFilename: ") (find-file-read-only filename) (add-hook 'kill-buffer-query-functions 'bury-if-read-only nil t) (auto-revert-mode 1)) (global-set-key "\C-x\M-f" 'watch-file-preciously)