summaryrefslogtreecommitdiff
path: root/lisp/autorevert.el
diff options
context:
space:
mode:
authorLuc Teirlinck <teirllm@auburn.edu>2004-04-01 01:37:03 +0000
committerLuc Teirlinck <teirllm@auburn.edu>2004-04-01 01:37:03 +0000
commit71c8db4cd53ac3da32bd4fd2f76b9f1124675026 (patch)
tree93bfb5787fedb8b0856275a3629b29f7400c7ce5 /lisp/autorevert.el
parent012ad4a3f8f4d21dd87f8700bb01ad98afa85a60 (diff)
downloademacs-71c8db4cd53ac3da32bd4fd2f76b9f1124675026.tar.gz
Delete obsolete autoload's and defvar's.
(auto-revert-check-vc-info): New variable. (auto-revert-vc-cvs-file-version, auto-revert-vc-buffer-p) (auto-revert-handler-vc): Delete. (auto-revert-handler): Treat return value `fast' of buffer-stale-function specially. Check `auto-revert-check-vc-info'.
Diffstat (limited to 'lisp/autorevert.el')
-rw-r--r--lisp/autorevert.el119
1 files changed, 38 insertions, 81 deletions
diff --git a/lisp/autorevert.el b/lisp/autorevert.el
index 165c6b8b24f..6e74a96eff5 100644
--- a/lisp/autorevert.el
+++ b/lisp/autorevert.el
@@ -70,14 +70,8 @@
;; Dependencies:
(require 'timer)
-(autoload 'dired-get-filename "dired")
-(autoload 'vc-workfile-version "vc-hooks")
-(autoload 'vc-mode-line "vc-hooks")
-(eval-when-compile
- (defvar dired-directory)
- (defvar vc-mode)
- (require 'cl))
+(eval-when-compile (require 'cl))
;; Custom Group:
@@ -191,6 +185,27 @@ not necessarily make manual updates useless for non-file buffers."
:group 'auto-revert
:type 'hook)
+(defcustom auto-revert-check-vc-info nil
+ "If non-nil Auto Revert Mode reliably updates version control info.
+Auto Revert Mode updates version control info whenever the buffer
+needs reverting, regardless of the value of this variable.
+However, the version control state can change without changes to
+the work file. If the change is made from the current Emacs
+session, all info is updated. But if, for instance, a new
+version is checked in from outside the current Emacs session, the
+version control number in the mode line, as well as other version
+control related information, may not be properly updated. If you
+are worried about this, set this variable to a non-nil value.
+
+This currently works by automatically updating the version
+control info every `auto-revert-interval' seconds. Nevertheless,
+it should not cause excessive CPU usage on a reasonably fast
+machine, if it does not apply to too many version controlled
+buffers. CPU usage depends on the version control system"
+ :group 'auto-revert
+ :type 'boolean
+ :version "21.4")
+
(defvar global-auto-revert-ignore-buffer nil
"*When non-nil, Global Auto-Revert Mode will not revert this buffer.
@@ -279,87 +294,29 @@ will use an up-to-date value of `auto-revert-interval'"
(not (memq major-mode
global-auto-revert-ignore-modes)))))
-(defun auto-revert-vc-cvs-file-version (file)
- "Get version of FILE by reading control file on disk."
- (let* ((control "CVS/Entries")
- (name (file-name-nondirectory file))
- (path (format "%s/%s"
- (file-name-directory file)
- control)))
- (when (file-exists-p path)
- (with-temp-buffer
- (insert-file-contents-literally path)
- (goto-char (point-min))
- (when (re-search-forward
- ;; /file.txt/1.3/Mon Sep 15 18:43:20 2003//
- (format "%s/\\([.0-9]+\\)" (regexp-quote name))
- nil t)
- (match-string 1))))))
-
-(defun auto-revert-vc-buffer-p ()
- "Check if buffer is version controlled."
- (and (boundp 'vc-mode)
- (string-match "[0-9]" (or vc-mode ""))))
-
-(defun auto-revert-handler-vc ()
- "Check if version controlled buffer needs revert."
- ;; [Emacs 1]
- ;; 1. File is saved (*)
- ;; 2. checkin is done 1.1 -> 1.2
- ;; 3. VC reverts, so that updated version number is shown in mode line
- ;;
- ;; Suppose the same file has been opened in another Emacs and
- ;; autorevert.el is on.
- ;;
- ;; [Emacs 2]
- ;; 1. Step (1) is detected and buffer is reverted.
- ;; 2. But check in does not always change the file in dis, but possibly only
- ;; control files like CVS/Entries
- ;; 3. The buffer is not reverted to update VC version line.
- ;; Incorrect version number 1.1 is shown in this Emacs
- ;;
- (when (featurep 'vc)
- (let* ((file (buffer-file-name))
- (backend (vc-backend (buffer-file-name)))
- (version-buffer (vc-workfile-version file)))
- (when (stringp version-buffer)
- (cond
- ((eq backend 'CVS)
- (let ((version-file
- (auto-revert-vc-cvs-file-version (buffer-file-name))))
- (and (stringp version-file)
- (not (string-match version-file version-buffer)))))
- ((eq backend 'RCS)
- ;; TODO:
- ))))))
-
(defun auto-revert-handler ()
"Revert current buffer, if appropriate.
This is an internal function used by Auto-Revert Mode."
(unless (buffer-modified-p)
(let (revert)
- (cond
- ((auto-revert-vc-buffer-p)
- (when (auto-revert-handler-vc)
- (setq revert 'vc)))
- ((or (and (buffer-file-name)
- (file-readable-p (buffer-file-name))
- (not (verify-visited-file-modtime (current-buffer))))
- (and (or auto-revert-mode global-auto-revert-non-file-buffers)
- revert-buffer-function
- (boundp 'buffer-stale-function)
- (functionp buffer-stale-function)
- (funcall buffer-stale-function t)))
- (setq revert t)))
+ (or (and (buffer-file-name)
+ (file-readable-p (buffer-file-name))
+ (not (verify-visited-file-modtime (current-buffer)))
+ (setq revert t))
+ (and (or auto-revert-mode global-auto-revert-non-file-buffers)
+ revert-buffer-function
+ (boundp 'buffer-stale-function)
+ (functionp buffer-stale-function)
+ (setq revert (funcall buffer-stale-function t))))
(when revert
- (when auto-revert-verbose
+ (when (and auto-revert-verbose
+ (not (eq revert 'fast)))
(message "Reverting buffer `%s'." (buffer-name)))
- (revert-buffer 'ignore-auto 'dont-ask 'preserve-modes)
- ;; `preserve-modes' avoids changing the (minor) modes. But we
- ;; do want to reset the mode for VC, so we do it explicitly.
- (vc-find-file-hook)
- (if (eq revert 'vc)
- (vc-mode-line buffer-file-name))))))
+ (revert-buffer 'ignore-auto 'dont-ask 'preserve-modes))
+ ;; `preserve-modes' avoids changing the (minor) modes. But we
+ ;; do want to reset the mode for VC, so we do it manually.
+ (when (or revert auto-revert-check-vc-info)
+ (vc-find-file-hook)))))
(defun auto-revert-buffers ()
"Revert buffers as specified by Auto-Revert and Global Auto-Revert Mode.