gmm-utils.el (gmm-flet, gmm-labels): New macros.
[gnus] / lisp / nnvirtual.el
index 751e6be..edc9fb6 100644 (file)
@@ -1,7 +1,6 @@
 ;;; nnvirtual.el --- virtual newsgroups access for Gnus
 
-;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-;;   2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+;; Copyright (C) 1994-2012 Free Software Foundation, Inc.
 
 ;; Author: David Moore <dmoore@ucsd.edu>
 ;;     Lars Magne Ingebrigtsen <larsi@gnus.org>
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; 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.
+;; the Free Software Foundation, either version 3 of the License, 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
@@ -21,9 +20,7 @@
 ;; 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., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -83,8 +80,7 @@ component group will show up when you enter the virtual group.")
 
 (defvoo nnvirtual-status-string "")
 
-(eval-and-compile
-  (autoload 'gnus-cache-articles-in-group "gnus-cache"))
+(autoload 'gnus-cache-articles-in-group "gnus-cache")
 
 \f
 
@@ -96,8 +92,7 @@ component group will show up when you enter the virtual group.")
 (deffoo nnvirtual-retrieve-headers (articles &optional newsgroup
                                             server fetch-old)
   (when (nnvirtual-possibly-change-server server)
-    (save-excursion
-      (set-buffer nntp-server-buffer)
+    (with-current-buffer nntp-server-buffer
       (erase-buffer)
       (if (stringp (car articles))
          'headers
@@ -173,8 +168,7 @@ component group will show up when you enter the virtual group.")
          ;; the nntp-server-buffer, which is where Gnus expects to find
          ;; them.
          (prog1
-             (save-excursion
-               (set-buffer nntp-server-buffer)
+             (with-current-buffer nntp-server-buffer
                (erase-buffer)
                (insert-buffer-substring vbuf)
                ;; FIX FIX FIX, we should be able to sort faster than
@@ -200,10 +194,11 @@ component group will show up when you enter the virtual group.")
            (when buffer
              (set-buffer buffer))
            (let* ((gnus-override-method nil)
-                  (method (gnus-find-method-for-group
-                           nnvirtual-last-accessed-component-group)))
-             (funcall (gnus-get-function method 'request-article)
-                      article nil (nth 1 method) buffer)))))
+                  (gnus-command-method
+                   (gnus-find-method-for-group
+                    nnvirtual-last-accessed-component-group)))
+             (funcall (gnus-get-function gnus-command-method 'request-article)
+                      article nil (nth 1 gnus-command-method) buffer)))))
       ;; This is a fetch by number.
       (let* ((amap (nnvirtual-map-article article))
             (cgroup (car amap)))
@@ -218,8 +213,7 @@ component group will show up when you enter the virtual group.")
         (t
          (setq nnvirtual-last-accessed-component-group cgroup)
          (if buffer
-             (save-excursion
-               (set-buffer buffer)
+             (with-current-buffer buffer
                ;; We bind this here to avoid double decoding.
                (let ((gnus-article-decode-hook nil))
                  (gnus-request-article-this-buffer (cdr amap) cgroup)))
@@ -253,7 +247,7 @@ component group will show up when you enter the virtual group.")
       t)))
 
 
-(deffoo nnvirtual-request-group (group &optional server dont-check)
+(deffoo nnvirtual-request-group (group &optional server dont-check info)
   (nnvirtual-possibly-change-server server)
   (setq nnvirtual-component-groups
        (delete (nnvirtual-current-group) nnvirtual-component-groups))
@@ -263,13 +257,11 @@ component group will show up when you enter the virtual group.")
     (nnheader-report 'nnvirtual "No component groups in %s" group))
    (t
     (setq nnvirtual-current-group group)
-    (when (or (not dont-check)
-             nnvirtual-always-rescan)
-      (nnvirtual-create-mapping)
-      (when nnvirtual-always-rescan
-       (nnvirtual-request-update-info
-        (nnvirtual-current-group)
-        (gnus-get-info (nnvirtual-current-group)))))
+    (nnvirtual-create-mapping dont-check)
+    (when nnvirtual-always-rescan
+      (nnvirtual-request-update-info
+       (nnvirtual-current-group)
+       (gnus-get-info (nnvirtual-current-group))))
     (nnheader-insert "211 %d 1 %d %s\n"
                     nnvirtual-mapping-len nnvirtual-mapping-len group))))
 
@@ -303,10 +295,6 @@ component group will show up when you enter the virtual group.")
   t)
 
 
-(deffoo nnvirtual-request-list (&optional server)
-  (nnheader-report 'nnvirtual "LIST is not implemented."))
-
-
 (deffoo nnvirtual-request-newgroups (date &optional server)
   (nnheader-report 'nnvirtual "NEWGROUPS is not supported."))
 
@@ -344,8 +332,7 @@ component group will show up when you enter the virtual group.")
         (when (not (numberp (gnus-group-unread g)))
           (gnus-activate-group g)))
        nnvirtual-component-groups)
-      (save-excursion
-       (set-buffer gnus-group-buffer)
+      (with-current-buffer gnus-group-buffer
        (gnus-group-catchup-current nil all)))))
 
 
@@ -677,7 +664,7 @@ the result."
     carticles))
 
 
-(defun nnvirtual-create-mapping ()
+(defun nnvirtual-create-mapping (dont-check)
   "Build the tables necessary to map between component (group, article) to virtual article.
 Generate the set of read messages and marks for the virtual group
 based on the marks on the component groups."
@@ -696,7 +683,9 @@ based on the marks on the component groups."
     ;; Into all-marks we put (g marks).
     ;; We also increment cnt and tot here, and compute M (max of sizes).
     (mapc (lambda (g)
-           (setq active (gnus-activate-group g)
+           (setq active (or (and dont-check
+                                 (gnus-active g))
+                            (gnus-activate-group g))
                  min (car active)
                  max (cdr active))
            (when (and active (>= max min) (not (zerop max)))
@@ -717,7 +706,7 @@ based on the marks on the component groups."
                    tot (+ tot size)
                    M (max M size))))
          nnvirtual-component-groups)
-    
+
     ;; Number of articles in the virtual group.
     (setq nnvirtual-mapping-len tot)
 
@@ -812,5 +801,4 @@ based on the marks on the component groups."
 
 (provide 'nnvirtual)
 
-;;; arch-tag: ca8c8ad9-1bd8-4b0f-9722-90dc645a45f5
 ;;; nnvirtual.el ends here