unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#30080: 24.5; write-region can reset idle time
@ 2018-01-11 21:00 Cecil Westerhof
  2018-01-11 23:49 ` Stefan Monnier
  0 siblings, 1 reply; 13+ messages in thread
From: Cecil Westerhof @ 2018-01-11 21:00 UTC (permalink / raw)
  To: 30080


It is possible that write-region resets idle time. As soon as I use
one or both of the following in my .emacs:
    (desktop-save-mode 1)
    (global-auto-revert-mode 1)

The idle time is reset when calling write-region.

To reproduce put one or both into .emacs.
Define the following function:
    (defun write-region-problem ()
      (message (format "Before: %s %s" (current-time) (current-idle-time)))
      (write-region "Just a test\n" nil "~/problem.log" t 0)
      (message (format "After:  %s %s" (current-time) (current-idle-time)))
      )

And execute:
    (setq timer-object (run-with-timer 30 30 'write-region-problem))

You then get output like the following:
    Before: (23127 39977 941713 503000) (0 29 994274 462000)
    After:  (23127 39977 982179 647000) (0 30 34741 483000)
    Before: (23127 40007 940217 421000) (0 29 946739 305000)
    After:  (23127 40007 981669 405000) (0 29 988192 219000)
    Before: (23127 40037 941670 105000) (0 29 944688 557000)
    After:  (23127 40037 991646 30000) (0 29 994665 603000)
    Before: (23127 40067 941685 17000) (0 29 938036 13000)
    After:  (23127 40067 992876 336000) (0 29 989228 329000)
    Before: (23127 40097 939595 311000) (0 29 936576 788000)
    After:  (23127 40097 977542 689000) (0 29 974525 333000)


If both are not defined, you get output like:
    Before: (23127 47206 936031 250000) (0 24 841129 146000)
    After:  (23127 47206 937987 23000) (0 24 843085 910000)
    Before: (23127 47236 936555 313000) (0 54 841653 459000)
    After:  (23127 47236 938648 51000) (0 54 843747 333000)
    Before: (23127 47266 935235 63000) (0 84 840333 256000)
    After:  (23127 47266 937094 166000) (0 84 842192 826000)
    Before: (23127 47296 936545 234000) (0 114 841643 122000)
    After:  (23127 47296 938517 313000) (0 114 843616 494000)


Before 19 December I did not have this problem. So it is recently
introduced.

My version of Emacs:
    GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.11) of 2017-09-12 on hullmann, modified by Debian

-- 
Cecil Westerhof
Senior Software Engineer
M Cecil@Decebal.nl

LinkedIn: http://www.linkedin.com/in/cecilwesterhof





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#30080: 24.5; write-region can reset idle time
  2018-01-11 21:00 bug#30080: 24.5; write-region can reset idle time Cecil Westerhof
@ 2018-01-11 23:49 ` Stefan Monnier
  2018-01-12  1:36   ` Cecil Westerhof
  0 siblings, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2018-01-11 23:49 UTC (permalink / raw)
  To: Cecil Westerhof; +Cc: 30080

>     (global-auto-revert-mode 1)

Ha, I think you have your culprit right there: my crystal ball says that
if you have auto-revert active on the file you modify with
`write-region` (or maybe even just a file in the same directory) any
modification to the file (e.g. via `write-region`) will send
a pseudo-event, which Emacs's command-loop will confuse for an actual
user event!


        Stefan





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#30080: 24.5; write-region can reset idle time
  2018-01-11 23:49 ` Stefan Monnier
@ 2018-01-12  1:36   ` Cecil Westerhof
  2018-01-12  9:11     ` Eli Zaretskii
  2018-01-12 14:56     ` Stefan Monnier
  0 siblings, 2 replies; 13+ messages in thread
From: Cecil Westerhof @ 2018-01-12  1:36 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 30080

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

>>     (global-auto-revert-mode 1)
>
> Ha, I think you have your culprit right there: my crystal ball says that
> if you have auto-revert active on the file you modify with
> `write-region` (or maybe even just a file in the same directory) any
> modification to the file (e.g. via `write-region`) will send
> a pseudo-event, which Emacs's command-loop will confuse for an actual
> user event!

The problem being that until the 19th of December it worked without a
problem. I did not change my .emacs.

Also (desktop-save-mode 1) has the same effect. When I do not have
(global-auto-revert-mode 1), but I do have (desktop-save-mode 1), then
also write-region will reset idle time.


It is even more funny: when I play a video with mpv, idle time is also
reset. And this I find really odd.

-- 
Cecil Westerhof
Senior Software Engineer
M Cecil@Decebal.nl

LinkedIn: http://www.linkedin.com/in/cecilwesterhof





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#30080: 24.5; write-region can reset idle time
  2018-01-12  1:36   ` Cecil Westerhof
