Gnus development mailing list
 help / color / mirror / Atom feed
* [Patch] tell expiry-hook functions where expired messages are going
@ 2014-07-29  9:04 Eric Abrahamsen
  2014-08-06  8:06 ` Alan Schmitt
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Abrahamsen @ 2014-07-29  9:04 UTC (permalink / raw)
  To: ding; +Cc: Lars Ingebrigtsen

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

This patch lets functions registered in the
`summary-article-expire-hook' know which group the expired articles are
going to. In particular this is useful for the registry: if people are
using expiration to move articles to a different group, rather than
deleting them, the registry should know where they've gone.

If nnmail-expiry-target is a function, this will still work, but not
quite as the docstring says: the hook function is given the from-group
as an argument, but is *not* called in a buffer narrowed to the message,
as it says. That would be hard to do, though, and this seems better than
nothing.

Eric


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Tell-expiry-hook-functions-where-the-message-is-goin.patch --]
[-- Type: text/x-diff, Size: 1075 bytes --]

From d89d596301fae28f94ce2370b7affe8719361ce3 Mon Sep 17 00:00:00 2001
From: Eric Abrahamsen <eric@ericabrahamsen.net>
Date: Tue, 29 Jul 2014 16:53:09 +0800
Subject: [PATCH] Tell expiry-hook functions where the message is going

* lisp/gnus-sum.el (gnus-summary-expire-articles): functions
  registered to the gnus-summary-article-expire-hook should be told
  where the function is going. In particular, the gnus registry might
  want to know.
---
 lisp/gnus-sum.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/gnus-sum.el b/lisp/gnus-sum.el
index c0e099b..4f061cd 100644
--- a/lisp/gnus-sum.el
+++ b/lisp/gnus-sum.el
@@ -10449,7 +10449,10 @@ This will be the case if the article has both been mailed and posted."
 					(gnus-data-header
 					 (assoc article (gnus-data-list nil)))
 					gnus-newsgroup-name
-					nil
+					(if (fboundp nnmail-expiry-target)
+					    (funcall nnmail-expiry-target
+						     gnus-newsgroup-name)
+					  nnmail-expiry-target)
 					nil)))))))
 	(gnus-message 6 "Expiring articles...done")))))
 
-- 
2.0.3


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

* Re: [Patch] tell expiry-hook functions where expired messages are going
  2014-07-29  9:04 [Patch] tell expiry-hook functions where expired messages are going Eric Abrahamsen
@ 2014-08-06  8:06 ` Alan Schmitt
  2014-08-06  8:45   ` Eric Abrahamsen
  0 siblings, 1 reply; 9+ messages in thread
From: Alan Schmitt @ 2014-08-06  8:06 UTC (permalink / raw)
  To: ding

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

Hello,

I gave this patch a try (as it's been applied to the git repo and I've
been able to use it) and I'm seeing an error when messages are refiled
during expiration.

Here is the backtrace:

Debugger entered--Lisp error: (wrong-type-argument symbolp "nnimap+zimbra:archive")
  fboundp("nnimap+zimbra:archive")
  gnus-summary-expire-articles()
  run-hooks(gnus-summary-prepare-exit-hook)
  apply(run-hooks gnus-summary-prepare-exit-hook)
  gnus-run-hooks(gnus-summary-prepare-exit-hook)
  gnus-summary-exit()
  call-interactively(gnus-summary-exit nil nil)

The problematic string corresponds to the target mailbox for the
expiration:

#+begin_src emacs-lisp
  (setq gnus-parameters
        '(("^old.*"
           (total-expire . t)
           (expiry-wait . 1)
           (expiry-target . "nnimap+zimbra:archive"))
          ...
          ("^work$"
           (total-expire . t)
           (expiry-wait . 7)
           (expiry-target . "nnimap+zimbra:archive"))
          ...
          ))

#+end_src

Looking at the code, the error comes from the patched code. Shouldn't
there be a check that `nnmail-expiry-target' is a symbol before calling
fboundp?

Thanks,

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7

[-- Attachment #2: Type: application/pgp-signature, Size: 494 bytes --]

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

* Re: [Patch] tell expiry-hook functions where expired messages are going
  2014-08-06  8:06 ` Alan Schmitt
@ 2014-08-06  8:45   ` Eric Abrahamsen
  2014-08-06 11:00     ` Katsumi Yamaoka
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Abrahamsen @ 2014-08-06  8:45 UTC (permalink / raw)
  To: ding

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> Hello,
>
> I gave this patch a try (as it's been applied to the git repo and I've
> been able to use it) and I'm seeing an error when messages are refiled
> during expiration.

Gah, that was my error. The patch should have used functionp and not
fboundp. Can someone fix that please?

