Unnamed repository; edit this file 'description' to name the repository.
 help / color / Atom feed
* Idle Time to Poll Serve
@ 2020-02-20 14:05 Richmond
  2020-02-20 16:41 ` Eric Abrahamsen
  0 siblings, 1 reply; 8+ messages in thread
From: Richmond @ 2020-02-20 14:05 UTC (permalink / raw)
  To: info-gnus-english

I have devised this script to set up idle timers to poll the news
server. But it seems to cause emacs to hang after a while. If I use gtk
I can get it to respond with ctrl-g, but running in a terminal,
i.e. konsole or lxterminal, it is more difficult. What's wrong? This is
placed in .gnus

(defun news-check ()
  (ignore-errors
    (gnus-group-get-new-news)
    )
  (setq result (run-with-idle-timer (time-add (current-idle-time) 300) t (lambda () (news-check))))
  )

(defun tell-me-news ()
  (interactive)
  (setq result (run-with-idle-timer 300 t (lambda () (news-check))))
  (message "timer result %s" result)
)

(tell-me-news)

_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
https://lists.gnu.org/mailman/listinfo/info-gnus-english

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

* Re: Idle Time to Poll Serve
  2020-02-20 14:05 Idle Time to Poll Serve Richmond
@ 2020-02-20 16:41 ` Eric Abrahamsen
  2020-02-20 16:52   ` Richmond
  2020-02-20 17:15   ` Richmond
  0 siblings, 2 replies; 8+ messages in thread
From: Eric Abrahamsen @ 2020-02-20 16:41 UTC (permalink / raw)
  To: Richmond; +Cc: info-gnus-english

Richmond <dnomhcir@gmx.com> writes:

> I have devised this script to set up idle timers to poll the news
> server. But it seems to cause emacs to hang after a while. If I use gtk
> I can get it to respond with ctrl-g, but running in a terminal,
> i.e. konsole or lxterminal, it is more difficult. What's wrong? This is
> placed in .gnus
>
> (defun news-check ()
>   (ignore-errors
>     (gnus-group-get-new-news)
>     )
>   (setq result (run-with-idle-timer (time-add (current-idle-time) 300) t (lambda () (news-check))))
>   )

Why is this function recursive? That's bound to be a bad idea. I would
refactor to remove the recursion, and to only start another check after
the last one has completed.

_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
https://lists.gnu.org/mailman/listinfo/info-gnus-english

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

* Re: Idle Time to Poll Serve
  2020-02-20 16:41 ` Eric Abrahamsen
@ 2020-02-20 16:52   ` Richmond
  2020-02-20 17:15   ` Richmond
  1 sibling, 0 replies; 8+ messages in thread
From: Richmond @ 2020-02-20 16:52 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: info-gnus-english

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> Richmond <dnomhcir@gmx.com> writes:
>
>> I have devised this script to set up idle timers to poll the news
>> server. But it seems to cause emacs to hang after a while. If I use gtk
>> I can get it to respond with ctrl-g, but running in a terminal,
>> i.e. konsole or lxterminal, it is more difficult. What's wrong? This is
>> placed in .gnus
>>
>> (defun news-check ()
>>   (ignore-errors
>>     (gnus-group-get-new-news)
>>     )
>>   (setq result (run-with-idle-timer (time-add (current-idle-time) 300) t (lambda () (news-check))))
>>   )
>
> Why is this function recursive? That's bound to be a bad idea. I would
> refactor to remove the recursion, and to only start another check after
> the last one has completed.

I don't know how that would be possible. Once the news-check script has
completed, it has no power to do anything, so it would not be able to
set up another idle timer.

The script has to finish, otherwise emacs would be unavailable to
use. So it has to prepare the next run before it finishes. Unless I set
up many idle timers in advance, say enough to last 24 hours?


_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
https://lists.gnu.org/mailman/listinfo/info-gnus-english

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

* Re: Idle Time to Poll Serve
  2020-02-20 16:41 ` Eric Abrahamsen
  2020-02-20 16:52   ` Richmond
@ 2020-02-20 17:15   ` Richmond
  2020-02-20 17:44     ` Eric Abrahamsen
  2020-02-20 18:25     ` Adam Sjøgren via info-gnus-english
  1 sibling, 2 replies; 8+ messages in thread
