GNU bug report logs -
#23207
25.1.50; file-notify event restarts the idle timer
Previous Next
Full log
View this message in rfc822 format
Johan Claesson <johanclaesson <at> bredband.net> writes:
> Hi,
Hi Johan,
> Every time there is a file-notify event the idle timer is restarted.
> This will postpone the triggering of idle timers. If there are
> periodical file-notify events they may prevent idle timers from ever
> triggering. The following recipe creates periodical file-notify
> events with the help of a normal non-idle timer. The poor idle timer
> started last in the recipe will never get to run.
>
> emacs -Q
>
> (with-current-buffer (find-file-noselect "/tmp/changing.txt")
> (setq auto-revert-interval 0.5)
> (auto-revert-mode))
> (run-with-timer 1 1 (lambda () (write-region "x" nil "/tmp/changing.txt")))
> (run-with-idle-timer 3 t (lambda () (message "Just idling")))
>
> The same behavior is also present in 24.4 and 24.5 (i have not checked
> older versions).
Thanks for the report. There is a problem, indeed!
> The idle timer gets restarted in read_char in keyboard.c. The
> following patch avoids this (but i am not sure it is the right
> thing to do).
>
> diff --git a/src/keyboard.c b/src/keyboard.c
> index 1a5dbd0..b71c656 100644
> --- a/src/keyboard.c
> +++ b/src/keyboard.c
> @@ -2834,7 +2834,9 @@ read_char (int commandflag, Lisp_Object map,
> last_input_event = c;
> call4 (Qcommand_execute, tem, Qnil, Fvector (1, &last_input_event), Qt);
>
> - if (CONSP (c) && EQ (XCAR (c), Qselect_window) && !end_time)
> + if (CONSP (c)
> + && (EQ (XCAR (c), Qselect_window) || EQ (XCAR (c), Qfile_notify))
> + && !end_time)
> /* We stopped being idle for this event; undo that. This
> prevents automatic window selection (under
> mouse_autoselect_window from acting as a real input event, for
Looks good to me. Of course, we must wrap EQ (XCAR (c), Qfile_notify) by
#ifdef USE_FILE_NOTIFY; not all Emacs instances are configured to use
file notifications.
> This is in the handing of special-event-map which includes
> file-notify. special-event-map includes some events that should
> restart the idle timer because they are user input (like drag-n-drop).
> But file-notify is not user input so i think it should not restart the
> idle timer.
>
> The same probably goes for dbus-event and config-changed-event that
> also are in the special-event-map. Maybe they also should be exempted
> in the same way.
I agree for dbus-event. Don't know whether we need it also for
config-changed-event, my naïve gut feeling tells me that this doesn't
happen very often. Maybe somebody else knows better.
> Also i don't understand why this code checks for Qselect_window.
> select-window is not included in special-event-map so that should
> never turn up there.
Same here.
Let's wait for some few days. If nobody else contributes further, I
would apply your patch, including dbus-event.
> Regards,
>
> /Johan
Best regards, Michael.
This bug report was last modified 9 years and 101 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.