help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to configure emacs to prompt for revert modified buffer at once


From: Thien-Thi Nguyen
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
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux)

() 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)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]