Fix my last change.
[gnus] / lisp / gnus-gl.el
index 8e2953e..afb16fc 100644 (file)
@@ -1,5 +1,5 @@
 ;;; gnus-gl.el --- an interface to GroupLens for Gnus
-;; Copyright (C) 1995,96,97 Free Software Foundation, Inc.
+;; Copyright (C) 1995,96,97,98,99 Free Software Foundation, Inc.
 
 ;; Author: Brad Miller <bmiller@cs.umn.edu>
 ;; Keywords: news, score
 
 ;;; Code:
 
+(eval-when-compile (require 'cl))
+
 (require 'gnus-score)
-(require 'cl)
 (require 'gnus)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 This pseudonym is obtained during the registration process")
 
 (defvar grouplens-bbb-host "grouplens.cs.umn.edu"
-  "Host where the bbbd is running)
+  "Host where the bbbd is running.")
 
 (defvar grouplens-bbb-port 9000
-  "Port where the bbbd is listening)
+  "Port where the bbbd is listening.")
 
 (defvar grouplens-newsgroups
   '("comp.groupware" "comp.human-factors" "comp.lang.c++"
@@ -193,19 +194,19 @@ GroupLens scores can be combined with gnus scores in one of three ways.
 ;;;; Program global variables
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 (defvar grouplens-bbb-token nil
-  "Current session token number")
+  "Current session token number.")
 
 (defvar grouplens-bbb-process nil
-  "Process Id of current bbbd network stream process")
+  "Process Id of current bbbd network stream process.")
 
 (defvar grouplens-bbb-buffer nil
-  "Buffer associated with the BBBD process")
+  "Buffer associated with the BBBD process.")
 
 (defvar grouplens-rating-alist nil
-  "Current set of  message-id rating pairs")
+  "Current set of  message-id rating pairs.")
 
 (defvar grouplens-current-hashtable nil
-  "A hashtable to hold predictions from the BBB")
+  "A hashtable to hold predictions from the BBB.")
 
 (defvar grouplens-current-group nil)
 
@@ -233,7 +234,7 @@ If this times out we give up and assume that something has died..." )
 (defun bbb-connect-to-bbbd (host port)
   (unless grouplens-bbb-buffer
     (setq grouplens-bbb-buffer
-         (get-buffer-create (format " *BBBD trace: %s*" host)))
+         (gnus-get-buffer-create (format " *BBBD trace: %s*" host)))
     (save-excursion
       (set-buffer grouplens-bbb-buffer)
       (make-local-variable 'bbb-read-point)
@@ -298,7 +299,7 @@ If this times out we give up and assume that something has died..." )
 ;;;;       Login Functions
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 (defun bbb-login ()
-  "return the token number if login is successful, otherwise return nil"
+  "return the token number if login is successful, otherwise return nil."
   (interactive)
   (setq grouplens-bbb-token nil)
   (if (not (equal grouplens-pseudonym ""))
@@ -311,7 +312,7 @@ If this times out we give up and assume that something has died..." )
                                (concat "login " grouplens-pseudonym))
              (if (bbb-read-response bbb-process)
                  (setq grouplens-bbb-token (bbb-extract-token-number))
-             (gnus-message 3 "Error: GroupLens login failed")))))
+               (gnus-message 3 "Error: GroupLens login failed")))))
     (gnus-message 3 "Error: you must set a pseudonym"))
   grouplens-bbb-token)
 
