Commits

yagnesh raghava yakkala committed d3abeeb

* init-gnus.el: eye candy for group display

Comments (0)

Files changed (1)

       (5 (message "Gnus timed out.") (debug))
     ad-do-it))
 
-;;; group mode
+;;; group buffer
 ;;; --------------------------------------------------------
 (defun gnus-topic-select-group (&optional all)
   "Select this newsgroup.
 
 (setq gnus-group-line-format "%M\%S\%p\%5y: %G\n")
 
-
-;;; summary mode
+;;; http://www.randomsample.de/dru5/node/64
+;; 0: gmane.emacs.gnus.user
+;; 0:   .  .  .announce
+;; 0:   .  .w3m
+;; 0:   .  .devel
+;; 0:   .  .bugs
+;; 0:   .mail.getmail.announce
+;; 0:   .  .mairix.user
+;; 0:   .linux.debian.user.security.announce
+;; 0: de.comm.software.gnus
+(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)
+
+;;; summary buffer
 ;;; --------------------------------------------------------
 
 (setq-default
 
 (setq gnus-summary-gather-subject-limit 'fuzzy)
 
-;;; article mode
+;;; article buffer
 ;;; --------------------------------------------------------
 (require 'gnus-cite)
 
 (setq gnus-visible-headers
       "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:\\|^User-Agent:\\|^X-Mailer:\\|^X-Newsreader:")
 
-;;; layout
+;;; Gnus layout
 ;;; --------------------------------------------------
 ;; (gnus-add-configuration '(article (vertical 1.0 (summary .35 point) (article 1.0))))
 
 ;;; --------------------------------------------------
 (gnus-demon-add-handler 'gnus-demon-scan-news 15 t)
 
-;;; spam
+
+;;; Spam related
 ;;; --------------------------------------------------
 (spam-initialize)
 (setq gnus-spam-process-newsgroups
 
 
 ;;; url
-
 (defun gnus-summary-guess-article-url ()
   "guess url of the article"
   (interactive)