From: Richmond @ 2020-02-20 17:15 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: info-gnus-english

I've modified the script so that it does not check the servers and I
think I see the problem:

News checked at Thu Feb 20 16:41:01 2020
News checked at Thu Feb 20 16:46:01 2020
News checked at Thu Feb 20 16:51:01 2020
News checked at Thu Feb 20 17:00:41 2020
News checked at Thu Feb 20 17:05:41 2020 [2 times]
News checked at Thu Feb 20 17:10:41 2020 [3 times]

It is checking multiple times. Why is it doing that?

(defun news-check ()
  (message "News checked at %s" (current-time-string))
  (setq result (run-with-idle-timer (time-add (current-idle-time) 300) t (lambda () (news-check))))
  )

(defun tell-me-news ()
  (interactive)
  (setq result (run-with-idle-timer 300 t (lambda () (news-check))))
  (message "timer result %s" result)
)

_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
https://lists.gnu.org/mailman/listinfo/info-gnus-english

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

* Re: Idle Time to Poll Serve
  2020-02-20 17:15   ` Richmond
@ 2020-02-20 17:44     ` Eric Abrahamsen
  2020-02-20 18:25     ` Adam Sjøgren via info-gnus-english
  1 sibling, 0 replies; 8+ messages in thread
From: Eric Abrahamsen @ 2020-02-20 17:44 UTC (permalink / raw)
  To: Richmond; +Cc: info-gnus-english

Richmond <dnomhcir@gmx.com> writes:

> I've modified the script so that it does not check the servers and I
> think I see the problem:
>
> News checked at Thu Feb 20 16:41:01 2020
> News checked at Thu Feb 20 16:46:01 2020
> News checked at Thu Feb 20 16:51:01 2020
> News checked at Thu Feb 20 17:00:41 2020
> News checked at Thu Feb 20 17:05:41 2020 [2 times]
> News checked at Thu Feb 20 17:10:41 2020 [3 times]
>
> It is checking multiple times. Why is it doing that?
>
> (defun news-check ()
>   (message "News checked at %s" (current-time-string))
>   (setq result (run-with-idle-timer (time-add (current-idle-time) 300)
> t (lambda () (news-check))))
>   )
>
> (defun tell-me-news ()
>   (interactive)
>   (setq result (run-with-idle-timer 300 t (lambda () (news-check))))
>   (message "timer result %s" result)
> )

Why two timers? Why recursive? I don't have time (or patience!) to
unpick exactly what's happening here, but I would suggest starting with
the simplest possible solution and making that work first.

_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
https://lists.gnu.org/mailman/listinfo/info-gnus-english

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

* Re: Idle Time to Poll Serve
  2020-02-20 17:15   ` Richmond
  2020-02-20 17:44     ` Eric Abrahamsen
@ 2020-02-20 18:25     ` Adam Sjøgren via info-gnus-english
  2020-02-20 22:02       ` Richmond
  1 sibling, 1 reply; 8+ messages in thread
From: Adam Sjøgren via info-gnus-english @ 2020-02-20 18:25 UTC (permalink / raw)
  To: info-gnus-english

As your approach is giving you problems, maybe it would make sense to
look into Gnus' demons?

 · http://gnus.org/manual/gnus_119.html#Daemons

I use this:

  ; Demon to fetch email every 5 minutes when Emacs has been idle for 5 minutes:
  (gnus-demon-add-handler 'gnus-demon-scan-news 5 5)
  ; Demon to send queued email every other minute:
  (gnus-demon-add-handler 'gnus-delay-send-queue 1 nil)
  (gnus-demon-init)

To my surprise, the manual doesn't mention gnus-demon-scan-news, which I
would think was the most obvious one to write about...

Hm, maybe it is obsolete? I guess this is the current way:

,----[ C-h f gnus-demon-add-rescan RET ]
| gnus-demon-add-rescan is an autoloaded compiled Lisp function in
| ‘gnus-demon.el’.
| 
| (gnus-demon-add-rescan)
| 
| Add daemonic scanning of new articles from all backends.
`----