@@ -323,7 +324,7 @@ If this times out we give up and assume that something has died..." )
 (gnus-add-shutdown 'bbb-logout 'gnus)
 
 (defun bbb-logout ()
-  "logout of bbb session"
+  "logout of bbb session."
   (when grouplens-bbb-token
     (let ((bbb-process
           (bbb-connect-to-bbbd grouplens-bbb-host grouplens-bbb-port)))
@@ -338,9 +339,8 @@ If this times out we give up and assume that something has died..." )
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (defun bbb-build-mid-scores-alist (groupname)
-  "this function can be called as part of the function to return the
-list of score files to use.  See the gnus variable
-gnus-score-find-score-files-function.
+  "this function can be called as part of the function to return the list of score files to use.
+See the gnus variable gnus-score-find-score-files-function.
 
 *Note:*  If you want to use grouplens scores along with calculated scores,
 you should see the offset and scale variables.  At this point, I don't
@@ -406,7 +406,7 @@ recommend using both scores and grouplens predictions together."
                pred (bbb-get-pred))
          (push `(,mid ,pred nil s) resp)
          (gnus-sethash mid (list pred (bbb-get-confl) (bbb-get-confh))
-                     grouplens-current-hashtable)
+                       grouplens-current-hashtable)
          (forward-line 1)
          t)
         ((looking-at "\\(<.*>\\) :pred=\\([0-9]\.[0-9][0-9]\\)")
@@ -668,9 +668,8 @@ recommend using both scores and grouplens predictions together."
   (gnus-summary-best-unread-article))
 
 (defun grouplens-summary-catchup-and-exit (rating)
-  "Mark all articles not marked as unread in this newsgroup as read,
-    then exit.   If prefix argument ALL is non-nil, all articles are
-    marked as read."
+  "Mark all articles not marked as unread in this newsgroup as read, then exit.
+If prefix argument ALL is non-nil, all articles are marked as read."
   (interactive "P")
   (when rating
     (bbb-summary-rate-article rating))
@@ -687,7 +686,6 @@ recommend using both scores and grouplens predictions together."
            article)
        (while (setq article (pop articles))
          (gnus-summary-goto-subject article)
-         (gnus-set-global-variables)
          (bbb-summary-rate-article score
                                    (mail-header-id
                                     (gnus-summary-article-header article)))))
@@ -748,7 +746,7 @@ recommend using both scores and grouplens predictions together."
 (defconst gnus-gl-version "gnus-gl.el 2.50")
 (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"
+  "Submit via mail a bug report on gnus-gl."
   (interactive)
   (require 'reporter)
   (reporter-submit-bug-report gnus-gl-maintainer-address
@@ -765,9 +763,9 @@ recommend using both scores and grouplens predictions together."
                              'gnus-gl-get-trace))
 
 (defun gnus-gl-get-trace ()
-  "Insert the contents of the BBBD trace buffer"
+  "Insert the contents of the BBBD trace buffer."
   (when grouplens-bbb-buffer
-    (insert-buffer grouplens-bbb-buffer)))
+    (insert-buffer-substring grouplens-bbb-buffer)))
 
 ;;
 ;; GroupLens minor mode
@@ -781,12 +779,12 @@ recommend using both scores and grouplens predictions together."
 (unless gnus-grouplens-mode-map
   (setq gnus-grouplens-mode-map (make-keymap))
   (gnus-define-keys
-   gnus-grouplens-mode-map
-   "n" grouplens-next-unread-article
-   "r" bbb-summary-rate-article
-   "k" grouplens-score-thread
-   "c" grouplens-summary-catchup-and-exit
-   "," grouplens-best-unread-article))
+      gnus-grouplens-mode-map
+    "n" grouplens-next-unread-article
+    "r" bbb-summary-rate-article
+    "k" grouplens-score-thread
+    "c" grouplens-summary-catchup-and-exit
+    "," grouplens-best-unread-article))
 
 (defun gnus-grouplens-make-menu-bar ()
   (unless (boundp 'gnus-grouplens-menu)
@@ -811,9 +809,9 @@ recommend using both scores and grouplens predictions together."
            (> (prefix-numeric-value arg) 0)))
     (when gnus-grouplens-mode
       (make-local-hook 'gnus-select-article-hook)
-      (gnus-add-hook 'gnus-select-article-hook 'grouplens-do-time nil 'local)
+      (add-hook 'gnus-select-article-hook 'grouplens-do-time nil 'local)
       (make-local-hook 'gnus-exit-group-hook)
-      (gnus-add-hook 'gnus-exit-group-hook 'bbb-exit-group nil 'local)
+      (add-hook 'gnus-exit-group-hook 'bbb-exit-group nil 'local)
       (make-local-variable 'gnus-score-find-score-files-function)
 
       (cond
@@ -850,12 +848,9 @@ recommend using both scores and grouplens predictions together."
       (when (and menu-bar-mode
                 (gnus-visual-p 'grouplens-menu 'menu))
        (gnus-grouplens-make-menu-bar))
-      (unless (assq 'gnus-grouplens-mode minor-mode-alist)
-       (push '(gnus-grouplens-mode " GroupLens") minor-mode-alist))
-      (unless (assq 'gnus-grouplens-mode minor-mode-map-alist)
-       (push (cons 'gnus-grouplens-mode gnus-grouplens-mode-map)
-             minor-mode-map-alist))
-      (run-hooks 'gnus-grouplens-mode-hook))))
+      (gnus-add-minor-mode
+       'gnus-grouplens-mode " GroupLens" gnus-grouplens-mode-map)
+      (gnus-run-hooks 'gnus-grouplens-mode-hook))))
 
 (provide 'gnus-gl)