Re: Idle Time to Poll Serve

2020-02-20 Thread Adam Sjøgren via 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
   a...@koldfront.dk


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


Re: Idle Time to Poll Serve

2020-02-20 Thread Richmond
Adam Sjøgren via info-gnus-english  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


Re: Idle Time to Poll Serve

2020-02-20 Thread Adam Sjøgren via 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   a...@koldfront.dk
  egen diskrete charme"


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


Re: Idle Time to Poll Serve

2020-02-20 Thread Eric Abrahamsen
Richmond  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


Re: Idle Time to Poll Serve

2020-02-20 Thread Richmond
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


Re: Idle Time to Poll Serve

2020-02-20 Thread Richmond
Eric Abrahamsen  writes:

> Richmond  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


Re: Idle Time to Poll Serve

2020-02-20 Thread Eric Abrahamsen
Richmond  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


Idle Time to Poll Serve

2020-02-20 Thread Richmond
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