From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/68577 Path: news.gmane.org!not-for-mail From: David Abrahams Newsgroups: gmane.emacs.gnus.general Subject: Re: Shorter/customized group names? Date: Fri, 29 May 2009 10:51:57 -0400 Message-ID: References: <87zlcydxa0.fsf@randomsample.de> <877i017ec4.fsf@randomsample.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1243608762 8359 80.91.229.12 (29 May 2009 14:52:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 29 May 2009 14:52:42 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M17008@lists.math.uh.edu Fri May 29 16:52:39 2009 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.50) id 1MA3Rl-0004HC-LE for ding-account@gmane.org; Fri, 29 May 2009 16:52:37 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1MA3R4-00024X-PA; Fri, 29 May 2009 09:51:54 -0500 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1MA3R1-00024G-U8 for ding@lists.math.uh.edu; Fri, 29 May 2009 09:51:51 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtp (Exim 4.69) (envelope-from ) id 1MA3Qy-0000my-Jd for ding@lists.math.uh.edu; Fri, 29 May 2009 09:51:51 -0500 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by quimby.gnus.org with esmtp (Exim 3.36 #1 (Debian)) id 1MA3RS-00054I-00 for ; Fri, 29 May 2009 16:52:18 +0200 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1MA3Qv-00040R-Uu for ding@gnus.org; Fri, 29 May 2009 14:51:45 +0000 Original-Received: from 207-172-223-249.c3-0.smr-ubr3.sbo-smr.ma.static.cable.rcn.com ([207.172.223.249]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 29 May 2009 14:51:45 +0000 Original-Received: from dave by 207-172-223-249.c3-0.smr-ubr3.sbo-smr.ma.static.cable.rcn.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 29 May 2009 14:51:45 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 92 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 207-172-223-249.c3-0.smr-ubr3.sbo-smr.ma.static.cable.rcn.com User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.93 (darwin) Cancel-Lock: sha1:LGW1tLzMRqmemBm4uQPt8DM5dCE= X-Spam-Score: -3.5 (---) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:68577 Archived-At: on Thu May 28 2009, David Engster wrote: > David Abrahams writes: >> on Wed May 27 2009, David Engster 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