Gnus development mailing list
 help / color / mirror / Atom feed
* Modify hook in group parameters?
@ 2009-10-13 15:30 Steinar Bang
  2009-10-13 17:57 ` Reiner Steib
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Steinar Bang @ 2009-10-13 15:30 UTC (permalink / raw)
  To: ding

Is it possible to modify a hook in group parameters?

Specifically, I would like to do
 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
for a limited set of nnimap groups (two, actually).

But I don't want gnus-summary-expire-articles done on exit for any other
groups, because that could potentially take too much time.

Is there any other way of accomplish this?

Thanx!


- Steinar




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

* Re: Modify hook in group parameters?
  2009-10-13 15:30 Modify hook in group parameters? Steinar Bang
@ 2009-10-13 17:57 ` Reiner Steib
  2009-10-13 19:23 ` Ted Zlatanov
  2009-10-13 22:47 ` Katsumi Yamaoka
  2 siblings, 0 replies; 6+ messages in thread
From: Reiner Steib @ 2009-10-13 17:57 UTC (permalink / raw)
  To: ding

On Tue, Oct 13 2009, Steinar Bang wrote:

> Is it possible to modify a hook in group parameters?

AFAICS: no.

> Specifically, I would like to do
>  (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
> for a limited set of nnimap groups (two, actually).

(add-hook 'gnus-summary-prepare-exit-hook
	  (lambda ()
	    (when (string-match "foo\\|bar" gnus-newsgroup-name)
	      (gnus-summary-expire-articles))))

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/




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

* Re: Modify hook in group parameters?
  2009-10-13 15:30 Modify hook in group parameters? Steinar Bang
  2009-10-13 17:57 ` Reiner Steib
@ 2009-10-13 19:23 ` Ted Zlatanov
  2009-10-13 22:47 ` Katsumi Yamaoka
  2 siblings, 0 replies; 6+ messages in thread
From: Ted Zlatanov @ 2009-10-13 19:23 UTC (permalink / raw)
  To: ding

On Tue, 13 Oct 2009 17:30:10 +0200 Steinar Bang <sb@dod.no> wrote: 

SB> Is it possible to modify a hook in group parameters?
SB> Specifically, I would like to do
SB>  (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
SB> for a limited set of nnimap groups (two, actually).

SB> But I don't want gnus-summary-expire-articles done on exit for any other
SB> groups, because that could potentially take too much time.

SB> Is there any other way of accomplish this?

Not currently.  I do this in a global hook, checking gnus-newsgroup-name
to see if I'm in the right group.

I think it would make sense to have

(add-gnus-conditional-hook 'test-function-or-string 'hook-name 'function-to-run)

to do what you're looking for.  I'd use it :)

Ted




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

* Re: Modify hook in group parameters?
  2009-10-13 15:30 Modify hook in group parameters? Steinar Bang
  2009-10-13 17:57 ` Reiner Steib
  2009-10-13 19:23 ` Ted Zlatanov
@ 2009-10-13 22:47 ` Katsumi Yamaoka
  2009-10-14 11:18   ` Steinar Bang
  2 siblings, 1 reply; 6+ messages in thread
From: Katsumi Yamaoka @ 2009-10-13 22:47 UTC (permalink / raw)
  To: ding

>>>>> Steinar Bang wrote:
> Is it possible to modify a hook in group parameters?

> Specifically, I would like to do
>  (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
> for a limited set of nnimap groups (two, actually).

> But I don't want gnus-summary-expire-articles done on exit for any other
> groups, because that could potentially take too much time.

> Is there any other way of accomplish this?

I don't know why it takes too much time though.  This will work:

(setq gnus-summary-prepare-exit-hook nil)
(add-to-list 'gnus-parameters
	     '("\\`nnimap[+:]" (gnus-summary-prepare-exit-hook
				'(gnus-summary-expire-articles t))))

This makes `gnus-summary-prepare-exit-hook' buffer-local in
the summary buffer for only the nnimap groups.  `t' there means
to run the global part of the hook, so you can use `add-hook' as
usual to add functions that run for any groups.



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

* Re: Modify hook in group parameters?
  2009-10-13 22:47 ` Katsumi Yamaoka
@ 2009-10-14 11:18   ` Steinar Bang
  2009-10-14 22:44     ` Katsumi Yamaoka
  0 siblings, 1 reply; 6+ messages in thread
From: Steinar Bang @ 2009-10-14 11:18 UTC (permalink / raw)
  To: ding

>>>>> Katsumi Yamaoka <yamaoka@jpl.org>:

> I don't know why it takes too much time though.

The check in is from May 2003, and one of the machines I was running on,
at that point in time, was the PII 233MHz machine with 128MB of RAM,
that is the same machine that hosts the imap server (a 1996 vintage DEC
PC 5000... still running... still hosting the imap server).

Another Gnus machine was a 1997 vintage DEC HiNote Ultra II, with 48MB
RAM.

Anyway, the machines used may have had something to do with the speed
issues. :-)

