Gnus development mailing list
 help / color / mirror / Atom feed
From: David Abrahams <dave@boostpro.com>
To: ding@gnus.org
Subject: Re: Shorter/customized group names?
Date: Fri, 29 May 2009 10:51:57 -0400	[thread overview]
Message-ID: <m2zlcwner6.fsf@boostpro.com> (raw)
In-Reply-To: <877i017ec4.fsf@randomsample.de>


on Thu May 28 2009, David Engster <deng-AT-randomsample.de> wrote:

> David Abrahams <dave@boostpro.com> writes:
>> on Wed May 27 2009, David Engster <deng-AT-randomsample.de> wrote:
>>> Just a guess, but using %G instead of %g in gnus-group-line-format will
>>> probably do what you want.
>>
>> Well, thanks; it's definitely a start.  I'd like to do better,
>> though. I guess I can use a ~(...) clause and hand-code it, but I
>> think there are some things I wouldn't be able to do very easily that
>> way.  For example, I'm currently seeing:
>>
>>        233 | gmane.comp.lib.boost.announce
>>       3251 | gmane.comp.lib.boost.asio.user
>
> [...]
>
>> which could be made as simple as:
>>
>>        233 | gmane.comp.lib.boost.announce
>>       3251 |  .boost.asio.user
>
> [...]
>
> Well, there's still the possibility to use collapsed group names (see %c
> in gnus-group-line-format), but I never used that because then *all*
> groups are collapsed; I like your idea much better. You can do that by
> using a user-defined function. Put the following into your .gnus:
>
> (defvar DE-format-previous-regexp nil)
> (defvar DE-format-collapse-level 2)
>
> (defun gnus-user-format-function-A (arg)
>   (let ((group gnus-tmp-qualified-group))
>     (if (eq (car gnus-tmp-method) 'nntp)
> 	(if (and DE-format-previous-regexp
> 		 (string-match DE-format-previous-regexp group))
> 	    (concat " ." (match-string 1 group))
> 	  (setq DE-format-previous-regexp 
> 		(if (string-match (format "\\(\\([a-z]+\\.\\)\\{%d\\}\\).+"
> 					  DE-format-collapse-level)
> 				  group)
> 		    (concat (regexp-quote (match-string 1 group))
> 			    "\\(.+\\)")
> 		  nil))
> 	  group)
>       (setq DE-format-previous-regexp nil)
>       group)))
>
>
> Now just use %uA instead of %G in gnus-group-line-format. You probably
> want to use a collapse level of "3" for your example above. Beware that
> this may be buggy, but it works for me so far.

Hey, thanks!  

This is pretty cool, but it's also got a few problems.  It relies on
implementation details of Gnus like the order in which groups get
formatted, that Gnus always formats *all* the groups (it doesn't) and on
some secret variables.  Also, I'm not sure what resets
DE-format-previous-regexp back to nil other than encountering a non-nntp
group.  Since I'd like this to work for non-nntp groups too, I don't
think that trick is going to work for me.

Here's what I've got so far as a tweak to the above, but since it relies
on the same assumptions, it doesn't quite work as well as it should.
This seems like the sort of thing for which we would need explicit
support from Gnus if it's not going to break with each release.  Or am I
missing something?

(require 'cl-seq)
(defvar DE-format-previous-group-name nil)

(defun gnus-user-format-function-A (arg)
  (let* ((current-group gnus-tmp-qualified-group)
         (common-prefix (substring current-group 0 (mismatch DE-format-previous-group-name current-group)))
         (common-dot-count (count ?. common-prefix))
         (prefix (mapconcat (lambda (x) x) (make-list common-dot-count "  .") ""))
         (suffix 
          (and (string-match
                      (format "\\([^.]*[.]\\)\\{%d\\}\\(.+\\)" common-dot-count) current-group)
               (match-string 2 current-group)))
         )
    (setq DE-format-previous-group-name current-group)
    (concat prefix suffix)))


-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com




  reply	other threads:[~2009-05-29 14:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-27 20:02 David Abrahams
2009-05-27 21:57 ` David Engster
2009-05-28  4:42   ` David Abrahams
2009-05-28  9:43     ` David Engster
2009-05-29 14:51       ` David Abrahams [this message]
2009-05-29 16:50         ` David Engster
2009-05-29 18:02           ` David Abrahams
2009-05-29 22:31             ` David Abrahams
2009-05-30 14:46               ` David Engster
2009-06-09 19:22                 ` David Abrahams
2009-07-08 19:17     ` Ted Zlatanov

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=m2zlcwner6.fsf@boostpro.com \
    --to=dave@boostpro.com \
    --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).