Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* per group value of gnus-summary-thread-gathering-function?
@ 2008-07-22 14:48 Giorgos Keramidas
  2008-07-23 12:52 ` Ted Zlatanov
  0 siblings, 1 reply; 9+ messages in thread
From: Giorgos Keramidas @ 2008-07-22 14:48 UTC (permalink / raw)
  To: info-gnus-english

Is it possible to customize `gnus-summary-thread-gathering-function' on
a per group basis?

I tried explicitly setting the thread gathering function in my ~/.gnus
file with:

  (setq gnus-summary-thread-gathering-function
        'gnus-gather-threads-by-references)

and the I added to the group parameters of a single group the item:

  (gnus-summary-thread-gathering-function . gnus-gather-threads-by-subject)

But this doesn't seem to work as I expected it would work.

The Gnus version I am using is hte bundled Gnus v5.13 snapshot from a
CVS Emacs snapshot checked out at 06-June-2008 (a bit old-ish but I
haven't been tracking Emacs very closely the last month or so).

What is the recommended way of getting different thread gathering logic
for some of the groups?

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

* Re: per group value of gnus-summary-thread-gathering-function?
  2008-07-22 14:48 per group value of gnus-summary-thread-gathering-function? Giorgos Keramidas
@ 2008-07-23 12:52 ` Ted Zlatanov
  2008-07-24 16:37   ` Giorgos Keramidas
  0 siblings, 1 reply; 9+ messages in thread
From: Ted Zlatanov @ 2008-07-23 12:52 UTC (permalink / raw)
  To: info-gnus-english

On Tue, 22 Jul 2008 17:48:29 +0300 Giorgos Keramidas <keramida@ceid.upatras.gr> wrote: 

GK> What is the recommended way of getting different thread gathering
GK> logic for some of the groups?

I don't know if there's a standard way; I do it in the summary entry
hook based on the newsgroup name.

Ted

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

* Re: per group value of gnus-summary-thread-gathering-function?
  2008-07-23 12:52 ` Ted Zlatanov
@ 2008-07-24 16:37   ` Giorgos Keramidas
  2008-07-24 17:53     ` Giorgos Keramidas
  2008-07-24 18:21     ` Ted Zlatanov
  0 siblings, 2 replies; 9+ messages in thread
From: Giorgos Keramidas @ 2008-07-24 16:37 UTC (permalink / raw)
  To: info-gnus-english

On Wed, 23 Jul 2008 07:52:14 -0500, Ted Zlatanov <tzz@lifelogs.com> wrote:
> On Tue, 22 Jul 2008 17:48:29 +0300 Giorgos Keramidas <keramida@ceid.upatras.gr> wrote:
> GK> What is the recommended way of getting different thread gathering
> GK> logic for some of the groups?
>
> I don't know if there's a standard way; I do it in the summary entry
> hook based on the newsgroup name.

Thank you Ted,

That sounds like a good idea.

I thought adding this to the group parameters was a nice way of making
it work, but maybe it's worth trying to patch Gnus and add some sort of
wrapper function that dispatches on the group name, i.e.:

  (setq-default gnus-summary-thread-gathering-function
                'keramida-gnus-gather-threads)

Then I could add regexp matches to one or two new variables like:

  (defvar keramida-gnus-thread-function-by-group-map
    '(("mail\\.foo\\.bar" . gnus-gather-threads-by-subject)
      ("mail\\..*" . gnus-gather-threads-by-references)
      (t . gnus-gather-threads-by-references))
    "List of (regexp . function) pairs to select a thread-gathering function.")

Then with `gnus-summary-exit-hook' I can restore the thread gathering
function to a `default' value.  I think I'll give this a try.  If it
seems to work nicely, I will post what I wrote here when I've tested it
a bit.

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

* Re: per group value of gnus-summary-thread-gathering-function?
  2008-07-24 16:37   ` Giorgos Keramidas
@ 2008-07-24 17:53     ` Giorgos Keramidas
  2008-07-28 14:54       ` Johan Bockgård
  2008-07-24 18:21     ` Ted Zlatanov
  1 sibling, 1 reply; 9+ messages in thread
From: Giorgos Keramidas @ 2008-07-24 17:53 UTC (permalink / raw)
  To: info-gnus-english

On Thu, 24 Jul 2008 19:37:49 +0300, Giorgos Keramidas <keramida@ceid.upatras.gr> wrote:
> On Wed, 23 Jul 2008 07:52:14 -0500, Ted Zlatanov <tzz@lifelogs.com> wrote:
>> On Tue, 22 Jul 2008 17:48:29 +0300 Giorgos Keramidas <keramida@ceid.upatras.gr> wrote:
>> GK> What is the recommended way of getting different thread gathering
>> GK> logic for some of the groups?
>>
>> I don't know if there's a standard way; I do it in the summary entry
>> hook based on the newsgroup name.
>
> Thank you Ted,
> [...]
> maybe it's worth trying to patch Gnus and add some sort of wrapper
> function that dispatches on the group name, i.e.:
>
>   (setq-default gnus-summary-thread-gathering-function
>                 'keramida-gnus-gather-threads)

Great...  Apparently, with a bit of Lisp, this works fine!

I added this to my `~/.gnus' file now:

  ;;; Threading customizations.

  (defun keramida-gnus-gather-threads-default (threads)
    "The default thread-gathering function for Gnus groups."
    (gnus-gather-threads-by-references threads))

  (defvar keramida-gnus-group-thread-function-map
    '(("mail\\.freebsd\\.bugs" . gnus-gather-threads-by-subject))
    "Custom per-group mapping of Gnus group names to thread gathering
  functions.")

  (defun keramida-gnus-gather-threads (threads)
    "Dispatch function that matches Gnus group names to thread
  gathering functions by looking up the group name in the
  `keramida-gnus-group-thread-function-map'."
    (let ((group gnus-newsgroup-name)
          (gather-function (or (and (fboundp 'keramida-gnus-gather-threads-default)
                                    (function keramida-gnus-gather-threads-default))
                               (and (fboundp 'gnus-gather-threads-by-references)
                                    (function gnus-gather-threads-by-references)))))
      (let ((match-function nil))
        (if (and group (boundp 'keramida-gnus-group-thread-function-map))
            (dolist (pair keramida-gnus-group-thread-function-map)
              (message "pair is %s" pair)
              (if (not match-function)
                  (let ((pattern (car pair))
                        (func (cdr pair)))
                    (if (and (string-match pattern group)
                             (fboundp func))
                        (setq match-function func))))))
        (if match-function
            (setq gather-function match-function)))
      (funcall gather-function threads)))

  ;; Use my own thread-gathering function.
  (setq gnus-summary-thread-gathering-function
        'keramida-gnus-gather-threads)

This seems to have worked great so far.  All my groups gather threads by
looking at references, and "mail.freebsd.bugs" gathers threads by looking
at the email subject.

It's probably not as polished as it could be, and it will iterate over the
entire list of (pattern . function) pairs, even if it has already found a
match, but I can live with that for now.

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

* Re: per group value of gnus-summary-thread-gathering-function?
  2008-07-24 16:37   ` Giorgos Keramidas
  2008-07-24 17:53     ` Giorgos Keramidas
@ 2008-07-24 18:21     ` Ted Zlatanov
  2008-07-24 19:25       ` Giorgos Keramidas
  1 sibling, 1 reply; 9+ messages in thread
From: Ted Zlatanov @ 2008-07-24 18:21 UTC (permalink / raw)
  To: info-gnus-english

On Thu, 24 Jul 2008 19:37:49 +0300 Giorgos Keramidas <keramida@ceid.upatras.gr> wrote: 

GK> On Wed, 23 Jul 2008 07:52:14 -0500, Ted Zlatanov <tzz@lifelogs.com> wrote:
>> On Tue, 22 Jul 2008 17:48:29 +0300 Giorgos Keramidas <keramida@ceid.upatras.gr> wrote:
GK> What is the recommended way of getting different thread gathering
GK> logic for some of the groups?
>> 
>> I don't know if there's a standard way; I do it in the summary entry
>> hook based on the newsgroup name.

GK> Thank you Ted,

GK> That sounds like a good idea.

GK> I thought adding this to the group parameters was a nice way of making
GK> it work, but maybe it's worth trying to patch Gnus and add some sort of
GK> wrapper function that dispatches on the group name, i.e.:

GK>   (setq-default gnus-summary-thread-gathering-function
GK>                 'keramida-gnus-gather-threads)

GK> Then I could add regexp matches to one or two new variables like:

GK>   (defvar keramida-gnus-thread-function-by-group-map
GK>     '(("mail\\.foo\\.bar" . gnus-gather-threads-by-subject)
GK>       ("mail\\..*" . gnus-gather-threads-by-references)
GK>       (t . gnus-gather-threads-by-references))
GK>     "List of (regexp . function) pairs to select a thread-gathering function.")

GK> Then with `gnus-summary-exit-hook' I can restore the thread gathering
GK> function to a `default' value.  I think I'll give this a try.  If it
GK> seems to work nicely, I will post what I wrote here when I've tested it
GK> a bit.

I think what you and others want is to modify gnus-posting-styles so it
allows a symbol instead of just a static definition.  In other words,
instead of

((".*"
  (signature-file "~/.signature")
  (name "Ted Zlatanov")
  (organization "Теодор Златанов @ Cienfuegos")))

it could be

((".*"
  ('gnus-summary-thread-gathering-function 'gnus-gather-threads-by-references)
  (signature-file "~/.signature")
  (name "Ted Zlatanov")
  (organization "Теодор Златанов @ Cienfuegos")))

Am I understanding you correctly?  I don't know how hard this change is,
if it's the right thing.

Ted

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

* Re: per group value of gnus-summary-thread-gathering-function?
  2008-07-24 18:21     ` Ted Zlatanov
@ 2008-07-24 19:25       ` Giorgos Keramidas
  0 siblings, 0 replies; 9+ messages in thread
From: Giorgos Keramidas @ 2008-07-24 19:25 UTC (permalink / raw)
  To: info-gnus-english

On Thu, 24 Jul 2008 13:21:05 -0500, Ted Zlatanov <tzz@lifelogs.com> wrote:
> On Thu, 24 Jul 2008 19:37:49 +0300 Giorgos Keramidas <keramida@ceid.upatras.gr> wrote:
> GK> Then with `gnus-summary-exit-hook' I can restore the thread
> GK> gathering function to a `default' value.  I think I'll give this a
> GK> try.  If it seems to work nicely, I will post what I wrote here
> GK> when I've tested it a bit.
>
> I think what you and others want is to modify gnus-posting-styles so it
> allows a symbol instead of just a static definition.  In other words,
> instead of
>
> ((".*"
>   (signature-file "~/.signature")
>   (name "Ted Zlatanov")
>   (organization "Теодор Златанов @ Cienfuegos")))
>
> it could be
>
> ((".*"
>   ('gnus-summary-thread-gathering-function 'gnus-gather-threads-by-references)
>   (signature-file "~/.signature")
>   (name "Ted Zlatanov")
>   (organization "Теодор Златанов @ Cienfuegos")))
>
> Am I understanding you correctly?  I don't know how hard this change
> is, if it's the right thing.

That could probably work too :)

I am not sure if it's the Right Thing, so I'll keep using the custom
thread-gathering function for now, unless some more experienced Gnus
user or developer wants to chime in with a more appropriate way of
achieving the same.

It was pretty easy to write the custom thread-gathering function.  I am
not sure I know enough about the internals of Gnus to modify the posting
style parsing code though :(

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

* Re: per group value of gnus-summary-thread-gathering-function?
  2008-07-24 17:53     ` Giorgos Keramidas
@ 2008-07-28 14:54       ` Johan Bockgård
  2008-07-29  2:34         ` Giorgos Keramidas
  0 siblings, 1 reply; 9+ messages in thread
From: Johan Bockgård @ 2008-07-28 14:54 UTC (permalink / raw)
  To: info-gnus-english

Giorgos Keramidas <keramida@ceid.upatras.gr> writes:

>             (dolist (pair keramida-gnus-group-thread-function-map)
>               (message "pair is %s" pair)
>               (if (not match-function)
>                   (let ((pattern (car pair))
>                         (func (cdr pair)))
>                     (if (and (string-match pattern group)
>                              (fboundp func))
>                         (setq match-function func))))))

    (assoc-default group keramida-gnus-group-thread-function-map
                   'string-match)

-- 
Johan Bockgård

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

* Re: per group value of gnus-summary-thread-gathering-function?
  2008-07-28 14:54       ` Johan Bockgård
@ 2008-07-29  2:34         ` Giorgos Keramidas
  2008-07-29  3:41           ` Giorgos Keramidas
  0 siblings, 1 reply; 9+ messages in thread
From: Giorgos Keramidas @ 2008-07-29  2:34 UTC (permalink / raw)
  To: info-gnus-english

On Mon, 28 Jul 2008 16:54:19 +0200, bojohan+news@dd.chalmers.se (Johan Bockgård) wrote:
> Giorgos Keramidas <keramida@ceid.upatras.gr> writes:
>
>>             (dolist (pair keramida-gnus-group-thread-function-map)
>>               (message "pair is %s" pair)
>>               (if (not match-function)
>>                   (let ((pattern (car pair))
>>                         (func (cdr pair)))
>>                     (if (and (string-match pattern group)
>>                              (fboundp func))
>>                         (setq match-function func))))))
>
>     (assoc-default group keramida-gnus-group-thread-function-map
>                    'string-match)

Thank you! :)

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

* Re: per group value of gnus-summary-thread-gathering-function?
  2008-07-29  2:34         ` Giorgos Keramidas
@ 2008-07-29  3:41           ` Giorgos Keramidas
  0 siblings, 0 replies; 9+ messages in thread
From: Giorgos Keramidas @ 2008-07-29  3:41 UTC (permalink / raw)
  To: info-gnus-english

On Tue, 29 Jul 2008 05:34:29 +0300, Giorgos Keramidas <keramida@ceid.upatras.gr> wrote:
> On Mon, 28 Jul 2008 16:54:19 +0200, bojohan+news@dd.chalmers.se (Johan Bockgård) wrote:
>> Giorgos Keramidas <keramida@ceid.upatras.gr> writes:
>>
>>>             (dolist (pair keramida-gnus-group-thread-function-map)
>>>               (message "pair is %s" pair)
>>>               (if (not match-function)
>>>                   (let ((pattern (car pair))
>>>                         (func (cdr pair)))
>>>                     (if (and (string-match pattern group)
>>>                              (fboundp func))
>>>                         (setq match-function func))))))
>>
>>     (assoc-default group keramida-gnus-group-thread-function-map
>>                    'string-match)
>
> Thank you! :)

After a bit of testing, the new threading function I'm using is:

(defun keramida-gnus-gather-threads (threads)
  "Dispatch function that matches Gnus group names to thread
gathering functions by looking up the group name in the
`keramida-gnus-group-thread-function-map'."
  (let ((group gnus-newsgroup-name)
        (gather-function (or (and (fboundp 'keramida-gnus-gather-threads-default)
                                    (function keramida-gnus-gather-threads-default))
                               (and (fboundp 'gnus-gather-threads-by-references)
                                    (function gnus-gather-threads-by-references)))))
    (let ((match-function (and group
                               (boundp 'keramida-gnus-group-thread-function-map)
                               (assoc-default group keramida-gnus-group-thread-function-map
                                              'string-match))))
      (funcall (or match-function gather-function) threads))))

This seems more 'Lispy' than the previous dolist-based version :)

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

end of thread, other threads:[~2008-07-29  3:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-22 14:48 per group value of gnus-summary-thread-gathering-function? Giorgos Keramidas
2008-07-23 12:52 ` Ted Zlatanov
2008-07-24 16:37   ` Giorgos Keramidas
2008-07-24 17:53     ` Giorgos Keramidas
2008-07-28 14:54       ` Johan Bockgård
2008-07-29  2:34         ` Giorgos Keramidas
2008-07-29  3:41           ` Giorgos Keramidas
2008-07-24 18:21     ` Ted Zlatanov
2008-07-24 19:25       ` Giorgos Keramidas

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