*** empty log message ***
[gnus] / lisp / gnus-agent.el
index a76b502..f8f353d 100644 (file)
@@ -1,9 +1,7 @@
 ;;; gnus-agent.el --- unplugged support for Gnus
-;; Copyright (C) 1997 Free Software Foundation, Inc.
+;; Copyright (C) 1997,98 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
-;; Keywords: news
-
 ;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
   :group 'gnus-agent
   :type 'hook)
 
+(defcustom gnus-agent-handle-level gnus-level-subscribed
+  "Groups on levels higher than this variable will be ignored by the Agent."
+  :group 'gnus-agent
+  :type 'integer)
+
 ;;; Internal variables
 
 (defvar gnus-agent-history-buffers nil)
 
 (defsubst gnus-agent-directory ()
   "Path of the Gnus agent directory."
-  (nnheader-concat gnus-agent-directory (gnus-agent-method) "/"))
+  (nnheader-concat gnus-agent-directory
+                  (nnheader-translate-file-chars (gnus-agent-method)) "/"))
 
 (defun gnus-agent-lib-file (file)
   "The full path of the Gnus agent library FILE."
                                                     buffer))))
            minor-mode-map-alist))
     (gnus-agent-toggle-plugged gnus-plugged)
-    (run-hooks 'gnus-agent-mode-hook)))
+    (gnus-run-hooks 'gnus-agent-mode-hook)))
 
 (defvar gnus-agent-group-mode-map (make-sparse-keymap))
 (gnus-define-keys gnus-agent-group-mode-map
   (interactive (list (not gnus-plugged)))
   (if plugged
       (progn
-       (run-hooks 'gnus-agent-plugged-hook)
+       (setq gnus-plugged plugged)
+       (gnus-run-hooks 'gnus-agent-plugged-hook)
        (setcar (cdr gnus-agent-mode-status) " Plugged"))
     (gnus-agent-close-connections)
-    (run-hooks 'gnus-agent-unplugged-hook)
+    (setq gnus-plugged plugged)
+    (gnus-run-hooks 'gnus-agent-unplugged-hook)
     (setcar (cdr gnus-agent-mode-status) " Unplugged"))
-  (setq gnus-plugged plugged)
   (set-buffer-modified-p t))
 
 (defun gnus-agent-close-connections ()
   (setq gnus-plugged nil)
   (gnus))
 
+;;;###autoload
+(defun gnus-plugged ()
+  "Start Gnus plugged."
+  (interactive)
+  (setq gnus-plugged t)
+  (gnus))
+
 ;;;###autoload
 (defun gnus-agentize ()
   "Allow Gnus to be an offline newsreader.
@@ -475,8 +487,11 @@ the actual number of articles toggled is returned."
 
 (defun gnus-agent-group-path (group)
   "Translate GROUP into a path."
-  (nnheader-translate-file-chars
-   (nnheader-replace-chars-in-string group ?. ?/)))
+  (if nnmail-use-long-file-names
+      group
+    (nnheader-replace-chars-in-string
+     (nnheader-translate-file-chars group)
+     ?. ?/)))
 
 \f
 
@@ -614,7 +629,8 @@ the actual number of articles toggled is returned."
            (if (not (re-search-forward "^Message-ID: *<\\([^>\n]+\\)>" nil t))
                (setq id "No-Message-ID-in-article")
              (setq id (buffer-substring (match-beginning 1) (match-end 1))))
-           (let ((coding-system-for-write gnus-agent-article-file-coding-system))
+           (let ((coding-system-for-write
+                  gnus-agent-article-file-coding-system))
              (write-region (point-min) (point-max)
                            (concat dir (number-to-string (caar pos)))
                            nil 'silent))
@@ -794,7 +810,8 @@ the actual number of articles toggled is returned."
              groups (gnus-groups-from-server (pop methods)))
        (gnus-agent-with-fetch
          (while (setq group (pop groups))
-           (gnus-agent-fetch-group-1 group gnus-command-method))))
+           (when (<= (gnus-group-level group) gnus-agent-handle-level)
+             (gnus-agent-fetch-group-1 group gnus-command-method)))))
       (gnus-message 6 "Finished fetching articles into the Gnus agent"))))
 
 (defun gnus-agent-fetch-group-1 (group method)
@@ -920,7 +937,7 @@ the actual number of articles toggled is returned."
        ["Edit groups" gnus-category-edit-groups t]
        ["Exit" gnus-category-exit t]))
 
-    (run-hooks 'gnus-category-menu-hook)))
+    (gnus-run-hooks 'gnus-category-menu-hook)))
 
 (defun gnus-category-mode ()
   "Major mode for listing and editing agent categories.
@@ -946,7 +963,7 @@ The following commands are available:
   (buffer-disable-undo (current-buffer))
   (setq truncate-lines t)
   (setq buffer-read-only t)
-  (run-hooks 'gnus-category-mode-hook))
+  (gnus-run-hooks 'gnus-category-mode-hook))
 
 (defalias 'gnus-category-position-point 'gnus-goto-colon)
 
@@ -995,7 +1012,7 @@ The following commands are available:
   (setq gnus-category-alist
        (or (gnus-agent-read-file
             (nnheader-concat gnus-agent-directory "lib/categories"))
-           (list (list 'default 'true nil nil)))))
+           (list (list 'default 'short nil nil)))))
     
 (defun gnus-category-write ()
   "Write the category alist."
@@ -1258,6 +1275,15 @@ The following commands are available:
                (delete-file file))))))
       (gnus-agent-save-alist nil nil nil dir))))
 
+;;;###autoload
+(defun gnus-agent-batch ()
+  (interactive)
+  (let ((init-file-user "")
+       (gnus-always-read-dribble-file t))
+    (gnus))
+  (gnus-group-send-drafts)
+  (gnus-agent-fetch-session))
+
 (provide 'gnus-agent)
 
 ;;; gnus-agent.el ends here