Sorry!

E

> Here is the backtrace:
>
> Debugger entered--Lisp error: (wrong-type-argument symbolp "nnimap+zimbra:archive")
>   fboundp("nnimap+zimbra:archive")
>   gnus-summary-expire-articles()
>   run-hooks(gnus-summary-prepare-exit-hook)
>   apply(run-hooks gnus-summary-prepare-exit-hook)
>   gnus-run-hooks(gnus-summary-prepare-exit-hook)
>   gnus-summary-exit()
>   call-interactively(gnus-summary-exit nil nil)
>
> The problematic string corresponds to the target mailbox for the
> expiration:
>
> #+begin_src emacs-lisp
>   (setq gnus-parameters
>         '(("^old.*"
>            (total-expire . t)
>            (expiry-wait . 1)
>            (expiry-target . "nnimap+zimbra:archive"))
>           ...
>           ("^work$"
>            (total-expire . t)
>            (expiry-wait . 7)
>            (expiry-target . "nnimap+zimbra:archive"))
>           ...
>           ))
>
> #+end_src
>
> Looking at the code, the error comes from the patched code. Shouldn't
> there be a check that `nnmail-expiry-target' is a symbol before calling
> fboundp?
>
> Thanks,
>
> Alan




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

* Re: [Patch] tell expiry-hook functions where expired messages are going
  2014-08-06  8:45   ` Eric Abrahamsen
@ 2014-08-06 11:00     ` Katsumi Yamaoka
  2014-08-06 11:14       ` Katsumi Yamaoka
  0 siblings, 1 reply; 9+ messages in thread
From: Katsumi Yamaoka @ 2014-08-06 11:00 UTC (permalink / raw)
  To: ding

On Wed, 06 Aug 2014 16:45:57 +0800, Eric Abrahamsen wrote:
> Alan Schmitt <alan.schmitt@polytechnique.org> writes:

>> I gave this patch a try (as it's been applied to the git repo and I've
>> been able to use it) and I'm seeing an error when messages are refiled
>> during expiration.

> Gah, that was my error. The patch should have used functionp and not
> fboundp. Can someone fix that please?

`functionp' doesn't fix it, either.  My `nnmail-expiry-target' is
the symbol `delete', that is the default.  I got:

(wrong-number-of-arguments delete 1)



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

* Re: [Patch] tell expiry-hook functions where expired messages are going
  2014-08-06 11:00     ` Katsumi Yamaoka
@ 2014-08-06 11:14       ` Katsumi Yamaoka
  2014-08-06 16:22         ` Eric Abrahamsen
  2014-08-11 14:07         ` Alan Schmitt
  0 siblings, 2 replies; 9+ messages in thread
From: Katsumi Yamaoka @ 2014-08-06 11:14 UTC (permalink / raw)
  To: ding

On Wed, 06 Aug 2014 20:00:47 +0900, Katsumi Yamaoka wrote:
> On Wed, 06 Aug 2014 16:45:57 +0800, Eric Abrahamsen wrote:
>> Alan Schmitt <alan.schmitt@polytechnique.org> writes:

>>> I gave this patch a try (as it's been applied to the git repo and I've
>>> been able to use it) and I'm seeing an error when messages are refiled
>>> during expiration.

>> Gah, that was my error. The patch should have used functionp and not
>> fboundp. Can someone fix that please?

> `functionp' doesn't fix it, either.  My `nnmail-expiry-target' is
> the symbol `delete', that is the default.  I got:

> (wrong-number-of-arguments delete 1)

I've reverted the change in the Gnus git master and the Emacs trunk.
Please reinstall the feature if you get a good solution.  I have
no idea for it so far, sorry.



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

* Re: [Patch] tell expiry-hook functions where expired messages are going
  2014-08-06 11:14       ` Katsumi Yamaoka
@ 2014-08-06 16:22         ` Eric Abrahamsen
  2014-08-11 14:07         ` Alan Schmitt
  1 sibling, 0 replies; 9+ messages in thread
From: Eric Abrahamsen @ 2014-08-06 16:22 UTC (permalink / raw)
  To: ding

Katsumi Yamaoka <yamaoka@jpl.org> writes:

> On Wed, 06 Aug 2014 20:00:47 +0900, Katsumi Yamaoka wrote:
>> On Wed, 06 Aug 2014 16:45:57 +0800, Eric Abrahamsen wrote:
>>> Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>
>>>> I gave this patch a try (as it's been applied to the git repo and I've
>>>> been able to use it) and I'm seeing an error when messages are refiled
>>>> during expiration.
>
>>> Gah, that was my error. The patch should have used functionp and not
>>> fboundp. Can someone fix that please?
>
>> `functionp' doesn't fix it, either.  My `nnmail-expiry-target' is
>> the symbol `delete', that is the default.  I got:
>
>> (wrong-number-of-arguments delete 1)
>
> I've reverted the change in the Gnus git master and the Emacs trunk.
> Please reinstall the feature if you get a good solution.  I have
> no idea for it so far, sorry.