> This will work:

> (setq gnus-summary-prepare-exit-hook nil)
> (add-to-list 'gnus-parameters
> 	     '("\\`nnimap[+:]" (gnus-summary-prepare-exit-hook
> 				'(gnus-summary-expire-articles t))))

Hm... what does the backslash-quoted backquote at the start of the
rexexp mean?  My existing gnus-parameters entries all start with a "^"
(start of line).

Here are my existing gnus-parameters setting:
(setq gnus-parameters '(("^nntp\\+news\\.gmane\\."
			 (spam-process
			  ((spam spam-use-gmane))))
                        ("^no\\."
                         (mm-coding-system-priorities
                          '(iso-8859-1)))))

> This makes `gnus-summary-prepare-exit-hook' buffer-local in
> the summary buffer for only the nnimap groups.  `t' there means
> to run the global part of the hook, so you can use `add-hook' as
> usual to add functions that run for any groups.

Ah, interesting, and quite elegant.

So if I leave my current
 (remove-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
in place in your example, instead of setting it to nil, that should also
work?




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

* Re: Modify hook in group parameters?
  2009-10-14 11:18   ` Steinar Bang
@ 2009-10-14 22:44     ` Katsumi Yamaoka
  0 siblings, 0 replies; 6+ messages in thread
From: Katsumi Yamaoka @ 2009-10-14 22:44 UTC (permalink / raw)
  To: ding

>>>>> Steinar Bang wrote:
>>>>>> Katsumi Yamaoka <yamaoka@jpl.org>:

>> I don't know why it takes too much time though.

> The check in is from May 2003, and one of the machines I was running on,
> at that point in time, was the PII 233MHz machine with 128MB of RAM,
> that is the same machine that hosts the imap server (a 1996 vintage DEC
> PC 5000... still running... still hosting the imap server).

> Another Gnus machine was a 1997 vintage DEC HiNote Ultra II, with 48MB
> RAM.

> Anyway, the machines used may have had something to do with the speed
> issues. :-)

I see.  I recalled the machine I'd been using till the year before
last. :)

>> This will work:

>> (setq gnus-summary-prepare-exit-hook nil)
>> (add-to-list 'gnus-parameters
>> 	     '("\\`nnimap[+:]" (gnus-summary-prepare-exit-hook
>> 				'(gnus-summary-expire-articles t))))

> Hm... what does the backslash-quoted backquote at the start of the
> rexexp mean?  My existing gnus-parameters entries all start with a "^"
> (start of line).

Both "\\`" and "^" match the beginning of a string object (and
the beginning of contents in an Emacs buffer), while "^" also
matches the beginning of a line (i.e., the next position of the
newline character) in a string or a buffer.  Anyway you can use
either in that case.  I usually use "\\`" when the matching target
is a string (a newsgroup name in that case).
Cf. (info "(emacs)Regexp")

[...]

> So if I leave my current
>  (remove-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
> in place in your example, instead of setting it to nil, that should also
> work?

It should be ok.



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

end of thread, other threads:[~2009-10-14 22:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-13 15:30 Modify hook in group parameters? Steinar Bang
2009-10-13 17:57 ` Reiner Steib
2009-10-13 19:23 ` Ted Zlatanov
2009-10-13 22:47 ` Katsumi Yamaoka
2009-10-14 11:18   ` Steinar Bang
2009-10-14 22:44     ` 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).