[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#23207: 25.1.50; file-notify event restarts the idle timer

From: Michael Albinus
Subject: bug#23207: 25.1.50; file-notify event restarts the idle timer
Date: Sun, 03 Apr 2016 18:05:17 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

Johan Claesson <address@hidden> 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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]