Thanks, and sorry for the poorly-tested code. I think this would be a
good feature, though, so I'll put a little more thought into it.




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

* Re: [Patch] tell expiry-hook functions where expired messages are going
  2014-08-06 11:14       ` Katsumi Yamaoka
  2014-08-06 16:22         ` Eric Abrahamsen
@ 2014-08-11 14:07         ` Alan Schmitt
  2014-08-14  7:42           ` Eric Abrahamsen
  1 sibling, 1 reply; 9+ messages in thread
From: Alan Schmitt @ 2014-08-11 14:07 UTC (permalink / raw)
  To: ding


[-- Attachment #1.1: Type: text/plain, Size: 673 bytes --]

Hello,

On 2014-08-06 20:14, Katsumi Yamaoka <yamaoka@jpl.org> writes:

> I've reverted the change in the Gnus git master and the Emacs trunk.
> Please reinstall the feature if you get a good solution.  I have
> no idea for it so far, sorry.

Here is an adaptation of Eric's patch that takes these problems into
account. As the target is either a string, the 'delete symbol, or
a function, I test those in turn. In the case it's a function, the
result from the call should be either a string or a 'delete symbol or
a string. In the case it's a 'delete symbole, the hook is called with
'nil' as target.

Eric: I reused your log message, I hope you don't mind.

Best,

Alan


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-Tell-expiry-hook-functions-where-the-message-is-goin.patch --]
[-- Type: text/x-patch, Size: 1710 bytes --]

From d79800074d63ff4242402ff7f7af7b2c9afdc6eb Mon Sep 17 00:00:00 2001
From: Alan Schmitt <alan.schmitt@polytechnique.org>
Date: Mon, 11 Aug 2014 16:01:06 +0200
Subject: [PATCH] Tell expiry-hook functions where the message is going

* lisp/gnus-sum.el (gnus-summary-expire-articles): functions
  registered to the gnus-summary-article-expire-hook should be told
  where the function is going. In particular, the gnus registry might
  want to know.
---
 lisp/gnus-sum.el | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/lisp/gnus-sum.el b/lisp/gnus-sum.el