@ 2018-01-12  9:11     ` Eli Zaretskii
  2018-01-12 10:36       ` Cecil Westerhof
  2018-01-12 14:56     ` Stefan Monnier
  1 sibling, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2018-01-12  9:11 UTC (permalink / raw)
  To: Cecil Westerhof; +Cc: 30080, monnier

> From: Cecil Westerhof <Cecil@decebal.nl>
> Date: Fri, 12 Jan 2018 02:36:52 +0100
> Cc: 30080@debbugs.gnu.org
> 
> Also (desktop-save-mode 1) has the same effect. When I do not have
> (global-auto-revert-mode 1), but I do have (desktop-save-mode 1), then
> also write-region will reset idle time.

desktop-save-mode writes the desktop file from time to time, and it
uses an idle timer, so I think this explains that.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#30080: 24.5; write-region can reset idle time
  2018-01-12  9:11     ` Eli Zaretskii
@ 2018-01-12 10:36       ` Cecil Westerhof
  2018-01-12 13:53         ` Eli Zaretskii
  0 siblings, 1 reply; 13+ messages in thread
From: Cecil Westerhof @ 2018-01-12 10:36 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 30080, monnier

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Cecil Westerhof <Cecil@decebal.nl>
>> Date: Fri, 12 Jan 2018 02:36:52 +0100
>> Cc: 30080@debbugs.gnu.org
>> 
>> Also (desktop-save-mode 1) has the same effect. When I do not have
>> (global-auto-revert-mode 1), but I do have (desktop-save-mode 1), then
>> also write-region will reset idle time.
>
> desktop-save-mode writes the desktop file from time to time, and it
> uses an idle timer, so I think this explains that.

I have two problems with that:
- I do not think that it is done every minute, or less. And the reset
  is done on the moment of the write-region of my command. So does not
  directly relate to the writing of the desktop file.
- Before 19 December I did not have this behaviour. So it started
  after an update. It did not work like this for more as five years,
  but started the 19th of December 2017.

-- 
Cecil Westerhof
Senior Software Engineer
M Cecil@Decebal.nl

LinkedIn: http://www.linkedin.com/in/cecilwesterhof





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#30080: 24.5; write-region can reset idle time
  2018-01-12 10:36       ` Cecil Westerhof
@ 2018-01-12 13:53         ` Eli Zaretskii
  2018-01-12 14:37           ` Cecil Westerhof
  0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2018-01-12 13:53 UTC (permalink / raw)
  To: Cecil Westerhof; +Cc: 30080, monnier

> From: Cecil Westerhof <Cecil@decebal.nl>
> Cc: monnier@IRO.UMontreal.CA,  30080@debbugs.gnu.org
> Date: Fri, 12 Jan 2018 11:36:15 +0100
> 
> > desktop-save-mode writes the desktop file from time to time, and it
> > uses an idle timer, so I think this explains that.
> 
> I have two problems with that:
> - I do not think that it is done every minute, or less. And the reset
>   is done on the moment of the write-region of my command. So does not
>   directly relate to the writing of the desktop file.

desktop.el auto-saves when something in the window/buffer
configuration changes, no matter how frequently that happens.  The
idle timer run by desktop.el uses the same timeout value as auto-save,
which is 30 sec by default.  Maybe these facts will allow you to find
out why desktop-save-mode has that effect.

> - Before 19 December I did not have this behaviour. So it started
>   after an update. It did not work like this for more as five years,
>   but started the 19th of December 2017.

I guess you will have to find out what changed with that update.  No
one else except yourself can do that.  Maybe it's some change in the
kernel, or in glibc, or in inotify.

FWIW, I cannot reproduce your problem, neither in "emacs -Q" nor if I
turn on global-auto-revert-mode or desktop-save-mode, neither on
GNU/Linux nor on MS-Windows.  So this is most probably something
specific to your system.

What is the value of system-configuration-features in that build, btw?
Maybe some of the features is responsible for that, and my builds are
without it.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#30080: 24.5; write-region can reset idle time
  2018-01-12 13:53         ` Eli Zaretskii
@ 2018-01-12 14:37           ` Cecil Westerhof
  2018-01-12 16:51             ` Glenn Morris
  0 siblings, 1 reply; 13+ messages in thread
