*** empty log message ***
[gnus] / lisp / gnus-gl.el
index 1d4fd7c..e8c9865 100644 (file)
 
 (require 'gnus-score)
 (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 ""
@@ -174,11 +175,13 @@ GroupLens predictions with scores calculated by other score methods.")
   "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
+(defvar gnus-grouplens-override-scoring 'override
   "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.")
+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
@@ -346,7 +349,9 @@ 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 (bbb-build-predict-command midlist groupname 
@@ -434,11 +439,11 @@ recommend using both scores and grouplens predictions together."
   (buffer-substring (match-beginning 1) (match-end 1)))
 
 (defun bbb-get-pred ()
-  (let ((tpred (round (string-to-int (buffer-substring  
+  (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 bbb-get-confl ()
@@ -457,7 +462,7 @@ recommend using both scores and grouplens predictions together."
 
 (defvar gnus-tmp-score)
 (defun bbb-grouplens-score (header)
-  (if (null gnus-grouplens-override-scoring)
+  (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))))
@@ -819,26 +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