?


  Best regards,

    Adam

-- 
 "Lidt som at skylle en pose lakridskonfekt ned med         Adam Sjøgren
  en flaske Kahlua, men det kan jo også have sin       asjo@koldfront.dk
  egen diskrete charme"


_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
https://lists.gnu.org/mailman/listinfo/info-gnus-english

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

* Re: Idle Time to Poll Serve
  2020-02-20 18:25     ` Adam Sjøgren via info-gnus-english
@ 2020-02-20 22:02       ` Richmond
  2020-02-21  7:35         ` Adam Sjøgren via info-gnus-english
  0 siblings, 1 reply; 8+ messages in thread
From: Richmond @ 2020-02-20 22:02 UTC (permalink / raw)
  To: Adam Sjøgren via info-gnus-english; +Cc: Adam Sjøgren

Adam Sjøgren via info-gnus-english <info-gnus-english@gnu.org> writes:

> As your approach is giving you problems, maybe it would make sense to
> look into Gnus' demons?
>
>  · http://gnus.org/manual/gnus_119.html#Daemons
>
> I use this:
>
>   ; Demon to fetch email every 5 minutes when Emacs has been idle for 5 minutes:
>   (gnus-demon-add-handler 'gnus-demon-scan-news 5 5)
>   ; Demon to send queued email every other minute:
>   (gnus-demon-add-handler 'gnus-delay-send-queue 1 nil)
>   (gnus-demon-init)
>
> To my surprise, the manual doesn't mention gnus-demon-scan-news, which I
> would think was the most obvious one to write about...
>
> Hm, maybe it is obsolete? I guess this is the current way:
>
> ,----[ C-h f gnus-demon-add-rescan RET ]
> | gnus-demon-add-rescan is an autoloaded compiled Lisp function in
> | ‘gnus-demon.el’.
> | 
> | (gnus-demon-add-rescan)
> | 
> | Add daemonic scanning of new articles from all backends.
> `----
>
> ?
>
>
>   Best regards,
>
>     Adam

Fantastic. It seems to work with me just doing this:

(gnus-demon-add-handler 'gnus-demon-scan-news 5 t)

So much time and effort replaced with one line!

Thanks!

_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
https://lists.gnu.org/mailman/listinfo/info-gnus-english

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

* Re: Idle Time to Poll Serve
  2020-02-20 22:02       ` Richmond
@ 2020-02-21  7:35         ` Adam Sjøgren via info-gnus-english
  0 siblings, 0 replies; 8+ messages in thread
From: Adam Sjøgren via info-gnus-english @ 2020-02-21  7:35 UTC (permalink / raw)
  To: info-gnus-english

Richmond writes:

> So much time and effort replaced with one line!

Gnus in a nutshell: so much time and effort saved, when you find the
right line.


  :-),

   Adam

-- 
 "I love loopholes."                                        Adam Sjøgren
                                                       asjo@koldfront.dk


_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
https://lists.gnu.org/mailman/listinfo/info-gnus-english

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

end of thread, back to index

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-20 14:05 Idle Time to Poll Serve Richmond
2020-02-20 16:41 ` Eric Abrahamsen
2020-02-20 16:52   ` Richmond
2020-02-20 17:15   ` Richmond
2020-02-20 17:44     ` Eric Abrahamsen
2020-02-20 18:25     ` Adam Sjøgren via info-gnus-english
2020-02-20 22:02       ` Richmond
2020-02-21  7:35         ` Adam Sjøgren via info-gnus-english

Unnamed repository; edit this file 'description' to name the repository.

Archives are clonable: git clone --mirror http://inbox.vuxu.org/info-gnus-english

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.emacs.gnus.user


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git