From: Cecil Westerhof @ 2018-01-12 14:37 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 30080, monnier

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Cecil Westerhof <Cecil@decebal.nl>
>> Cc: monnier@IRO.UMontreal.CA,  30080@debbugs.gnu.org
>> Date: Fri, 12 Jan 2018 11:36:15 +0100
>> 
>> > desktop-save-mode writes the desktop file from time to time, and it
>> > uses an idle timer, so I think this explains that.
>> 
>> I have two problems with that:
>> - I do not think that it is done every minute, or less. And the reset
>>   is done on the moment of the write-region of my command. So does not
>>   directly relate to the writing of the desktop file.
>
> desktop.el auto-saves when something in the window/buffer
> configuration changes, no matter how frequently that happens.  The
> idle timer run by desktop.el uses the same timeout value as auto-save,
> which is 30 sec by default.  Maybe these facts will allow you to find
> out why desktop-save-mode has that effect.

But it is not desktop-save-mode that does it. As long as I do no
write-region the idle-time is not reset. So desktop-save-mode does not
reset idle time, but desktop-save-mode makes write region reset idle
time.

>> - Before 19 December I did not have this behaviour. So it started
>>   after an update. It did not work like this for more as five years,
>>   but started the 19th of December 2017.
>
> I guess you will have to find out what changed with that update.  No
> one else except yourself can do that.  Maybe it's some change in the
> kernel, or in glibc, or in inotify.

Well, I have to ask on the Debian mailing list then.


> FWIW, I cannot reproduce your problem, neither in "emacs -Q" nor if I
> turn on global-auto-revert-mode or desktop-save-mode, neither on
> GNU/Linux nor on MS-Windows.  So this is most probably something
> specific to your system.

I just tried it on an Ubuntu system and I get the same results.


> What is the value of system-configuration-features in that build, btw?
> Maybe some of the features is responsible for that, and my builds are
> without it.

How do I get that?

-- 
Cecil Westerhof
Senior Software Engineer
M Cecil@Decebal.nl

LinkedIn: http://www.linkedin.com/in/cecilwesterhof





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#30080: 24.5; write-region can reset idle time
  2018-01-12  1:36   ` Cecil Westerhof
  2018-01-12  9:11     ` Eli Zaretskii
@ 2018-01-12 14:56     ` Stefan Monnier
  2018-01-12 15:11       ` Cecil Westerhof
  1 sibling, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2018-01-12 14:56 UTC (permalink / raw)
  To: Cecil Westerhof; +Cc: 30080

>>>     (global-auto-revert-mode 1)
>> Ha, I think you have your culprit right there: my crystal ball says that
>> if you have auto-revert active on the file you modify with
>> `write-region` (or maybe even just a file in the same directory) any
>> modification to the file (e.g. via `write-region`) will send
>> a pseudo-event, which Emacs's command-loop will confuse for an actual
>> user event!
> The problem being that until the 19th of December it worked without a
> problem. I did not change my .emacs.

