aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2013-01-10 21:26:15 +0100
committerMichael Albinus2013-01-10 21:26:15 +0100
commita778dd57d0da9004a72320f8082d4f6220f178e2 (patch)
tree7c945b0dc2290b693c6a3d5b860fd76da76f81ff
parent48660ca5db63d6245c56dd373adfcdb1879eb352 (diff)
downloademacs-a778dd57d0da9004a72320f8082d4f6220f178e2.tar.gz
emacs-a778dd57d0da9004a72320f8082d4f6220f178e2.zip
* autorevert.el (auto-revert-notify-enabled): Move up.
(auto-revert-use-notify): New defcustom. (auto-revert-mode, global-auto-revert-mode) (auto-revert-notify-add-watch, auto-revert-handler) (auto-revert-buffers): Use `auto-revert-use-notify' instead of `auto-revert-notify-enabled'.
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/autorevert.el43
2 files changed, 39 insertions, 13 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index da239252f7e..0d4566a91a6 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
12013-01-10 Michael Albinus <michael.albinus@gmx.de>
2
3 * autorevert.el (auto-revert-notify-enabled): Move up.
4 (auto-revert-use-notify): New defcustom.
5 (auto-revert-mode, global-auto-revert-mode)
6 (auto-revert-notify-add-watch, auto-revert-handler)
7 (auto-revert-buffers): Use `auto-revert-use-notify' instead of
8 `auto-revert-notify-enabled'.
9
12013-01-10 Elias Pipping <pipping@exherbo.org> 102013-01-10 Elias Pipping <pipping@exherbo.org>
2 11
3 * files.el (auto-mode-alist): Use doc-view for djvu files (bug#13164). 12 * files.el (auto-mode-alist): Use doc-view for djvu files (bug#13164).
diff --git a/lisp/autorevert.el b/lisp/autorevert.el
index 395323a074a..4434ed21169 100644
--- a/lisp/autorevert.el
+++ b/lisp/autorevert.el
@@ -49,7 +49,9 @@
49;; (except that your buffers will be reverted, of course). 49;; (except that your buffers will be reverted, of course).
50;; 50;;
51;; If Emacs is compiled with file watch support, notifications are 51;; If Emacs is compiled with file watch support, notifications are
52;; used instead of checking the time stamp of the files. 52;; used instead of checking the time stamp of the files. You can
53;; disable this by setting the user option `auto-revert-use-notify' to
54;; nil.
53;; 55;;
54;; After reverting a file buffer, Auto Revert Mode normally puts point 56;; After reverting a file buffer, Auto Revert Mode normally puts point
55;; at the same position that a regular manual revert would. However, 57;; at the same position that a regular manual revert would. However,
@@ -257,6 +259,28 @@ buffers. CPU usage depends on the version control system."
257This variable becomes buffer local when set in any fashion.") 259This variable becomes buffer local when set in any fashion.")
258(make-variable-buffer-local 'global-auto-revert-ignore-buffer) 260(make-variable-buffer-local 'global-auto-revert-ignore-buffer)
259 261
262(defconst auto-revert-notify-enabled
263 (or (featurep 'inotify) (featurep 'w32notify))
264 "Non-nil when Emacs has been compiled with file watch support.")
265
266(defcustom auto-revert-use-notify auto-revert-notify-enabled
267 "If non-nil Auto Revert Mode uses file watch functions.
268This requires Emacs being compiled with file watch support (see
269`auto-revert-notify-enabled'). You should set this variable
270through Custom only."
271 :group 'auto-revert
272 :type 'boolean
273 :set (lambda (variable value)
274 (set-default variable (and auto-revert-notify-enabled value))
275 (if (symbol-value variable)
276 (add-hook 'kill-buffer-hook 'auto-revert-notify-rm-watch)
277 (remove-hook 'kill-buffer-hook 'auto-revert-notify-rm-watch)
278 (when auto-revert-notify-enabled
279 (dolist (buf (buffer-list))
280 (with-current-buffer buf
281 (auto-revert-notify-rm-watch))))))
282 :version "24.4")
283
260;; Internal variables: 284;; Internal variables:
261 285
262(defvar auto-revert-buffer-list () 286(defvar auto-revert-buffer-list ()
@@ -279,13 +303,6 @@ the list of old buffers.")
279 (set (make-local-variable 'auto-revert-tail-pos) 303 (set (make-local-variable 'auto-revert-tail-pos)
280 (nth 7 (file-attributes buffer-file-name))))) 304 (nth 7 (file-attributes buffer-file-name)))))
281 305
282(defconst auto-revert-notify-enabled
283 (or (featurep 'inotify) (featurep 'w32notify))
284 "Non-nil when Emacs has been compiled with file watch support.")
285
286(when auto-revert-notify-enabled
287 (add-hook 'kill-buffer-hook 'auto-revert-notify-rm-watch))
288
289(defvar auto-revert-notify-watch-descriptor-hash-list 306(defvar auto-revert-notify-watch-descriptor-hash-list
290 (make-hash-table :test 'equal) 307 (make-hash-table :test 'equal)
291 "A hash table collecting all file watch descriptors. 308 "A hash table collecting all file watch descriptors.
@@ -320,7 +337,7 @@ without being changed in the part that is already in the buffer."
320 (if auto-revert-mode 337 (if auto-revert-mode
321 (if (not (memq (current-buffer) auto-revert-buffer-list)) 338 (if (not (memq (current-buffer) auto-revert-buffer-list))
322 (push (current-buffer) auto-revert-buffer-list)) 339 (push (current-buffer) auto-revert-buffer-list))
323 (when auto-revert-notify-enabled (auto-revert-notify-rm-watch)) 340 (when auto-revert-use-notify (auto-revert-notify-rm-watch))
324 (setq auto-revert-buffer-list 341 (setq auto-revert-buffer-list
325 (delq (current-buffer) auto-revert-buffer-list))) 342 (delq (current-buffer) auto-revert-buffer-list)))
326 (auto-revert-set-timer) 343 (auto-revert-set-timer)
@@ -426,7 +443,7 @@ specifies in the mode line."
426 (auto-revert-set-timer) 443 (auto-revert-set-timer)
427 (if global-auto-revert-mode 444 (if global-auto-revert-mode
428 (auto-revert-buffers) 445 (auto-revert-buffers)
429 (when auto-revert-notify-enabled 446 (when auto-revert-use-notify
430 (dolist (buf (buffer-list)) 447 (dolist (buf (buffer-list))
431 (with-current-buffer buf 448 (with-current-buffer buf
432 (auto-revert-notify-rm-watch)))))) 449 (auto-revert-notify-rm-watch))))))
@@ -458,7 +475,7 @@ will use an up-to-date value of `auto-revert-interval'"
458 475
459(defun auto-revert-notify-add-watch () 476(defun auto-revert-notify-add-watch ()
460 "Enable file watch for current buffer's associated file." 477 "Enable file watch for current buffer's associated file."
461 (when (and buffer-file-name auto-revert-notify-enabled) 478 (when (and buffer-file-name auto-revert-use-notify)
462 (auto-revert-notify-rm-watch) 479 (auto-revert-notify-rm-watch)
463 (let ((func (if (fboundp 'inotify-add-watch) 480 (let ((func (if (fboundp 'inotify-add-watch)
464 'inotify-add-watch 'w32-add-watch)) 481 'inotify-add-watch 'w32-add-watch))
@@ -506,7 +523,7 @@ This is an internal function used by Auto-Revert Mode."
506 (setq size 523 (setq size
507 (nth 7 (file-attributes 524 (nth 7 (file-attributes
508 buffer-file-name)))))) 525 buffer-file-name))))))
509 (if auto-revert-notify-enabled 526 (if auto-revert-use-notify
510 ;; There are file watches. 527 ;; There are file watches.
511 auto-revert-notify-modified-p 528 auto-revert-notify-modified-p
512 (and (not (file-remote-p buffer-file-name)) 529 (and (not (file-remote-p buffer-file-name))
@@ -628,7 +645,7 @@ the timer when no buffers need to be checked."
628 (delq buf auto-revert-buffer-list))) 645 (delq buf auto-revert-buffer-list)))
629 (when (auto-revert-active-p) 646 (when (auto-revert-active-p)
630 ;; Enable file watches. 647 ;; Enable file watches.
631 (when (and auto-revert-notify-enabled buffer-file-name 648 (when (and auto-revert-use-notify buffer-file-name
632 (not auto-revert-notify-watch-descriptor) 649 (not auto-revert-notify-watch-descriptor)
633 (auto-revert-notify-add-watch))) 650 (auto-revert-notify-add-watch)))
634 (auto-revert-handler))) 651 (auto-revert-handler)))