*** empty log message ***
[gnus] / lisp / gnus-gl.el
index d9b97a6..e8c9865 100644 (file)
@@ -1,3 +1,28 @@
+;;; gnus-gl.el --- an interface to GroupLens for Gnus
+;; Copyright (C) 1995,96 Free Software Foundation, Inc.
+
+;; Author: Brad Miller <bmiller@cs.umn.edu>
+;; Keywords: news, score
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; GroupLens software and documentation is copyright (c) 1995 by Paul
 ;; Resnick (Massachusetts Institute of Technology); Brad Miller, John
 ;; As of version 2.5, grouplens now works as a minor mode of 
 ;; gnus-summary-mode.  To get make that work you just need a couple of
 ;; hooks.
-;; In addition, there are a few gnus-*-hooks that need to be set:
-;; (add-hook 'gnus-startup-hook 'bbb-login)
-;; (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode)
-;;
-;; If you want to see grouplens scores using our format you might want to
-;; add a %uG to the gnus-summary-line-format.  For example, I use:
-;; (setq gnus-summary-line-format "%U%R%uG%I%(%[%4L: %-20,20uB%]%) %s\n")
-;; The above format also assumes that you are using gnus-bbdb  You can
-;; just as easily ad %uG to whatever format string you use.  Or add
-;; a %i to just see a simple numeric version of the predictions that
-;; uses less space on the summary line.  If you use %uG you have several
-;; choices for how things look.  See the doc string for the
-;; grouplens-prediction-display variable.
-;; (setq grouplens-prediction-display 'prediction-bar)
-;;
-;; If you use %uI on your group-line-format you will get (GroupLens Enhanced)
-;; after the names of newsgroups supported by GroupLens.
-;; (setq gnus-group-line-format "%M%S%p%5y: %(%g%) %uI\n")
+;; (setq gnus-use-grouplens t)
+;; (setq grouplens-pseudonym "")
+;; (setq grouplens-bbb-host "grouplens.cs.umn.edu")
 ;;
 ;; (setq gnus-summary-default-score 0)
 ;;
-;; In addition there are some GroupLens user variables to set
-;; (setq grouplens-pseudonym "foobar")
-;; If you are using a bbb other than twain.cs.umn.edu you will need to
-;; set the grouplens-bbb-host variable, and possibly the
-;; grouplens-bbb-port variable. 
-;;
-;;(setq grouplens-newsgroups '("comp.lang.c++" "rec.humor" "rec.food.recipes"))
-;; This sets up the groups for which you will get predictions and ratings.
-;;
 ;;                              USING GROUPLENS
 ;; How do I Rate an article??
 ;;   Before you type n to go to the next article, hit a number from 1-5
-;;   Type V r in the summary buffer and you will be prompted.
+;;   Type r in the summary buffer and you will be prompted.
+;;   Note that when you're in grouplens-minor-mode 'r' maskes the
+;;   usual reply binding for 'r'
 ;;
 ;; What if, Gasp, I find a bug???
 ;; Please type M-x gnus-gl-submit-bug-report.  This will set up a
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; 
 
+;;; Code:
+
 (require 'gnus-score)
-(eval-and-compile (require 'cl))
+(require 'cl)
+(require 'gnus-load)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;; User variables
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (defvar gnus-summary-grouplens-line-format
-  "%U%R%z%l%I%(%[%4L: %-20,20n%]%) %s\n"
+  "%U\%R\%z%l%I\%(%[%4L: %-20,20n%]%) %s\n"
   "*The line format spec in summary GroupLens mode buffers.")
 
 (defvar grouplens-pseudonym ""
-  "User's pseudonym.  This pseudonym is obtained during the registration 
-process")
+  "User's pseudonym.  This pseudonym is obtained during the registration process")
 
 (defvar grouplens-bbb-host "grouplens.cs.umn.edu"
   "Host where the bbbd is running" )
@@ -154,27 +159,29 @@ process")
 
 (defvar grouplens-score-offset 0
   "Offset the prediction by this value.  
-Setting this variable to -2 would have the following effect on grouplens 
-scores:
+Setting this variable to -2 would have the following effect on
+GroupLens scores:
+
    1   -->   -2
    2   -->   -1
    3   -->    0
    4   -->    1
    5   -->    2
    
-the reason a user might want to do this is to combine grouplens 
-predictions with scores calculated by other score methods")
+The reason is that a user might want to do this is to combine
+GroupLens predictions with scores calculated by other score methods.")
 
 (defvar grouplens-score-scale-factor 1
-  "This variable allow sthe user to magify the effect of grouplens scores. 
+  "This variable allows the user to magnify the effect of GroupLens scores. 
 The scale factor is applied after the offset.")
 
-(defvar gnus-grouplens-override-scoring t
-  "Tell Grouplens to override the normal Gnus scoring mechanism.  If
-  this variable is non-nill than Grouplens will completely override
-  the normal scoring mechanism of Gnus.  When nil, Grouplens will not
-  override the normal scoring mechanism so both can be used at once.")
+(defvar gnus-grouplens-override-scoring 'override
+  "Tell Grouplens to override the normal Gnus scoring mechanism.  
+GroupLens scores can be combined with gnus scores in one of three ways.
+'override -- just use grouplens predictions for grouplens groups
+'combine  -- combine grouplens scores with gnus scores
+'separate -- treat grouplens scores completely separate from gnus")
+
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;; Program global variables
@@ -205,11 +212,11 @@ The scale factor is applied after the offset.")
 (defvar bbb-alist nil)
 
 (defvar bbb-timeout-secs 10
-  "Number of seconds to wait for some response from the BBB before
-    we give up and assume that something has died..." )
+  "Number of seconds to wait for some response from the BBB.
+If this times out we give up and assume that something has died..." )
 
 (defvar grouplens-previous-article nil
-  "message-id of the last article read")
+  "Message-ID of the last article read.")
 
 (defvar bbb-read-point)
 (defvar bbb-response-point)
@@ -292,16 +299,18 @@ The scale factor is applied after the offset.")
              (bbb-send-command bbb-process 
                                (concat "login " grouplens-pseudonym))
              (if (bbb-read-response bbb-process)
-                 (setq grouplens-bbb-token (extract-token-number))
+                 (setq grouplens-bbb-token (bbb-extract-token-number))
                (gnus-message 3 "Error: Grouplens login failed")))))
     (gnus-message 3 "Error: you must set a pseudonym"))
   grouplens-bbb-token)
 
-(defun extract-token-number ()
+(defun bbb-extract-token-number ()
   (let ((token-pos (search-forward "token=" nil t) ))
     (if (looking-at "[0-9]+")
        (buffer-substring token-pos (match-end 0)))))
 
+(gnus-add-shutdown 'bbb-logout 'gnus)
+
 (defun bbb-logout ()
   "logout of bbb session"
   (let ((bbb-process 
@@ -327,7 +336,7 @@ you should see the offset and scale variables.  At this point, I don't
 recommend using both scores and grouplens predictions together."
   (setq grouplens-current-group groupname)
   (if (member groupname grouplens-newsgroups)
-      (let* ((mid-list (get-all-mids))
+      (let* ((mid-list (bbb-get-all-mids))
             (predict-list (bbb-get-predictions mid-list groupname)))
        (setq grouplens-previous-article nil)
        ;; scores-alist should be a list of lists:
@@ -340,11 +349,13 @@ recommend using both scores and grouplens predictions together."
   "Ask the bbb for predictions, and build up the score alist."
   (if (or (null grouplens-bbb-token)
          (equal grouplens-bbb-token "0"))
-      (gnus-message 3 "Error: You are not logged in to a BBB")
+      (progn 
+       (gnus-message 3 "Error: You are not logged in to a BBB")
+       nil)
     (gnus-message 5 "Fetching Predictions...")
     (let (predict-list
-         (predict-command (build-predict-command midlist groupname 
-                                                 grouplens-bbb-token))
+         (predict-command (bbb-build-predict-command midlist groupname 
+                                                     grouplens-bbb-token))
          (bbb-process (bbb-connect-to-bbbd grouplens-bbb-host 
                                            grouplens-bbb-port)))
       (if bbb-process
@@ -357,7 +368,7 @@ recommend using both scores and grouplens predictions together."
              (ding))))
       (setq bbb-alist predict-list))))
 
-(defun get-all-mids ()
+(defun bbb-get-all-mids ()
   (let ((index (nth 1 (assoc "message-id" gnus-header-index)))
        (articles gnus-newsgroup-headers)
        art this)
@@ -369,7 +380,7 @@ recommend using both scores and grouplens predictions together."
             (setq bbb-mid-list (cons this bbb-mid-list))))
     bbb-mid-list))
 
-(defun build-predict-command (mlist grpname token)
+(defun bbb-build-predict-command (mlist grpname token)
   (let ((cmd (concat "getpredictions " token " " grpname "\r\n"))
        art)
     (while mlist
@@ -388,32 +399,32 @@ recommend using both scores and grouplens predictions together."
       (goto-char bbb-read-point))
     (setq match-end (point))
     (goto-char (+ bbb-response-point 4))  ;; we ought to be right before OK
-    (build-response-alist)))
+    (bbb-build-response-alist)))
 
 ;; build-response-alist assumes that the cursor has been positioned at
 ;; the first line of the list of mid/rating pairs.  For now we will
 ;; use a prediction of 99 to signify no prediction.  Ultimately, we
 ;; should just ignore messages with no predictions.
-(defun build-response-alist ()
+(defun bbb-build-response-alist ()
   (let ((resp nil)
        (match-end (point)))
     (setq grouplens-current-hashtable (make-hash-table :test 'equal :size 100))
     (while
        (cond ((looking-at "\\(<.*>\\) :nopred=")
-              (push `(,(get-mid) ,gnus-summary-default-score nil s) resp)
+              (push `(,(bbb-get-mid) ,gnus-summary-default-score nil s) resp)
               (forward-line 1)
               t)
              ((looking-at "\\(<.*>\\) :pred=\\([0-9]\.[0-9][0-9]\\) :conflow=\\([0-9]\.[0-9][0-9]\\) :confhigh=\\([0-9]\.[0-9][0-9]\\)")
-              (push `(,(get-mid) ,(get-pred) nil s) resp)
-              (cl-puthash (get-mid)
-                          (list (get-pred) (get-confl) (get-confh))
+              (push `(,(bbb-get-mid) ,(bbb-get-pred) nil s) resp)
+              (cl-puthash (bbb-get-mid)
+                          (list (bbb-get-pred) (bbb-get-confl) (bbb-get-confh))
                           grouplens-current-hashtable)
               (forward-line 1)
               t)
              ((looking-at "\\(<.*>\\) :pred=\\([0-9]\.[0-9][0-9]\\)")
-              (push `(,(get-mid) ,(get-pred) nil s) resp)
-              (cl-puthash (get-mid)
-                          (list (get-pred) 0 0)
+              (push `(,(bbb-get-mid) ,(bbb-get-pred) nil s) resp)
+              (cl-puthash (bbb-get-mid)
+                          (list (bbb-get-pred) 0 0)
                           grouplens-current-hashtable)
               (forward-line 1)
               t)
@@ -424,101 +435,102 @@ recommend using both scores and grouplens predictions together."
 ;; around.  Where the first parenthesized expression is the
 ;; message-id, and the second is the prediction.  Since gnus assumes
 ;; that scores are integer values?? we round the prediction.
-(defun get-mid ()
+(defun bbb-get-mid ()
   (buffer-substring (match-beginning 1) (match-end 1)))
 
-(defun get-pred ()
-  (let ((tpred (round (string-to-int (buffer-substring  
+(defun bbb-get-pred ()
+  (let ((tpred (string-to-number (buffer-substring  
                                      (match-beginning 2) 
-                                     (match-end 2))))))
+                                     (match-end 2)))))
     (if (> tpred 0)
-       (* grouplens-score-scale-factor (+ grouplens-score-offset  tpred))
+       (round (* grouplens-score-scale-factor (+ grouplens-score-offset  tpred)))
       1)))
 
-(defun get-confl ()
+(defun bbb-get-confl ()
   (string-to-number (buffer-substring (match-beginning 3) (match-end 3))))
 
-(defun get-confh ()
+(defun bbb-get-confh ()
   (string-to-number (buffer-substring (match-beginning 4) (match-end 4))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;      Prediction Display
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(defconst rating-range 4.0)
+(defconst grplens-rating-range 4.0)
 (defconst grplens-maxrating 5)
 (defconst grplens-minrating 1)
 (defconst grplens-predstringsize 12)
 
-(defalias 'bbb-grouplens-score 'gnus-user-format-function-G)
-
 (defvar gnus-tmp-score)
-(defun gnus-user-format-function-G (header)
-  (let* ((rate-string (make-string 12 ? ))
-        (mid (aref header (nth 1 (assoc "message-id" gnus-header-index))))
-        (hashent (gethash mid grouplens-current-hashtable))
-        (iscore (if (string-match "September" gnus-version) 
-                    gnus-tmp-score
-                  score))
-        (low (car (cdr hashent)))
-        (high (car (cdr (cdr hashent)))))
-    (aset rate-string 0 ?|) 
-    (aset rate-string 11 ?|)
-    (unless (member grouplens-current-group grouplens-newsgroups)
-      (unless (equal grouplens-prediction-display 'prediction-num)
-       (cond ((< iscore 0)
-              (setq iscore 1))
-             ((> iscore 5)
-              (setq iscore 5))))
-      (setq low 0) 
-      (setq high 0))
-    (if (and (grouplens-valid-score iscore) 
-            (not (null mid)))
-       (cond 
-        ;; prediction-spot
-        ((equal grouplens-prediction-display 'prediction-spot)
-         (setq rate-string (fmt-prediction-spot rate-string iscore)))
-        ;; confidence-interval
-        ((equal grouplens-prediction-display 'confidence-interval)
-         (setq rate-string (fmt-confidence-interval iscore low high)))
-        ;; prediction-bar
-        ((equal grouplens-prediction-display 'prediction-bar)
-         (setq rate-string (fmt-prediction-bar rate-string iscore)))
-        ;; confidence-bar
-        ((equal grouplens-prediction-display 'confidence-bar)
-         (setq rate-string (format "|   %4.2f   |" iscore)))
-        ;; confidence-spot
-        ((equal grouplens-prediction-display 'confidence-spot)
-         (setq rate-string (format "|   %4.2f   |" iscore)))
-        ;; prediction-num
-        ((equal grouplens-prediction-display 'prediction-num)
-         (setq rate-string (fmt-prediction-num iscore)))
-        ;; confidence-plus-minus
-        ((equal grouplens-prediction-display 'confidence-plus-minus)
-              (setq rate-string (fmt-confidence-plus-minus iscore low high))
-              )
-        (t (gnus-message 3 "Invalid prediction display type")))
-      (aset rate-string 5 ?N) (aset rate-string 6 ?A))
-    rate-string))
+(defun bbb-grouplens-score (header)
+  (if (eq gnus-grouplens-override-scoring 'separate)
+      (bbb-grouplens-other-score header)
+    (let* ((rate-string (make-string 12 ? ))
+          (mid (aref header (nth 1 (assoc "message-id" gnus-header-index))))
+          (hashent (gethash mid grouplens-current-hashtable))
+          (iscore gnus-tmp-score)
+          (low (car (cdr hashent)))
+          (high (car (cdr (cdr hashent)))))
+      (aset rate-string 0 ?|) 
+      (aset rate-string 11 ?|)
+      (unless (member grouplens-current-group grouplens-newsgroups)
+       (unless (equal grouplens-prediction-display 'prediction-num)
+         (cond ((< iscore 0)
+                (setq iscore 1))
+               ((> iscore 5)
+                (setq iscore 5))))
+       (setq low 0) 
+       (setq high 0))
+      (if (and (bbb-valid-score iscore) 
+              (not (null mid)))
+         (cond 
+          ;; prediction-spot
+          ((equal grouplens-prediction-display 'prediction-spot)
+           (setq rate-string (bbb-fmt-prediction-spot rate-string iscore)))
+          ;; confidence-interval
+          ((equal grouplens-prediction-display 'confidence-interval)
+           (setq rate-string (bbb-fmt-confidence-interval iscore low high)))
+          ;; prediction-bar
+          ((equal grouplens-prediction-display 'prediction-bar)
+           (setq rate-string (bbb-fmt-prediction-bar rate-string iscore)))
+          ;; confidence-bar
+          ((equal grouplens-prediction-display 'confidence-bar)
+           (setq rate-string (format "|   %4.2f   |" iscore)))
+          ;; confidence-spot
+          ((equal grouplens-prediction-display 'confidence-spot)
+           (setq rate-string (format "|   %4.2f   |" iscore)))
+          ;; prediction-num
+          ((equal grouplens-prediction-display 'prediction-num)
+           (setq rate-string (bbb-fmt-prediction-num iscore)))
+          ;; confidence-plus-minus
+          ((equal grouplens-prediction-display 'confidence-plus-minus)
+           (setq rate-string (bbb-fmt-confidence-plus-minus iscore low high))
+           )
+          (t (gnus-message 3 "Invalid prediction display type")))
+       (aset rate-string 5 ?N) (aset rate-string 6 ?A))
+      rate-string)))
 
 ;;
 ;; Gnus user format function that doesn't depend on
 ;; bbb-build-mid-scores-alist being used as the score function, but is
 ;; instead called from gnus-select-group-hook. -- LAB
-(defun gnus-user-format-function-L (header)
+(defun bbb-grouplens-other-score (header)
   (if (not (member grouplens-current-group grouplens-newsgroups))
       ;; Return an empty string
       ""
     (let* ((rate-string (make-string 12 ? ))
            (mid (aref header (nth 1 (assoc "message-id" gnus-header-index))))
            (hashent (gethash mid grouplens-current-hashtable))
-           (pred (nth 0 hashent))
+           (pred (or (nth 0 hashent) 0))
            (low (nth 1 hashent))
            (high (nth 2 hashent)))
-      (gnus-message 5 (concat "mid = " mid))
       ;; Init rate-string
       (aset rate-string 0 ?|) 
       (aset rate-string 11 ?|)
-      
+      (unless (equal grouplens-prediction-display 'prediction-num)
+       (cond ((< pred 0)
+              (setq pred 1))
+             ((> pred 5)
+              (setq pred 5))))
       ;; If no entry in BBB hash mark rate string as NA and return
       (cond 
        ((null hashent) 
@@ -527,13 +539,13 @@ recommend using both scores and grouplens predictions together."
        rate-string)
 
        ((equal grouplens-prediction-display 'prediction-spot)
-       (fmt-prediction-spot rate-string pred))
+       (bbb-fmt-prediction-spot rate-string pred))
        
        ((equal grouplens-prediction-display 'confidence-interval)
-       (fmt-confidence-interval pred low high))
+       (bbb-fmt-confidence-interval pred low high))
        
        ((equal grouplens-prediction-display 'prediction-bar)
-       (fmt-prediction-bar rate-string pred))
+       (bbb-fmt-prediction-bar rate-string pred))
 
        ((equal grouplens-prediction-display 'confidence-bar)
        (format "|   %4.2f   |" pred))
@@ -542,10 +554,10 @@ recommend using both scores and grouplens predictions together."
        (format "|   %4.2f   |" pred))
        
        ((equal grouplens-prediction-display 'prediction-num)
-       (fmt-prediction-num pred))
+       (bbb-fmt-prediction-num pred))
        
        ((equal grouplens-prediction-display 'confidence-plus-minus)
-       (fmt-confidence-plus-minus pred low high))
+       (bbb-fmt-confidence-plus-minus pred low high))
        
        (t 
        (gnus-message 3 "Invalid prediction display type")
@@ -553,40 +565,40 @@ recommend using both scores and grouplens predictions together."
        (aset rate-string 11 ?|)
        rate-string)))))
 
-(defun grouplens-valid-score (score)
+(defun bbb-valid-score (score)
   (or (equal grouplens-prediction-display 'prediction-num)
       (and (>= score grplens-minrating)
           (<= score grplens-maxrating))))
 
-(defun requires-confidence (format-type)
+(defun bbb-requires-confidence (format-type)
   (or (equal format-type 'confidence-plus-minus)
       (equal format-type 'confidence-spot)
       (equal format-type 'confidence-interval)))
 
-(defun have-confidence (clow chigh)
+(defun bbb-have-confidence (clow chigh)
   (not (or (null clow)
           (null chigh))))
 
-(defun fmt-prediction-spot (rate-string score)
+(defun bbb-fmt-prediction-spot (rate-string score)
   (aset rate-string
-       (round (* (/ (- score grplens-minrating) rating-range)
+       (round (* (/ (- score grplens-minrating) grplens-rating-range)
                  (+ (- grplens-predstringsize 4) 1.49)))
        ?*)
   rate-string)
 
-(defun fmt-confidence-interval (score low high)
-  (if (have-confidence low high)
+(defun bbb-fmt-confidence-interval (score low high)
+  (if (bbb-have-confidence low high)
       (format "|%4.2f-%4.2f |" low high)
-    (fmt-prediction-num score)))
+    (bbb-fmt-prediction-num score)))
 
-(defun fmt-confidence-plus-minus (score low high)
-  (if (have-confidence low high)
+(defun bbb-fmt-confidence-plus-minus (score low high)
+  (if (bbb-have-confidence low high)
       (format "|%3.1f+/-%4.2f|" score (/ (- high low) 2.0))
-    (fmt-prediction-num score)))
+    (bbb-fmt-prediction-num score)))
 
-(defun fmt-prediction-bar (rate-string score)
+(defun bbb-fmt-prediction-bar (rate-string score)
   (let* ((i 1) 
-        (step (/ rating-range (- grplens-predstringsize 4)))
+        (step (/ grplens-rating-range (- grplens-predstringsize 4)))
         (half-step (/ step 2))
         (loc (- grplens-minrating half-step)))
     (while (< i (- grplens-predstringsize 2))
@@ -598,7 +610,7 @@ recommend using both scores and grouplens predictions together."
     )
   rate-string)
 
-(defun fmt-prediction-num (score)
+(defun bbb-fmt-prediction-num (score)
   (format "|   %4.2f   |" score))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -613,7 +625,7 @@ recommend using both scores and grouplens predictions together."
           (member gnus-newsgroup-name grouplens-newsgroups))
       (let ((bbb-process (bbb-connect-to-bbbd grouplens-bbb-host 
                                          grouplens-bbb-port))
-           (rate-command (build-rate-command grouplens-rating-alist)))
+           (rate-command (bbb-build-rate-command grouplens-rating-alist)))
        (if bbb-process
            (save-excursion 
              (set-buffer (process-buffer bbb-process))
@@ -628,7 +640,7 @@ recommend using both scores and grouplens predictions together."
          (gnus-message 3 "No BBB connection")))
     (setq grouplens-rating-alist nil)))
 
-(defun build-rate-command (rate-alist)
+(defun bbb-build-rate-command (rate-alist)
   (let (this
        (cmd (concat "putratings " grouplens-bbb-token 
                     " " grouplens-current-group " \r\n")))
@@ -643,7 +655,7 @@ recommend using both scores and grouplens predictions together."
 (defun bbb-summary-rate-article (rating &optional midin)
   (interactive "nRating: ")
   (when (member gnus-newsgroup-name grouplens-newsgroups)
-    (let ((mid (or midin (get-current-id))))
+    (let ((mid (or midin (bbb-get-current-id))))
       (if (and rating 
               (>= rating grplens-minrating) 
               (<= rating grplens-maxrating)
@@ -701,19 +713,12 @@ recommend using both scores and grouplens predictions together."
   (gnus-set-mode-line 'summary))
 
 
-(defun get-current-id ()
+(defun bbb-get-current-id ()
   (if gnus-current-headers
       (aref gnus-current-headers 
            (nth 1 (assoc "message-id" gnus-header-index)))
     (gnus-message 3 "You must select an article before you rate it")))
 
-(defvar gnus-tmp-group)
-(defun gnus-user-format-function-I (header)
-  (let ((gname (if (string-match "September" gnus-version)
-                  gnus-tmp-group
-                group)))
-    (if (member gname grouplens-newsgroups) "  (GroupLens Enhanced)" "")))
-
 (defun bbb-grouplens-group-p (group)
   "Say whether GROUP is a GroupLens group."
   (if (member group grouplens-newsgroups) " (GroupLens Enhanced)" ""))
@@ -727,10 +732,10 @@ recommend using both scores and grouplens predictions together."
   (setq grouplens-current-starting-time (current-time)))
 
 (defun grouplens-elapsed-time ()
-  (let ((et (time-float (current-time))))
-    (- et (time-float grouplens-current-starting-time))))
+  (let ((et (bbb-time-float (current-time))))
+    (- et (bbb-time-float grouplens-current-starting-time))))
 
-(defun time-float (timeval)
+(defun bbb-time-float (timeval)
   (+ (* (car timeval) 65536) 
        (cadr timeval)))
 
@@ -745,13 +750,13 @@ recommend using both scores and grouplens predictions together."
                  grouplens-rating-alist)
          (setcdr oldrating (cons (cadr oldrating) elapsed-time)))))
     (grouplens-start-timer)
-    (setq grouplens-previous-article (get-current-id))))
+    (setq grouplens-previous-article (bbb-get-current-id))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;          BUG REPORTING
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(defconst gnus-gl-version "gnus-gl.el 2.5lars/rrh")
+(defconst gnus-gl-version "gnus-gl.el 2.12")
 (defconst gnus-gl-maintainer-address "grouplens-bug@cs.umn.edu")
 (defun gnus-gl-submit-bug-report ()
   "Submit via mail a bug report on gnus-gl"
@@ -819,24 +824,37 @@ recommend using both scores and grouplens predictions together."
          (if (null arg) (not gnus-grouplens-mode)
            (> (prefix-numeric-value arg) 0)))
     (when gnus-grouplens-mode
-      (if (not (fboundp 'make-local-hook))
-         (add-hook 'gnus-select-article-hook 'grouplens-do-time)
-       (make-local-hook 'gnus-select-article-hook)
-       (add-hook 'gnus-select-article-hook 'grouplens-do-time nil 'local))
-      (if (not (fboundp 'make-local-hook))
-         (add-hook 'gnus-exit-group-hook 'bbb-put-ratings)
-       (make-local-hook 'gnus-exit-group-hook)
-       (add-hook 'gnus-exit-group-hook 'bbb-put-ratings nil 'local))
+      (gnus-make-local-hook 'gnus-select-article-hook)
+      (gnus-add-hook 'gnus-select-article-hook 'grouplens-do-time nil 'local)
+      (gnus-make-local-hook 'gnus-exit-group-hook)
+      (gnus-add-hook 'gnus-exit-group-hook 'bbb-put-ratings nil 'local)
       (make-local-variable 'gnus-score-find-score-files-function)
-      (if gnus-grouplens-override-scoring
-          (setq gnus-score-find-score-files-function 
-                'bbb-build-mid-scores-alist)
-        (add-hook 'gnus-select-group-hook 
-                  '(lambda() 
-                     (bbb-build-mid-scores-alist gnus-newsgroup-name))))
+      (cond ((eq gnus-grouplens-override-scoring 'combine)
+            ;; either add bbb-buld-mid-scores-alist to a list
+             ;; or make a list
+            (if (listp gnus-score-find-score-files-function)
+                (setq gnus-score-find-score-files-function 
+                  (append 'bbb-build-mid-scores-alist      
+                          gnus-score-find-score-files-function ))
+              (setq gnus-score-find-score-files-function 
+                    (list gnus-score-find-score-files-function 
+                          'bbb-build-mid-scores-alist))))
+            ;; leave the gnus-score-find-score-files variable alone
+           ((eq gnus-grouplens-override-scoring 'separate)
+            (add-hook 'gnus-select-group-hook 
+                      '(lambda() 
+                         (bbb-build-mid-scores-alist gnus-newsgroup-name))))
+           ;; default is to override
+           (t (setq gnus-score-find-score-files-function 
+                    'bbb-build-mid-scores-alist)))
+
+      ;; Change how summary lines look
       (make-local-variable 'gnus-summary-line-format)
-      (setq gnus-summary-line-format gnus-summary-grouplens-line-format)
       (make-local-variable 'gnus-summary-line-format-spec)
+      (setq gnus-summary-line-format gnus-summary-grouplens-line-format)
+      (setq gnus-summary-line-format-spec nil)
+      (gnus-update-format-specifications nil 'summary)
+      (gnus-update-summary-mark-positions)
 
       ;; Set up the menu.
       (when (and menu-bar-mode
@@ -851,4 +869,4 @@ recommend using both scores and grouplens predictions together."
 
 (provide 'gnus-gl)
 
-;;; end gnus-gl.el
+;;; gnus-gl.el ends here