all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Cecil Westerhof <Cecil@decebal.nl>
To: help-gnu-emacs@gnu.org
Subject: Re: Idel time continually around 60 seconds
Date: Wed, 10 Jan 2018 22:48:30 +0100	[thread overview]
Message-ID: <87o9m1v101.fsf@munus.decebal.nl> (raw)
In-Reply-To: mailman.7156.1515611667.27995.help-gnu-emacs@gnu.org

Narendra Joshi <narendraj9@gmail.com> writes:

> Cecil Westerhof <Cecil@decebal.nl> writes:
>
>> I am using Gnus and I have installed a daemon that depending on the
>> amount of idle time does something, or not. But strangely the idle
>> time is continuously around 60 seconds. (And I want it to be more.)
>>
>> I added some debugging to my daemon routine:
>> 2018-01-10 14:33:49: Starting gnus-idle-daemon ((23126 5693 809219 184000), (0 60 3465 810000))
>>            14:33:50: Leaving gnus-idle-daemon (1 second, (0 60 604458 776000))
>> 2018-01-10 14:34:50: Starting gnus-idle-daemon ((23126 5754 456491 143000), (0 60 858 915000))
>>            14:34:50: Leaving gnus-idle-daemon (0 seconds, (0 60 516542 418000))
>> 2018-01-10 14:35:51: Starting gnus-idle-daemon ((23126 5815 17667 46000), (0 60 792 785000))
>>            14:35:51: Leaving gnus-idle-daemon (0 seconds, (0 60 499851 979000))
>> 2018-01-10 14:36:51: Starting gnus-idle-daemon ((23126 5875 570675 402000), (0 60 712 877000))
>>            14:36:52: Leaving gnus-idle-daemon (1 second, (0 60 490399 246000))
>> 2018-01-10 14:37:52: Starting gnus-idle-daemon ((23126 5936 115162 38000), (0 60 696 902000))
>>            14:37:52: Leaving gnus-idle-daemon (0 seconds, (0 60 541211 971000))
>>
>> When entering I display the values of current-time and
>> current-idle-time. When leaving only current-idle-time.
>>
>> What could be the reason of this?
> Can you share the code you are using for the above?

It is a lot of code, but I shall give the gist.

Activating is done with:
    (gnus-demon-add-handler 'dcbl-gnus-idle-daemon 1 nil)

I changed the last parameter to nil, so the daemon routine is called
every minute. If the system has been idle, or not.

The routine itself (which calls other functions again) is:
    (defun dcbl-gnus-idle-daemon ()
      "Do potential time consuming things when Emacs is idle;
    At the moment:
    - dcbl-gnus-delay-send-queue
    - gnus-group-get-new-news.
    - gnus-group-expire-all-groups"
      (setq dcbl-gnus-current-log-format 'start)
      (let ((log-enter-and-leave (and (integerp dcbl-gnus-idle-daemon-do-log)
                                      (>=       dcbl-gnus-idle-daemon-do-log 10)))
            (start-time          (current-time)))
        (when log-enter-and-leave
          (dcbl-gnus-log-message (format "Starting gnus-idle-daemon (%s, %s)"
                                         (current-time) (current-idle-time))))
        (when (and dcbl-gnus-idle-daemon-semafoor
                   (>= (time-difference dcbl-gnus-idle-daemon-semafoor (current-time))
                       (* 15 +seconds-in-minute+)))
          (setq dcbl-gnus-current-log-format 'start)
          (dcbl-gnus-log-message "ERROR: Needed to reset gnus-idle-daemon-semafoor")
          (setq dcbl-gnus-idle-daemon-semafoor nil))
        (unless dcbl-gnus-idle-daemon-semafoor
          (setq dcbl-gnus-idle-daemon-semafoor (current-time))
          (condition-case err
              ;; Protected form.
              (dolist (poll-element dcbl-gnus-poll-struct)
                (dcbl-gnus-idle-daemon-call-function poll-element))
            ;; The handler.
            (error
             (dcbl-gnus-log-message (format
                                     "Error in dcbl-gnus-idle-daemon dolist: %s"
                                     err))
             nil))
          (setq dcbl-gnus-idle-daemon-semafoor nil))
        (when log-enter-and-leave
          (dcbl-gnus-log-message (format "Leaving gnus-idle-daemon (%s, %s)"
                                         (time-difference-formatted start-time)
                                         (current-idle-time))))))

When not using Emacs, but playing a video through mpv, I get:
2018-01-10 22:32:35: Starting gnus-idle-daemon ((23126 34419 369076 610000), (0 0 658640 85000))
           22:32:36: Leaving gnus-idle-daemon (1 second, (0 1 392452 151000))
2018-01-10 22:33:35: Starting gnus-idle-daemon ((23126 34479 369090 736000), (0 0 753334 161000))
           22:33:36: Leaving gnus-idle-daemon (1 second, (0 1 562405 319000))
2018-01-10 22:34:35: Starting gnus-idle-daemon ((23126 34539 368969 98000), (0 0 673375 295000))
           22:34:36: Leaving gnus-idle-daemon (1 second, (0 1 432972 290000))

So mpv looks to make Emacs think it is not idle at all.

After this I let Emacs be idle for a few minutes and this gave the
following:
2018-01-10 22:42:35: Starting gnus-idle-daemon ((23126 35019 371985 309000), (0 59 125327 787000))
           22:42:36: Leaving gnus-idle-daemon (1 second, (0 60 16979 177000))
2018-01-10 22:43:35: Starting gnus-idle-daemon ((23126 35079 371650 415000), (0 59 52674 710000))
           22:43:36: Leaving gnus-idle-daemon (1 second, (0 59 827891 167000))
2018-01-10 22:44:35: Starting gnus-idle-daemon ((23126 35139 370952 276000), (0 59 165616 289000))
           22:44:36: Leaving gnus-idle-daemon (1 second, (0 59 913835 893000))
2018-01-10 22:45:35: Starting gnus-idle-daemon ((23126 35199 371468 342000), (0 59 196502 494000))
           22:45:36: Leaving gnus-idle-daemon (1 second, (0 60 8895 962000))

So my routine does nothing to change idle time, but when coming back,
it is as if idle time was reset.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


  parent reply	other threads:[~2018-01-10 21:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-10 13:44 Idel time continually around 60 seconds Cecil Westerhof
2018-01-10 15:11 ` Cecil Westerhof
2018-01-10 19:14 ` Narendra Joshi
     [not found] ` <mailman.7156.1515611667.27995.help-gnu-emacs@gnu.org>
2018-01-10 21:48   ` Cecil Westerhof [this message]
2018-01-11 17:24     ` Cecil Westerhof

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=87o9m1v101.fsf@munus.decebal.nl \
    --to=cecil@decebal.nl \
    --cc=help-gnu-emacs@gnu.org \
    /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.