And I see also that keyboard.c does seem to do it right:

      if (CONSP (c)
          && (EQ (XCAR (c), Qselect_window)
#ifdef HAVE_DBUS
	      || EQ (XCAR (c), Qdbus_event)
#endif
#ifdef USE_FILE_NOTIFY
	      || EQ (XCAR (c), Qfile_notify)
#endif
	      || EQ (XCAR (c), Qconfig_changed_event))
          && !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
	   example banishing the mouse under mouse-avoidance-mode.  */
	timer_resume_idle ();

Hmm...

> It is even more funny: when I play a video with mpv, idle time is also
> reset. And this I find really odd.

Can you try to run Emacs under GDB?
Then start Emacs to try and reproduce the problem with mpv.
Once ready to start mpv, hit `C-c C-z` in GDB, then type

    break timer_stop_idle
    continue

then launch mpv and try to see the backtrace (with command `bt`) when
the timer_stop_idle breakpoint is triggered.
[ Then again, maybe this will trigger all the time, but is a false
  alarm because it would be undone right after by the above code.  ]


        Stefan





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#30080: 24.5; write-region can reset idle time
  2018-01-12 14:56     ` Stefan Monnier
@ 2018-01-12 15:11       ` Cecil Westerhof
  0 siblings, 0 replies; 13+ messages in thread
From: Cecil Westerhof @ 2018-01-12 15:11 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 30080

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

>> It is even more funny: when I play a video with mpv, idle time is also
>> reset. And this I find really odd.
>
> Can you try to run Emacs under GDB?
> Then start Emacs to try and reproduce the problem with mpv.
> Once ready to start mpv, hit `C-c C-z` in GDB, then type
>
>     break timer_stop_idle
>     continue
>
> then launch mpv and try to see the backtrace (with command `bt`) when
> the timer_stop_idle breakpoint is triggered.
> [ Then again, maybe this will trigger all the time, but is a false
>   alarm because it would be undone right after by the above code.  ]

And it is funnier still: I found out that this only happens when mpv
is started when clicking on a file in KTorrent. If I click om a file
in Thunar, or start mpv from the command line it does not happen.

I will try to do what you asked this weekend.

-- 
Cecil Westerhof
Senior Software Engineer
M Cecil@Decebal.nl

LinkedIn: http://www.linkedin.com/in/cecilwesterhof





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#30080: 24.5; write-region can reset idle time
  2018-01-12 14:37           ` Cecil Westerhof
@ 2018-01-12 16:51             ` Glenn Morris
  2018-01-12 17:10               ` Cecil Westerhof
  0 siblings, 1 reply; 13+ messages in thread
From: Glenn Morris @ 2018-01-12 16:51 UTC (permalink / raw)
  To: Cecil Westerhof; +Cc: 30080, monnier

Cecil Westerhof wrote:

>> What is the value of system-configuration-features in that build, btw?
>> Maybe some of the features is responsible for that, and my builds are
>> without it.
>
> How do I get that?

Upgrade to at least Emacs 25.1. Preferably 25.3.
(Is it just me who thinks investigating an Emacs 24.5 problem isn't
productive?)





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#30080: 24.5; write-region can reset idle time
  2018-01-12 16:51             ` Glenn Morris
@ 2018-01-12 17:10               ` Cecil Westerhof
  2018-01-12 18:22                 ` Stefan Monnier
  0 siblings, 1 reply; 13+ messages in thread
From: Cecil Westerhof @ 2018-01-12 17:10 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 30080, monnier

Glenn Morris <rgm@gnu.org> writes:

> Cecil Westerhof wrote:
>
>>> What is the value of system-configuration-features in that build, btw?
>>> Maybe some of the features is responsible for that, and my builds are
>>> without it.
>>
>> How do I get that?
>
> Upgrade to at least Emacs 25.1. Preferably 25.3.
> (Is it just me who thinks investigating an Emacs 24.5 problem isn't
> productive?)

Debian is always a bit behind, but I could look into upgrading
manually.

-- 
Cecil Westerhof
Senior Software Engineer
M Cecil@Decebal.nl

LinkedIn: http://www.linkedin.com/in/cecilwesterhof





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#30080: 24.5; write-region can reset idle time
  2018-01-12 17:10               ` Cecil Westerhof
@ 2018-01-12 18:22                 ` Stefan Monnier
  2018-01-12 22:59                   ` Cecil Westerhof
  0 siblings, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2018-01-12 18:22 UTC (permalink / raw)
  To: Cecil Westerhof; +Cc: 30080

>> (Is it just me who thinks investigating an Emacs 24.5 problem isn't
>> productive?)

Oh, my, I didn't even notice.

> Debian is always a bit behind, but I could look into upgrading
> manually.

Debian testing has 25.2, please try at least that version.


        Stefan





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#30080: 24.5; write-region can reset idle time
  2018-01-12 18:22                 ` Stefan Monnier
@ 2018-01-12 22:59                   ` Cecil Westerhof
  0 siblings, 0 replies; 13+ messages in thread
From: Cecil Westerhof @ 2018-01-12 22:59 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 30080

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

>>> (Is it just me who thinks investigating an Emacs 24.5 problem isn't
>>> productive?)
>
> Oh, my, I didn't even notice.
>
>> Debian is always a bit behind, but I could look into upgrading
>> manually.
>
> Debian testing has 25.2, please try at least that version.

Stable has also 25.1.1. I had to install emacs25 instead of emacs.
Done that and both problems disappeared. In a way this keeps me
wondering how it could appear and disappear, but I think I let it go.
;-)

Is there a reason to go to 25.2 instead of 25.1.1, or is this good
enough?

-- 
Cecil Westerhof
Senior Software Engineer
M Cecil@Decebal.nl

LinkedIn: http://www.linkedin.com/in/cecilwesterhof





^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2018-01-12 22:59 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-11 21:00 bug#30080: 24.5; write-region can reset idle time Cecil Westerhof
2018-01-11 23:49 ` Stefan Monnier
2018-01-12  1:36   ` Cecil Westerhof
2018-01-12  9:11     ` Eli Zaretskii
2018-01-12 10:36       ` Cecil Westerhof
2018-01-12 13:53         ` Eli Zaretskii
2018-01-12 14:37           ` Cecil Westerhof
2018-01-12 16:51             ` Glenn Morris
2018-01-12 17:10               ` Cecil Westerhof
2018-01-12 18:22                 ` Stefan Monnier
2018-01-12 22:59                   ` Cecil Westerhof
2018-01-12 14:56     ` Stefan Monnier
2018-01-12 15:11       ` Cecil Westerhof

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).