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?
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
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.
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.
GK> On Wed, 23 Jul 2008 07:52:14 -0500, Ted Zlatanov <t...@lifelogs.com> wrote:
>> On Tue, 22 Jul 2008 17:48:29 +0300 Giorgos Keramidas <kera...@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
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 :(
> (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
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 :)