aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/autorevert.el57
1 files changed, 25 insertions, 32 deletions
diff --git a/lisp/autorevert.el b/lisp/autorevert.el
index 344f230b087..97d45a582e1 100644
--- a/lisp/autorevert.el
+++ b/lisp/autorevert.el
@@ -1,6 +1,6 @@
1;; autorevert --- Revert buffers when file on disk change. 1;; autorevert --- Revert buffers when file on disk change.
2 2
3;; Copyright (C) 1997 Free Software Foundation, Inc. 3;; Copyright (C) 1997, 1998 Free Software Foundation, Inc.
4 4
5;; Author: Anders Lindgren <andersl@csd.uu.se> 5;; Author: Anders Lindgren <andersl@csd.uu.se>
6;; Created: 1 Jun 1997 6;; Created: 1 Jun 1997
@@ -28,31 +28,21 @@
28;; Introduction: 28;; Introduction:
29;; 29;;
30;; Whenever a file that Emacs is editing has been changed by another 30;; Whenever a file that Emacs is editing has been changed by another
31;; program the user normally have to execute the command `revert-buffer' 31;; program the user normally has to execute the command `revert-buffer'
32;; to load the new content of the file into Emacs. 32;; to load the new content of the file into Emacs.
33;; 33;;
34;; This package contains two minor modes: Global Auto-Revert Mode and 34;; This package contains two minor modes: Global Auto-Revert Mode and
35;; Auto-Revert Mode. Both modes automatically reverts buffers 35;; Auto-Revert Mode. Both modes automatically revert buffers
36;; whenever the corresponding files have been changed on disk. 36;; whenever the corresponding files have been changed on disk.
37;; 37;;
38;; Auto-Revert Mode can be activated for individual buffers. 38;; Auto-Revert Mode can be activated for individual buffers.
39;; Global Auto-Revert Mode applies to all file buffers. 39;; Global Auto-Revert Mode applies to all file buffers.
40;; 40;;
41;; Both modes operates by checking the time stamp of all files at 41;; Both modes operate by checking the time stamp of all files at
42;; given intervals, the default is every five seconds. The check is 42;; intervals of `auto-revert-interval'. The default is every five
43;; aborted whenever the user actually use Emacs. Hopefully you will 43;; seconds. The check is aborted whenever the user actually uses
44;; never even notice that this package is active (except that your 44;; Emacs. You should never even notice that this package is active
45;; buffers will be reverted, of course). 45;; (except that your buffers will be reverted, of course).
46
47;; Installation:
48;;
49;; To install this package, place it in somewhere on Emacs' load-path,
50;; byte-compile it (not necessary), and place the following lines in
51;; the appropriate init file:
52;;
53;; (autoload 'auto-revert-mode "autorevert" nil t)
54;; (autoload 'turn-on-auto-revert-mode "autorevert" nil nil)
55;; (autoload 'global-auto-revert-mode "autorevert" nil t)
56 46
57;; Usage: 47;; Usage:
58;; 48;;
@@ -62,8 +52,9 @@
62;; To activate Global Auto-Revert Mode, press: 52;; To activate Global Auto-Revert Mode, press:
63;; M-x global-auto-revert-mode RET 53;; M-x global-auto-revert-mode RET
64;; 54;;
65;; To activate Global Auto-Revert Mode every time Emacs is started the 55;; To activate Global Auto-Revert Mode every time Emacs is started
66;; following line could be added to your ~/.emacs: 56;; customise the option `global-auto-revert-mode' or the following
57;; line could be added to your ~/.emacs:
67;; (global-auto-revert-mode 1) 58;; (global-auto-revert-mode 1)
68;; 59;;
69;; The function `turn-on-auto-revert-mode' could be added to any major 60;; The function `turn-on-auto-revert-mode' could be added to any major
@@ -87,7 +78,7 @@
87;; Files group under Emacs. 78;; Files group under Emacs.
88 79
89(defgroup auto-revert nil 80(defgroup auto-revert nil
90 "Revert individual buffer when file on disk change. 81 "Revert individual buffers when files on disk change.
91 82
92Auto-Revert Mode can be activated for individual buffer. 83Auto-Revert Mode can be activated for individual buffer.
93Global Auto-Revert Mode applies to all buffers." 84Global Auto-Revert Mode applies to all buffers."
@@ -99,14 +90,14 @@ Global Auto-Revert Mode applies to all buffers."
99(defvar auto-revert-mode nil 90(defvar auto-revert-mode nil
100 "*Non-nil when Auto-Revert Mode is active. 91 "*Non-nil when Auto-Revert Mode is active.
101 92
102Do never set this variable directly, use the command 93Never set this variable directly, use the command `auto-revert-mode'
103`auto-revert-mode' instead.") 94instead.")
104 95
105(defcustom global-auto-revert-mode nil 96(defcustom global-auto-revert-mode nil
106 "When on, buffers are automatically reverted when files on disk change. 97 "When on, buffers are automatically reverted when files on disk change.
107 98
108Set this variable when using \\[customize] only. Otherwise, use the 99Set this variable using \\[customize] only. Otherwise, use the
109command `global-auto-revert-mode' instead." 100command `global-auto-revert-mode'."
110 :group 'auto-revert 101 :group 'auto-revert
111 :initialize 'custom-initialize-default 102 :initialize 'custom-initialize-default
112 :set '(lambda (symbol value) 103 :set '(lambda (symbol value)
@@ -150,7 +141,7 @@ deactivated, and whenever a file is reverted."
150 "String to display when Global Auto-Revert Mode is active. 141 "String to display when Global Auto-Revert Mode is active.
151 142
152The default is nothing since when this mode is active this text doesn't 143The default is nothing since when this mode is active this text doesn't
153vary neither over time, nor between buffers. Hence a mode line text 144vary over time, or between buffers. Hence mode line text
154would only waste precious space." 145would only waste precious space."
155 :group 'auto-revert 146 :group 'auto-revert
156 :type 'string) 147 :type 'string)
@@ -192,7 +183,7 @@ Use this option with care since it could lead to excessive reverts."
192(defvar global-auto-revert-ignore-buffer nil 183(defvar global-auto-revert-ignore-buffer nil
193 "*When non-nil, Global Auto-Revert Mode will not revert this buffer. 184 "*When non-nil, Global Auto-Revert Mode will not revert this buffer.
194 185
195This variable becomes buffer local when set in any faishon.") 186This variable becomes buffer local when set in any fashion.")
196(make-variable-buffer-local 'global-auto-revert-ignore-buffer) 187(make-variable-buffer-local 'global-auto-revert-ignore-buffer)
197 188
198 189
@@ -218,9 +209,10 @@ the list of old buffers.")
218 209
219;;;###autoload 210;;;###autoload
220(defun auto-revert-mode (&optional arg) 211(defun auto-revert-mode (&optional arg)
221 "Revert buffer when file on disk change. 212 "Toggle reverting buffer when file on disk changes.
222 213
223This is a minor mode that affect only the current buffer. 214With arg, turn Auto Revert mode on if and only if arg is positive.
215This is a minor mode that affects only the current buffer.
224Use `global-auto-revert-mode' to automatically revert all buffers." 216Use `global-auto-revert-mode' to automatically revert all buffers."
225 (interactive "P") 217 (interactive "P")
226 (make-local-variable 'auto-revert-mode) 218 (make-local-variable 'auto-revert-mode)
@@ -256,7 +248,8 @@ This function is designed to be added to hooks, for example:
256(defun global-auto-revert-mode (&optional arg) 248(defun global-auto-revert-mode (&optional arg)
257 "Revert any buffer when file on disk change. 249 "Revert any buffer when file on disk change.
258 250
259This is a minor mode that affect all buffers. 251With arg, turn Auto Revert mode on globally if and only if arg is positive.
252This is a minor mode that affects all buffers.
260Use `auto-revert-mode' to revert a particular buffer." 253Use `auto-revert-mode' to revert a particular buffer."
261 (interactive "P") 254 (interactive "P")
262 (setq global-auto-revert-mode 255 (setq global-auto-revert-mode
@@ -297,13 +290,13 @@ reverted either when Auto-Revert Mode is active in that buffer, or
297when the variable `global-auto-revert-non-file-buffers' is non-nil 290when the variable `global-auto-revert-non-file-buffers' is non-nil
298and Global Auto-Revert Mode is active. 291and Global Auto-Revert Mode is active.
299 292
300This function stops whenever the user use Emacs. The buffers not 293This function stops whenever there is user input. The buffers not
301checked are stored in the variable `auto-revert-remaining-buffers'. 294checked are stored in the variable `auto-revert-remaining-buffers'.
302 295
303To avoid starvation, the buffers in `auto-revert-remaining-buffers' 296To avoid starvation, the buffers in `auto-revert-remaining-buffers'
304are checked first the next time this function is called. 297are checked first the next time this function is called.
305 298
306This function is also responslible for removing buffers no longer in 299This function is also responsible for removing buffers no longer in
307Auto-Revert mode from `auto-revert-buffer-list', and for canceling 300Auto-Revert mode from `auto-revert-buffer-list', and for canceling
308the timer when no buffers need to be checked." 301the timer when no buffers need to be checked."
309 (let ((bufs (if global-auto-revert-mode 302 (let ((bufs (if global-auto-revert-mode