Gnus development mailing list
 help / color / mirror / Atom feed
* [gnu.emacs.gnus] Re: is there a way to have a thread tree like in tin?
@ 2000-06-15  7:17 Timo Lilja
  0 siblings, 0 replies; only message in thread
From: Timo Lilja @ 2000-06-15  7:17 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1679 bytes --]


I posted this to gnu.emacs.gnus and somebody suggested that I should
post it to this mailing list: 

rjs@lloke.dna.fi (Riku Saikkonen) writes:

>I'll try to implement the thread tree, if I get the time. We'll see...
>Don't hold your breath.

Okay, here is a patch for gnus-sum.el that me and Riku wrote.
(gnus-sum.el is located in /usr/share/emacs/site-lisp/gnus/gnus-sum.el
atleast in my Debian system.) Copy the original gnus-sum.el to a local
directory, say ~/elisp and patch (1) it.

Following elisp-spells have to be added into your local Gnus
configuration file (~/.gnus):

 (load "~/elisp/gnus-sum.el") 
 (setq gnus-summary-line-format "%U%R%z%(%[%4L: %-20,20f%]%) %B%s\n")

 ;; Dummy roots to threads
 (setq gnus-summary-make-false-root 'dummy)
 (setq gnus-summary-dummy-line-format 
       "   %(:                          :%) %-10S\n")

It's not necessary to use dummy thread roots but I think they make the
the summary buffer easier to read.

After restarting Gnus the Summary buffer should look something like
this:

   :                          : Re: is there a way to have a thread t$
   [  15: Miernik             ] +->
   [  16: Riku Saikkonen      ] | \->
   [  35: Miernik             ] \->
   [  49: Nuutti Kotivuori    ]   \->


You can customize this thread tree display somewhat. There are some
variables defined in the patched gnus-sum.el. 

What the patch does is that it adds a new format specification
character B in the accepted format specifications in
'gnus-summary-line-format' variable. 

Note that I've tried this patch with Gnus version 5.8.3 only. I have
no idea, whether this patch works in any other Gnus version. (Probably
not, though ;) 


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: gnus-sum.el.diff --]
[-- Type: text/x-patch, Size: 3825 bytes --]

--- /usr/share/emacs/site-lisp/gnus/gnus-sum.el	Wed Jan 26 01:23:18 2000
+++ gnus-sum.el	Tue Jun 13 21:23:40 2000
@@ -941,11 +941,13 @@
 	 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
 	?c)
     (?u gnus-tmp-user-defined ?s)
-    (?P (gnus-pick-line-number) ?d))
+    (?P (gnus-pick-line-number) ?d)
+    (?B gnus-tmp-thread-tree-header-string ?s))
   "An alist of format specifications that can appear in summary lines,
 and what variables they correspond with, along with the type of the
 variable (string, integer, character, etc).")
 
+
 (defvar gnus-summary-dummy-line-format-alist
   `((?S gnus-tmp-subject ?s)
     (?N gnus-tmp-number ?d)
@@ -3768,6 +3770,16 @@
   (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
       ""))
 
+;; Not sure, whether this is the right place to put these variables. 
+(defvar gnus-tmp-thread-tree-header-string nil)
+
+(defvar gnus-sum-thread-tree-root "> ")
+(defvar gnus-sum-thread-tree-single-indent "")
+(defvar gnus-sum-thread-tree-vertical "| ")
+(defvar gnus-sum-thread-tree-indent "  ")
+(defvar gnus-sum-thread-tree-leaf-with-other "+->")
+(defvar gnus-sum-thread-tree-single-leaf "\\->")
+
 (defun gnus-summary-prepare-threads (threads)
   "Prepare summary buffer from THREADS and indentation LEVEL.
 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
@@ -3786,7 +3798,8 @@
 	gnus-tmp-replied gnus-tmp-subject-or-nil
 	gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
 	gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
-	gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
+	gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
+        tree-stack)
 
     (setq gnus-tmp-prev-subject nil)
 
@@ -3824,7 +3837,8 @@
 	    ;; the stack.
 	    (setq state (car stack)
 		  gnus-tmp-level (car state)
-		  thread (cdr state)
+                  tree-stack (cadr state)
+		  thread (caddr state)
 		  stack (cdr stack)
 		  gnus-tmp-header (caar thread))))
 
@@ -3929,7 +3943,7 @@
 	    (push (gnus-data-make number gnus-tmp-unread (1+ (point))
 				  gnus-tmp-header gnus-tmp-level)
 		  gnus-newsgroup-data)
-
+            
 	    ;; Actually insert the line.
 	    (setq
 	     gnus-tmp-subject-or-nil
@@ -3990,7 +4004,21 @@
 	      ((string-match "(.+)" gnus-tmp-from)
 	       (substring gnus-tmp-from
 			  (1+ (match-beginning 0)) (1- (match-end 0))))
-	      (t gnus-tmp-from)))
+	      (t gnus-tmp-from))
+             gnus-tmp-thread-tree-header-string 
+             (if (zerop gnus-tmp-level)
+                 (if (or (cdar thread) (not (nth 1 thread)))
+                     gnus-sum-thread-tree-root
+                   gnus-sum-thread-tree-single-indent)
+               (concat (apply 'concat (mapcar (lambda (item) 
+                                              (if (= item 1) 
+                                                  gnus-sum-thread-tree-vertical
+                                                gnus-sum-thread-tree-indent))
+                                            (cdr (reverse tree-stack))))
+                       (if (nth 1 thread) 
+                           gnus-sum-thread-tree-leaf-with-other
+                         gnus-sum-thread-tree-single-leaf))))
+
 	    (when (string= gnus-tmp-name "")
 	      (setq gnus-tmp-name gnus-tmp-from))
 	    (unless (numberp gnus-tmp-lines)
@@ -4007,7 +4035,13 @@
 	    (setq gnus-tmp-prev-subject subject)))
 
 	(when (nth 1 thread)
-	  (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
+	  (push (list (max 0 gnus-tmp-level) 
+                      (copy-list tree-stack)
+                      (nthcdr 1 thread))
+                stack))
+
+        (push (if (nth 1 thread) 1 0) tree-stack)
+
 	(incf gnus-tmp-level)
 	(setq threads (if thread-end nil (cdar thread)))
 	(unless threads

[-- Attachment #3: Type: text/plain, Size: 25 bytes --]



-- 
!tlilja@cc.hut.fi!

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2000-06-15  7:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-06-15  7:17 [gnu.emacs.gnus] Re: is there a way to have a thread tree like in tin? Timo Lilja

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).