From: Dima Kogan <lists@dima.secretsauce.net>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: emacs-devel@gnu.org
Subject: Re: Clarification about auto-revert-mode and inotify
Date: Tue, 21 Oct 2014 10:59:29 -0700 [thread overview]
Message-ID: <878uk9s3mh.fsf@secretsauce.net> (raw)
In-Reply-To: <jwvppdlk0bq.fsf-monnier+emacs@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 731 bytes --]
Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
>> NEWS; does this mean simply that auto-revert is more efficient?
>
> Indeed, IIUC the current auto-revert-mode implementation only uses the
> file-notification code to reduce the amount of polling, but the revert
> itself is still only performed from the 5s timer.
>
> I don't think there's a strong technical reason for that,
OK.
I'm attaching a prototype patch to fix this. It updates the buffer
immediately when a change is detected, unless the previous such update
happened very recently. If it DID happen very recently, the normal
timer-based update kicks in later.
Is such a patch reasonable? If so, I'll add the proper comments and
docstrings, and resubmit it.
dima
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: emacs_notify_immediate_prototype.patch --]
[-- Type: text/x-diff, Size: 1489 bytes --]
diff --git a/lisp/autorevert.el b/lisp/autorevert.el
index f1074e2..00e1664 100644
--- a/lisp/autorevert.el
+++ b/lisp/autorevert.el
@@ -531,6 +533,15 @@ will use an up-to-date value of `auto-revert-interval'"
;; Fallback to file checks.
(set (make-local-variable 'auto-revert-use-notify) nil))))
+
+
+(defvar auto-revert-notify-lockout-timer nil
+ "Lockout timer used by Auto-Revert Mode.")
+(make-variable-buffer-local 'auto-revert-notify-lockout-timer)
+
+(defvar auto-revert-notify-lockout-interval 3
+ "Lockout interval for the notify timers")
+
(defun auto-revert-notify-handler (event)
"Handle an EVENT returned from file notification."
(with-demoted-errors
@@ -566,6 +577,15 @@ will use an up-to-date value of `auto-revert-interval'"
(file-name-nondirectory buffer-file-name)))))
;; Mark buffer modified.
(setq auto-revert-notify-modified-p t)
+
+ (unless (timerp auto-revert-notify-lockout-timer)
+ (auto-revert-handler 1)
+
+ (setq auto-revert-notify-lockout-timer
+ (run-with-timer auto-revert-notify-lockout-interval nil
+ (lambda ()
+ (setq auto-revert-notify-lockout-timer nil)))))
+
;; No need to check other buffers.
(cl-return)))))))))
next prev parent reply other threads:[~2014-10-21 17:59 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-21 7:00 Clarification about auto-revert-mode and inotify Dima Kogan
2014-10-21 13:43 ` Stefan Monnier
2014-10-21 15:08 ` Eli Zaretskii
2014-10-21 16:28 ` Stefan Monnier
2014-10-21 17:47 ` Eli Zaretskii
2014-10-21 20:23 ` Stefan Monnier
2014-10-21 20:32 ` Eli Zaretskii
2014-10-21 21:32 ` Stefan Monnier
2014-10-22 2:47 ` Eli Zaretskii
2014-10-22 3:20 ` Stefan Monnier
2014-10-22 14:47 ` Eli Zaretskii
2014-10-22 17:09 ` Stefan Monnier
2014-10-24 7:02 ` Dima Kogan
2014-10-21 17:59 ` Dima Kogan [this message]
2014-10-21 18:34 ` Eli Zaretskii
2014-10-21 18:59 ` Dima Kogan
2014-10-21 19:36 ` Eli Zaretskii
2014-10-21 19:39 ` Dima Kogan
2014-10-21 20:09 ` Eli Zaretskii
2014-10-21 20:29 ` Dima Kogan
2014-10-22 2:42 ` Eli Zaretskii
2014-10-22 5:36 ` Per Starbäck
2014-10-22 14:51 ` Eli Zaretskii
2014-10-22 19:08 ` Per Starbäck
2014-10-22 19:35 ` Eli Zaretskii
2014-10-22 10:13 ` Florian Weimer
-- strict thread matches above, loose matches on Subject: below --
2014-10-21 6:01 Dima Kogan
2014-10-21 5:03 Dima Kogan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878uk9s3mh.fsf@secretsauce.net \
--to=lists@dima.secretsauce.net \
--cc=emacs-devel@gnu.org \
--cc=monnier@IRO.UMontreal.CA \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.