index c0e099b..d54fe91 100644
--- a/lisp/gnus-sum.el
+++ b/lisp/gnus-sum.el
@@ -10444,13 +10444,18 @@ This will be the case if the article has both been mailed and posted."
 		  (when (and (not (memq article es))
 			     (gnus-data-find article))
 		    (gnus-summary-mark-article article gnus-canceled-mark)
-		    (run-hook-with-args 'gnus-summary-article-expire-hook
-					'delete
-					(gnus-data-header
-					 (assoc article (gnus-data-list nil)))
-					gnus-newsgroup-name
-					nil
-					nil)))))))
+		    (run-hook-with-args
+		     'gnus-summary-article-expire-hook
+		     'delete
+		     (gnus-data-header (assoc article (gnus-data-list nil)))
+		     gnus-newsgroup-name
+		     (cond
+		      ((stringp nnmail-expiry-target) nnmail-expiry-target)
+		      ((eq nnmail-expiry-target 'delete) nil)
+		      (t
+		       (let ((rescall (funcall nnmail-expiry-target gnus-newsgroup-name)))
+			 (if (stringp rescall) rescall nil))))
+		     nil)))))))
 	(gnus-message 6 "Expiring articles...done")))))
 
 (defun gnus-summary-expire-articles-now ()
-- 
2.0.3


[-- Attachment #1.3: Type: text/plain, Size: 44 bytes --]



-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

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

* Re: [Patch] tell expiry-hook functions where expired messages are going
  2014-08-11 14:07         ` Alan Schmitt
@ 2014-08-14  7:42           ` Eric Abrahamsen
  2014-08-14 11:30             ` Katsumi Yamaoka
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Abrahamsen @ 2014-08-14  7:42 UTC (permalink / raw)
  To: ding

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> Hello,
>
> On 2014-08-06 20:14, Katsumi Yamaoka <yamaoka@jpl.org> writes:
>
>> I've reverted the change in the Gnus git master and the Emacs trunk.
>> Please reinstall the feature if you get a good solution.  I have
>> no idea for it so far, sorry.
>
> Here is an adaptation of Eric's patch that takes these problems into
> account. As the target is either a string, the 'delete symbol, or
> a function, I test those in turn. In the case it's a function, the
> result from the call should be either a string or a 'delete symbol or
> a string. In the case it's a 'delete symbole, the hook is called with
> 'nil' as target.
>
> Eric: I reused your log message, I hope you don't mind.

I don't mind at all, of course! This seems like the only solution that's
likely to work. The only sure-fire solution would be to have the expiry
functions return a list of articles they expired, and where they expired
them to, but that's the opposite of what they do now -- they return a
list of article that *weren't* expired.

E

> Best,
>
> Alan
>
> From d79800074d63ff4242402ff7f7af7b2c9afdc6eb Mon Sep 17 00:00:00 2001
> From: Alan Schmitt <alan.schmitt@polytechnique.org>
> Date: Mon, 11 Aug 2014 16:01:06 +0200
> Subject: [PATCH] Tell expiry-hook functions where the message is going
>
> * lisp/gnus-sum.el (gnus-summary-expire-articles): functions
>   registered to the gnus-summary-article-expire-hook should be told
>   where the function is going. In particular, the gnus registry might
>   want to know.
> ---
>  lisp/gnus-sum.el | 19 ++++++++++++-------
>  1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/lisp/gnus-sum.el b/lisp/gnus-sum.el
> index c0e099b..d54fe91 100644
> --- a/lisp/gnus-sum.el
> +++ b/lisp/gnus-sum.el
> @@ -10444,13 +10444,18 @@ This will be the case if the article has both been mailed and posted."
>  		  (when (and (not (memq article es))
>  			     (gnus-data-find article))
>  		    (gnus-summary-mark-article article gnus-canceled-mark)
> -		    (run-hook-with-args 'gnus-summary-article-expire-hook
> -					'delete
> -					(gnus-data-header
> -					 (assoc article (gnus-data-list nil)))
> -					gnus-newsgroup-name
> -					nil
> -					nil)))))))
> +		    (run-hook-with-args
> +		     'gnus-summary-article-expire-hook
> +		     'delete
> +		     (gnus-data-header (assoc article (gnus-data-list nil)))
> +		     gnus-newsgroup-name
> +		     (cond
> +		      ((stringp nnmail-expiry-target) nnmail-expiry-target)
> +		      ((eq nnmail-expiry-target 'delete) nil)
> +		      (t
> +		       (let ((rescall (funcall nnmail-expiry-target gnus-newsgroup-name)))
> +			 (if (stringp rescall) rescall nil))))
> +		     nil)))))))
>  	(gnus-message 6 "Expiring articles...done")))))
>  
>  (defun gnus-summary-expire-articles-now ()
> -- 
> 2.0.3




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

* Re: [Patch] tell expiry-hook functions where expired messages are going
  2014-08-14  7:42           ` Eric Abrahamsen
@ 2014-08-14 11:30             ` Katsumi Yamaoka
  0 siblings, 0 replies; 9+ messages in thread
From: Katsumi Yamaoka @ 2014-08-14 11:30 UTC (permalink / raw)
  To: ding

Eric Abrahamsen <eric@ericabrahamsen.net> wrote:
> Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>> Hello,
>>
>> On 2014-08-06 20:14, Katsumi Yamaoka <yamaoka@jpl.org> writes:
>>
>>> I've reverted the change in the Gnus git master and the Emacs trunk.
>>> Please reinstall the feature if you get a good solution.  I have
>>> no idea for it so far, sorry.
>>
>> Here is an adaptation of Eric's patch that takes these problems into
>> account. As the target is either a string, the 'delete symbol, or
>> a function, I test those in turn. In the case it's a function, the
>> result from the call should be either a string or a 'delete symbol or
>> a string. In the case it's a 'delete symbole, the hook is called with
>> 'nil' as target.
>>
>> Eric: I reused your log message, I hope you don't mind.

>I don't mind at all, of course! This seems like the only solution that's
>likely to work. The only sure-fire solution would be to have the expiry
>functions return a list of articles they expired, and where they expired
>them to, but that's the opposite of what they do now -- they return a
>list of article that *weren't* expired.

Installed.  Thanks!



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

end of thread, other threads:[~2014-08-14 11:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-29  9:04 [Patch] tell expiry-hook functions where expired messages are going Eric Abrahamsen
2014-08-06  8:06 ` Alan Schmitt
2014-08-06  8:45   ` Eric Abrahamsen
2014-08-06 11:00     ` Katsumi Yamaoka
2014-08-06 11:14       ` Katsumi Yamaoka
2014-08-06 16:22         ` Eric Abrahamsen
2014-08-11 14:07         ` Alan Schmitt
2014-08-14  7:42           ` Eric Abrahamsen
2014-08-14 11:30             ` Katsumi Yamaoka

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).