From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/68607 Path: news.gmane.org!not-for-mail From: David Abrahams Newsgroups: gmane.emacs.gnus.general Subject: Re: Shorter/customized group names? Date: Tue, 09 Jun 2009 15:22:19 -0400 Message-ID: References: <87zlcydxa0.fsf@randomsample.de> <877i017ec4.fsf@randomsample.de> <87vdnimyxd.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 1244575343 1223 80.91.229.12 (9 Jun 2009 19:22:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 9 Jun 2009 19:22:23 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M17036@lists.math.uh.edu Tue Jun 09 21:22:20 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 1ME6tl-0001Aa-Ha for ding-account@gmane.org; Tue, 09 Jun 2009 21:22:17 +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 1ME6tg-0001RY-DM; Tue, 09 Jun 2009 14:22:12 -0500 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1ME6tf-0001RE-4G for ding@lists.math.uh.edu; Tue, 09 Jun 2009 14:22:11 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtp (Exim 4.69) (envelope-from ) id 1ME6tZ-0007WA-8f for ding@lists.math.uh.edu; Tue, 09 Jun 2009 14:22:11 -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 1ME6u3-0007SS-00 for ; Tue, 09 Jun 2009 21:22:35 +0200 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1ME6tV-0002o5-MM for ding@gnus.org; Tue, 09 Jun 2009 19:22:01 +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 ; Tue, 09 Jun 2009 19:22:01 +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 ; Tue, 09 Jun 2009 19:22:01 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 51 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.94 (darwin) Cancel-Lock: sha1:PG04GM2VnB0zLpA6Dt7QLe9oVbk= X-Spam-Score: -3.6 (---) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:68607 Archived-At: on Sat May 30 2009, David Engster wrote: > So here's yet another version, based on your already modified one. It > also uses an internal feature: the complete group name is saved in the > text properties at the beginning of each group line. Since many internal > Gnus functions use these, this isn't likely to change. > > (defun DE-collapse-group-names () > (save-excursion > (let (previous-group current-group common-prefix > common-dot-count prefix suffix) > (goto-char (point-min)) > (while (not (eobp)) > (when (setq current-group > (get-text-property (point) 'gnus-group)) > (setq current-group (symbol-name current-group)) > (when (string-match "\\(.+\\):\\(.+\\)" current-group) > (setq current-group (match-string 2 current-group))) > (setq common-prefix (substring current-group 0 > (mismatch previous-group 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)) > previous-group current-group) > (unless (zerop (length prefix)) > (when (search-forward current-group (point-at-eol) t) > (let ((props (text-properties-at (1- (point))))) > (replace-match (apply 'propertize (concat prefix suffix) > props)))))) > (forward-line 1))))) > > (add-hook 'gnus-group-prepare-hook 'DE-collapse-group-names) > (add-hook 'gnus-group-update-group-hook 'DE-collapse-group-names) > > This code assumes that you use "%G" in your group line format. > > I think you can even omit the last hook if you don't use a three pane > buffer configuration. Ah, but I do! But this is fantastic; it really works. Thank you for all your help on this one! -- Dave Abrahams BoostPro Computing http://www.boostpro.com