Gnus development mailing list
 help / color / mirror / Atom feed
From: Philipp Haselwarter <philipp.haselwarter@gmx.de>
To: ding@gnus.org
Subject: Re: scanning for new mail with demon-handler
Date: Mon, 20 Jun 2011 04:19:41 +0200	[thread overview]
Message-ID: <877h8hz1ky.fsf@nzebook.haselwarter.org> (raw)
In-Reply-To: <87mxhdwk3m.fsf@topper.koldfront.dk>

[-- Attachment #1: Type: text/plain, Size: 1210 bytes --]

On 2011-06-19 22:07 UT, Adam Sjøgren <asjo@koldfront.dk> wrote:

AS> On Sun, 19 Jun 2011 18:49:58 +0200, Philipp wrote:

>> +(fset 'gnus-demon-scan-news-1 + (apply-partially
>> 'gnus-demon-scan-news 1)) +(fset 'gnus-demon-scan-news-2 +
>> (apply-partially 'gnus-demon-scan-news 2))

AS> [...snipped the last 7...]

AS> That looks like...there must be a better way than such repetition?

>> (gnus-demon-add-handler 'gnus-demon-scan-news-1 121 10)

AS> Maybe you could do something like a lambda here instead?Along the
AS> lines of

AS>  (gnus-demon-add-handler '(lambda () (gnus-demon-scan-news 1)) 121
AS> 10)

AS> or something?

Using lambda-forms on timers has the same problem as their usage on
hooks, they're a pain to deal with once you added them. Simple overriding
or removing them fails. Evaluating gnus-demon-add-handler several times
results in a new timer getting added every time.

#+begin_src emacs-lisp
(gnus-demon-add-handler (lambda () (message "foo")) 8 3)
;; comparison with `eq' fails with current code:
(gnus-demon-remove-handler (lambda () (message "foo")))
#+end_src

Then again, this could be easily fixed, which would certainly make
sense, no matter if the fsets are provided or not:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: allow lambda-forms as gnus-demon-handler --]
[-- Type: text/x-patch, Size: 516 bytes --]

	Modified   lisp/gnus-demon.el
diff --git a/lisp/gnus-demon.el b/lisp/gnus-demon.el
index 419346b..c799a3c 100644
--- a/lisp/gnus-demon.el
+++ b/lisp/gnus-demon.el
@@ -87,7 +87,7 @@ Emacs has been idle for IDLE `gnus-demon-timestep's."
 
 (defun gnus-demon-remove-handler (function &optional no-init)
   "Remove the handler FUNCTION from the list of handlers."
-  (gnus-alist-pull function gnus-demon-handlers)
+  (gnus-alist-pull function gnus-demon-handlers 'use-assoc)
   (unless no-init
     (gnus-demon-init)))

[-- Attachment #3: Type: text/plain, Size: 85 bytes --]



AS>   Best regards,

AS>     Adam - not an expert.

best,

-- 
Philipp Haselwarter

      reply	other threads:[~2011-06-20  2:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-17 16:54 lee
2011-06-17 17:04 ` Adam Sjøgren
2011-06-17 19:05   ` lee
2011-06-17 19:17     ` Adam Sjøgren
2011-06-17 19:19     ` Adam Sjøgren
2011-06-17 20:34       ` lee
2011-06-19 16:49         ` Philipp Haselwarter
2011-06-19 18:08           ` lee
2011-06-19 22:07           ` Adam Sjøgren
2011-06-20  2:19             ` Philipp Haselwarter [this message]

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=877h8hz1ky.fsf@nzebook.haselwarter.org \
    --to=philipp.haselwarter@gmx.de \
    --cc=ding@gnus.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.
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 NNTP newsgroup(s).