From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/68581 Path: news.gmane.org!not-for-mail From: David Engster Newsgroups: gmane.emacs.gnus.general Subject: Re: Shorter/customized group names? Date: Sat, 30 May 2009 16:46:06 +0200 Message-ID: <87vdnimyxd.fsf@randomsample.de> 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 1243696628 12721 80.91.229.12 (30 May 2009 15:17:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 30 May 2009 15:17:08 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M17012@lists.math.uh.edu Sat May 30 17:17:03 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 1MAQIx-0008KQ-LE for ding-account@gmane.org; Sat, 30 May 2009 17:17:03 +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 1MAQI8-00089H-RL; Sat, 30 May 2009 10:16:12 -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 1MAPpE-00082C-Qv for ding@lists.math.uh.edu; Sat, 30 May 2009 09:46:20 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtp (Exim 4.69) (envelope-from ) id 1MAPp8-0005Cw-I9 for ding@lists.math.uh.edu; Sat, 30 May 2009 09:46:20 -0500 Original-Received: from m61s02.vlinux.de ([83.151.21.164]) by quimby.gnus.org with esmtp (Exim 3.36 #1 (Debian)) id 1MAPpc-0004ow-00 for ; Sat, 30 May 2009 16:46:44 +0200 Original-Received: from dslc-082-082-177-108.pools.arcor-ip.net ([82.82.177.108] helo=void) by m61s02.vlinux.de with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1MAPp6-00087Q-Aj for ding@gnus.org; Sat, 30 May 2009 16:46:12 +0200 In-Reply-To: (David Abrahams's message of "Fri, 29 May 2009 18:31:33 -0400") User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.93 (gnu/linux) Mail-Copies-To: never Mail-Followup-To: ding@gnus.org X-Spam-Score: -2.6 (--) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:68581 Archived-At: David Abrahams writes: > on Fri May 29 2009, David Abrahams wrote: > >> on Fri May 29 2009, David Engster wrote: >> >>> David Abrahams writes: >>>> 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. >>> >>> It's a hack, for sure. Maybe the reason it works pretty well for me is >>> because I'm using topic mode? >> >> I'm using topic mode too. > > A possibly-less-hacky approach might be to "after" advise the functions > that operate on the *Group* buffer to postprocess those strings. Still, > I really think this (or the tools to support it) should be a built-in > feature. I couldn't exactly reproduce the problems you had, but I also noticed some inconsistencies when the Group buffer is rebuild only partially (e.g. when opening a topic). I agree that doing this as a postprocess is the best way to go about this. Since there are more than enough hooks we don't even need to advise anything. :-) 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. --8<---------------cut here---------------start------------->8--- (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) --8<---------------cut here---------------end--------------->8--- 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. -David