annotate lisp/gnus/nnweb.el @ 110534:826d60163924

Merge changes from emacs-23 branch.
author Chong Yidong <cyd@stupidchicken.com>
date Thu, 23 Sep 2010 22:10:54 -0400
parents 4d2f8b81bb01
children 7aa4fdb60d57
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
1 ;;; nnweb.el --- retrieving articles via web search engines
64754
fafd692d1e40 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64085
diff changeset
2
fafd692d1e40 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64085
diff changeset
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
4 ;; 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
5
24357
15fc6acbae7a Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 23584
diff changeset
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
7 ;; Keywords: news
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
8
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
10
94662
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93722
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
94662
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93722
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93722
diff changeset
14 ;; (at your option) any later version.
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
15
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
20
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
94662
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93722
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
23
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
24 ;;; Commentary:
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
25
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
26 ;; Note: You need to have `w3' installed for some functions to work.
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
27
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
28 ;;; Code:
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
29
19521
6f6cf9184e93 Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents: 17493
diff changeset
30 (eval-when-compile (require 'cl))
6f6cf9184e93 Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents: 17493
diff changeset
31
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
32 (require 'nnoo)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
33 (require 'message)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
34 (require 'gnus-util)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
35 (require 'gnus)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
36 (require 'nnmail)
31716
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
37 (require 'mm-util)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
38 (require 'mm-url)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
39 (eval-and-compile
23214
f075bf0ae873 (require): Wrap requirement of w3 and url in
Dave Love <fx@gnu.org>
parents: 19969
diff changeset
40 (ignore-errors
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
41 (require 'url)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
42 (autoload 'w3-parse-buffer "w3-parse")
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
43
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
44 (nnoo-declare nnweb)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
45
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
46 (defvoo nnweb-directory (nnheader-concat gnus-directory "nnweb/")
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
47 "Where nnweb will save its files.")
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
48
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
49 (defvoo nnweb-type 'google
24357
15fc6acbae7a Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 23584
diff changeset
50 "What search engine type is being used.
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
51 Valid types include `google', `dejanews', and `gmane'.")
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
52
31716
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
53 (defvar nnweb-type-definition
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
54 '((google
65342
c71b1b2d2d04 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-530
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
55 (id . "http://www.google.com/groups?as_umsgid=%s&hl=en&dmode=source")
68521
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
56 (result . "http://groups.google.com/group/%s/msg/%s?dmode=source")
65342
c71b1b2d2d04 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-530
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
57 (article . nnweb-google-wash-article)
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
58 (reference . identity)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
59 (map . nnweb-google-create-mapping)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
60 (search . nnweb-google-search)
65342
c71b1b2d2d04 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-530
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
61 (address . "http://groups.google.com/groups")
c71b1b2d2d04 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-530
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
62 (base . "http://groups.google.com")
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
63 (identifier . nnweb-google-identity))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
64 (dejanews ;; alias of google
68521
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
65 (id . "http://www.google.com/groups?as_umsgid=%s&hl=en&dmode=source")
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
66 (result . "http://groups.google.com/group/%s/msg/%s?dmode=source")
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
67 (article . nnweb-google-wash-article)
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
68 (reference . identity)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
69 (map . nnweb-google-create-mapping)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
70 (search . nnweb-google-search)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
71 (address . "http://groups.google.com/groups")
60390
d8ddb2b48062 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-155
Miles Bader <miles@gnu.org>
parents: 60356
diff changeset
72 (base . "http://groups.google.com")
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
73 (identifier . nnweb-google-identity))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
74 (gmane
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
75 (article . nnweb-gmane-wash-article)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
76 (id . "http://gmane.org/view.php?group=%s")
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
77 (reference . identity)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
78 (map . nnweb-gmane-create-mapping)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
79 (search . nnweb-gmane-search)
69247
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
80 (address . "http://search.gmane.org/nov.php")
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
81 (identifier . nnweb-gmane-identity)))
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
82 "Type-definition alist.")
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
83
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
84 (defvoo nnweb-search nil
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
85 "Search string to feed to Google.")
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
86
24357
15fc6acbae7a Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 23584
diff changeset
87 (defvoo nnweb-max-hits 999
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
88 "Maximum number of hits to display.")
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
89
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
90 (defvoo nnweb-ephemeral-p nil
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
91 "Whether this nnweb server is ephemeral.")
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
92
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
93 ;;; Internal variables
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
94
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
95 (defvoo nnweb-articles nil)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
96 (defvoo nnweb-buffer nil)
69247
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
97 (defvoo nnweb-group-alist nil)
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
98 (defvoo nnweb-group nil)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
99 (defvoo nnweb-hashtb nil)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
100
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
101 ;;; Interface functions
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
102
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
103 (nnoo-define-basics nnweb)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
104
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
105 (deffoo nnweb-retrieve-headers (articles &optional group server fetch-old)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
106 (nnweb-possibly-change-server group server)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
107 (with-current-buffer nntp-server-buffer
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
108 (erase-buffer)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
109 (let (article header)
31716
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
110 (mm-with-unibyte-current-buffer
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
111 (while (setq article (pop articles))
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
112 (when (setq header (cadr (assq article nnweb-articles)))
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
113 (nnheader-insert-nov header))))
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
114 'nov)))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
115
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
116 (deffoo nnweb-request-scan (&optional group server)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
117 (nnweb-possibly-change-server group server)
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
118 (if nnweb-ephemeral-p
68521
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
119 (setq nnweb-hashtb (gnus-make-hashtable 4095))
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
120 (unless nnweb-articles
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
121 (nnweb-read-overview group)))
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
122 (funcall (nnweb-definition 'map))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
123 (unless nnweb-ephemeral-p
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
124 (nnweb-write-active)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
125 (nnweb-write-overview group)))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
126
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110410
diff changeset
127 (deffoo nnweb-request-group (group &optional server dont-check info)
68521
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
128 (nnweb-possibly-change-server group server)
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
129 (unless (or nnweb-ephemeral-p
68606
5ea0e0a7dd38 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-42
Miles Bader <miles@gnu.org>
parents: 68521
diff changeset
130 dont-check
5ea0e0a7dd38 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-42
Miles Bader <miles@gnu.org>
parents: 68521
diff changeset
131 nnweb-articles)
68521
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
132 (nnweb-read-overview group))
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
133 (cond
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
134 ((not nnweb-articles)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
135 (nnheader-report 'nnweb "No matching articles"))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
136 (t
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
137 (let ((active (if nnweb-ephemeral-p
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
138 (cons (caar nnweb-articles)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
139 (caar (last nnweb-articles)))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
140 (cadr (assoc group nnweb-group-alist)))))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
141 (nnheader-report 'nnweb "Opened group %s" group)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
142 (nnheader-insert
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
143 "211 %d %d %d %s\n" (length nnweb-articles)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
144 (car active) (cdr active) group)))))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
145
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
146 (deffoo nnweb-close-group (group &optional server)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
147 (nnweb-possibly-change-server group server)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
148 (when (gnus-buffer-live-p nnweb-buffer)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
149 (with-current-buffer nnweb-buffer
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
150 (set-buffer-modified-p nil)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
151 (kill-buffer nnweb-buffer)))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
152 t)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
153
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
154 (deffoo nnweb-request-article (article &optional group server buffer)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
155 (nnweb-possibly-change-server group server)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
156 (with-current-buffer (or buffer nntp-server-buffer)
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
157 (let* ((header (cadr (assq article nnweb-articles)))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
158 (url (and header (mail-header-xref header))))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
159 (when (or (and url
31716
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
160 (mm-with-unibyte-current-buffer
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
161 (mm-url-insert url)))
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
162 (and (stringp article)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
163 (nnweb-definition 'id t)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
164 (let ((fetch (nnweb-definition 'id))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
165 art active)
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
166 (when (string-match "^<\\(.*\\)>$" article)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
167 (setq art (match-string 1 article)))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
168 (when (and fetch art)
72009
e7287a023d2c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70245
diff changeset
169 (setq url (format fetch
e7287a023d2c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70245
diff changeset
170 (mm-url-form-encode-xwfu art)))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
171 (mm-with-unibyte-current-buffer
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
172 (mm-url-insert url))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
173 (if (nnweb-definition 'reference t)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
174 (setq article
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
175 (funcall (nnweb-definition
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
176 'reference) article)))))))
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
177 (unless nnheader-callback-function
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
178 (funcall (nnweb-definition 'article)))
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
179 (nnheader-report 'nnweb "Fetched article %s" article)
31716
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
180 (cons group (and (numberp article) article))))))
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
181
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
182 (deffoo nnweb-close-server (&optional server)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
183 (when (and (nnweb-server-opened server)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
184 (gnus-buffer-live-p nnweb-buffer))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
185 (with-current-buffer nnweb-buffer
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
186 (set-buffer-modified-p nil)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
187 (kill-buffer nnweb-buffer)))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
188 (nnoo-close-server 'nnweb server))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
189
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
190 (deffoo nnweb-request-list (&optional server)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
191 (nnweb-possibly-change-server nil server)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
192 (with-current-buffer nntp-server-buffer
68521
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
193 (nnmail-generate-active (list (assoc server nnweb-group-alist)))
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
194 t))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
195
110516
4d2f8b81bb01 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110422
diff changeset
196 (deffoo nnweb-request-update-info (group info &optional server))
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
197
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
198 (deffoo nnweb-asynchronous-p ()
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
199 nil)
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
200
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
201 (deffoo nnweb-request-create-group (group &optional server args)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
202 (nnweb-possibly-change-server nil server)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
203 (nnweb-request-delete-group group)
68521
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
204 (push `(,group ,(cons 1 0)) nnweb-group-alist)
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
205 (nnweb-write-active)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
206 t)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
207
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
208 (deffoo nnweb-request-delete-group (group &optional force server)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
209 (nnweb-possibly-change-server group server)
31716
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
210 (gnus-pull group nnweb-group-alist t)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
211 (nnweb-write-active)
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
212 (gnus-delete-file (nnweb-overview-file group))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
213 t)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
214
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
215 (nnoo-define-skeleton nnweb)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
216
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
217 ;;; Internal functions
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
218
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
219 (defun nnweb-read-overview (group)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
220 "Read the overview of GROUP and build the map."
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
221 (when (file-exists-p (nnweb-overview-file group))
31716
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
222 (mm-with-unibyte-buffer
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
223 (nnheader-insert-file-contents (nnweb-overview-file group))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
224 (goto-char (point-min))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
225 (let (header)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
226 (while (not (eobp))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
227 (setq header (nnheader-parse-nov))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
228 (forward-line 1)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
229 (push (list (mail-header-number header)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
230 header (mail-header-xref header))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
231 nnweb-articles)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
232 (nnweb-set-hashtb header (car nnweb-articles)))))))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
233
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
234 (defun nnweb-write-overview (group)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
235 "Write the overview file for GROUP."
31716
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
236 (with-temp-file (nnweb-overview-file group)
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
237 (let ((articles nnweb-articles))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
238 (while articles
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
239 (nnheader-insert-nov (cadr (pop articles)))))))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
240
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
241 (defun nnweb-set-hashtb (header data)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
242 (gnus-sethash (nnweb-identifier (mail-header-xref header))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
243 data nnweb-hashtb))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
244
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
245 (defun nnweb-get-hashtb (url)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
246 (gnus-gethash (nnweb-identifier url) nnweb-hashtb))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
247
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
248 (defun nnweb-identifier (ident)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
249 (funcall (nnweb-definition 'identifier) ident))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
250
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
251 (defun nnweb-overview-file (group)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
252 "Return the name of the overview file of GROUP."
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
253 (nnheader-concat nnweb-directory group ".overview"))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
254
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
255 (defun nnweb-write-active ()
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
256 "Save the active file."
31716
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
257 (gnus-make-directory nnweb-directory)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
258 (with-temp-file (nnheader-concat nnweb-directory "active")
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
259 (prin1 `(setq nnweb-group-alist ',nnweb-group-alist) (current-buffer))))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
260
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
261 (defun nnweb-read-active ()
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
262 "Read the active file."
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
263 (load (nnheader-concat nnweb-directory "active") t t t))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
264
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
265 (defun nnweb-definition (type &optional noerror)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
266 "Return the definition of TYPE."
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
267 (let ((def (cdr (assq type (assq nnweb-type nnweb-type-definition)))))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
268 (when (and (not def)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
269 (not noerror))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
270 (error "Undefined definition %s" type))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
271 def))
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
272
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
273 (defun nnweb-possibly-change-server (&optional group server)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
274 (when server
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
275 (unless (nnweb-server-opened server)
68521
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
276 (nnweb-open-server server))
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
277 (nnweb-init server))
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
278 (unless nnweb-group-alist
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
279 (nnweb-read-active))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
280 (unless nnweb-hashtb
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
281 (setq nnweb-hashtb (gnus-make-hashtable 4095)))
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
282 (when group
68521
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
283 (setq nnweb-group group)))
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
284
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
285 (defun nnweb-init (server)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
286 "Initialize buffers and such."
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
287 (unless (gnus-buffer-live-p nnweb-buffer)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
288 (setq nnweb-buffer
93722
ac376173ee3d (nnweb-init): Avoid nn-with-unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92776
diff changeset
289 (save-current-buffer
ac376173ee3d (nnweb-init): Avoid nn-with-unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92776
diff changeset
290 (nnheader-set-temp-buffer
ac376173ee3d (nnweb-init): Avoid nn-with-unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92776
diff changeset
291 (format " *nnweb %s %s %s*"
ac376173ee3d (nnweb-init): Avoid nn-with-unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92776
diff changeset
292 nnweb-type nnweb-search server))
ac376173ee3d (nnweb-init): Avoid nn-with-unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92776
diff changeset
293 (mm-disable-multibyte)
ac376173ee3d (nnweb-init): Avoid nn-with-unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92776
diff changeset
294 (current-buffer)))))
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
295
31716
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
296 ;;;
65342
c71b1b2d2d04 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-530
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
297 ;;; groups.google.com
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
298 ;;;
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
299
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
300 (defun nnweb-google-wash-article ()
65342
c71b1b2d2d04 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-530
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
301 ;; We have Google's masked e-mail addresses here. :-/
69247
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
302 (let ((case-fold-search t)
70245
322c5c5027dc Revision: emacs@sv.gnu.org/emacs--devo--0--patch-249
Miles Bader <miles@gnu.org>
parents: 69802
diff changeset
303 (start-re "<pre>[\r\n ]*")
322c5c5027dc Revision: emacs@sv.gnu.org/emacs--devo--0--patch-249
Miles Bader <miles@gnu.org>
parents: 69802
diff changeset
304 (end-re "[\r\n ]*</pre>"))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
305 (goto-char (point-min))
65388
45be648405bb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-536
Miles Bader <miles@gnu.org>
parents: 65342
diff changeset
306 (if (save-excursion
45be648405bb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-536
Miles Bader <miles@gnu.org>
parents: 65342
diff changeset
307 (or (re-search-forward "The requested message.*could not be found."
45be648405bb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-536
Miles Bader <miles@gnu.org>
parents: 65342
diff changeset
308 nil t)
69247
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
309 (not (and (re-search-forward start-re nil t)
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
310 (re-search-forward end-re nil t)))))
65388
45be648405bb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-536
Miles Bader <miles@gnu.org>
parents: 65342
diff changeset
311 ;; FIXME: Don't know how to indicate "not found".
45be648405bb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-536
Miles Bader <miles@gnu.org>
parents: 65342
diff changeset
312 ;; Should this function throw an error? --rsteib
45be648405bb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-536
Miles Bader <miles@gnu.org>
parents: 65342
diff changeset
313 (progn
45be648405bb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-536
Miles Bader <miles@gnu.org>
parents: 65342
diff changeset
314 (gnus-message 3 "Requested article not found")
45be648405bb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-536
Miles Bader <miles@gnu.org>
parents: 65342
diff changeset
315 (erase-buffer))
45be648405bb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-536
Miles Bader <miles@gnu.org>
parents: 65342
diff changeset
316 (delete-region (point-min)
69247
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
317 (re-search-forward start-re))
65388
45be648405bb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-536
Miles Bader <miles@gnu.org>
parents: 65342
diff changeset
318 (goto-char (point-min))
69247
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
319 (delete-region (progn
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
320 (re-search-forward end-re)
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
321 (match-beginning 0))
65388
45be648405bb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-536
Miles Bader <miles@gnu.org>
parents: 65342
diff changeset
322 (point-max))
45be648405bb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-536
Miles Bader <miles@gnu.org>
parents: 65342
diff changeset
323 (mm-url-decode-entities))))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
324
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
325 (defun nnweb-google-parse-1 (&optional Message-ID)
68521
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
326 "Parse search result in current buffer."
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
327 (let ((i 0)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
328 (case-fold-search t)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
329 (active (cadr (assoc nnweb-group nnweb-group-alist)))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
330 Subject Score Date Newsgroups From
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
331 map url mid)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
332 (unless active
68521
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
333 (push (list nnweb-group (setq active (cons 1 0)))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
334 nnweb-group-alist))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
335 ;; Go through all the article hits on this page.
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
336 (goto-char (point-min))
68521
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
337 (while
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
338 (re-search-forward
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
339 "a +href=\"/group/\\([^>\"]+\\)/browse_thread/[^>]+#\\([0-9a-f]+\\)"
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
340 nil t)
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
341 (setq Newsgroups (match-string-no-properties 1)
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
342 ;; Note: Starting with Google Groups 2, `mid' is a Google-internal
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
343 ;; ID, not a proper Message-ID.
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
344 mid (match-string-no-properties 2)
47934
79f5c0e65980 (nnweb-dejanews-create-mapping, nnweb-reference-create-mapping,
Juanma Barranquero <lekktu@gmail.com>
parents: 40542
diff changeset
345 url (format
68521
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
346 (nnweb-definition 'result) Newsgroups mid))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
347 (narrow-to-region (search-forward ">" nil t)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
348 (search-forward "</a>" nil t))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
349 (mm-url-remove-markup)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
350 (mm-url-decode-entities)
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
351 (setq Subject (buffer-string))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
352 (goto-char (point-max))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
353 (widen)
68521
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
354 (narrow-to-region (point)
75678
17f71e8e8472 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
355 (search-forward "</table" nil t))
68521
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
356
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
357 (mm-url-remove-markup)
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
358 (mm-url-decode-entities)
75678
17f71e8e8472 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
359 (goto-char (point-max))
17f71e8e8472 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
360 (when
17f71e8e8472 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
361 (re-search-backward
92359
1af6d6eab2e9 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87649
diff changeset
362 "^\\(?:\\(\\w+\\) \\([0-9]+\\)\\|\\S-+\\)\\(?: \\([0-9]\\{4\\}\\)\\)? by ?\\(.*\\)"
75678
17f71e8e8472 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
363 nil t)
76001
73e575b86f8a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75678
diff changeset
364 (setq Date (if (match-string 1)
73e575b86f8a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75678
diff changeset
365 (format "%s %s 00:00:00 %s"
73e575b86f8a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75678
diff changeset
366 (match-string 1)
73e575b86f8a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75678
diff changeset
367 (match-string 2)
73e575b86f8a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75678
diff changeset
368 (or (match-string 3)
73e575b86f8a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75678
diff changeset
369 (substring (current-time-string) -4)))
73e575b86f8a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75678
diff changeset
370 (current-time-string)))
75678
17f71e8e8472 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
371 (setq From (match-string 4)))
68521
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
372 (widen)
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
373 (incf i)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
374 (unless (nnweb-get-hashtb url)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
375 (push
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
376 (list
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
377 (incf (cdr active))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
378 (make-full-mail-header
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
379 (cdr active) (if Newsgroups
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
380 (concat "(" Newsgroups ") " Subject)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
381 Subject)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
382 From Date (or Message-ID mid)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
383 nil 0 0 url))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
384 map)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
385 (nnweb-set-hashtb (cadar map) (car map))))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
386 map))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
387
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
388 (defun nnweb-google-reference (id)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
389 (let ((map (nnweb-google-parse-1 id)) header)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
390 (setq nnweb-articles
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
391 (nconc nnweb-articles map))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
392 (when (setq header (cadar map))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
393 (mm-with-unibyte-current-buffer
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
394 (mm-url-insert (mail-header-xref header)))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
395 (caar map))))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
396
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
397 (defun nnweb-google-create-mapping ()
47934
79f5c0e65980 (nnweb-dejanews-create-mapping, nnweb-reference-create-mapping,
Juanma Barranquero <lekktu@gmail.com>
parents: 40542
diff changeset
398 "Perform the search and create a number-to-url alist."
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
399 (with-current-buffer nnweb-buffer
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
400 (erase-buffer)
69247
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
401 (nnheader-message 7 "Searching google...")
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
402 (when (funcall (nnweb-definition 'search) nnweb-search)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
403 (let ((more t)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
404 (i 0))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
405 (while more
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
406 (setq nnweb-articles
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
407 (nconc nnweb-articles (nnweb-google-parse-1)))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
408 ;; Check if there are more articles to fetch
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
409 (goto-char (point-min))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
410 (incf i 100)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
411 (if (or (not (re-search-forward
72084
002ee31c5102 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 72009
diff changeset
412 "<a [^>]+href=\"\n?\\([^>\" \n\t]+\\)[^<]*<img[^>]+src=[^>]+next"
69247
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
413 nil t))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
414 (>= i nnweb-max-hits))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
415 (setq more nil)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
416 ;; Yup, there are more articles
60390
d8ddb2b48062 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-155
Miles Bader <miles@gnu.org>
parents: 60356
diff changeset
417 (setq more (concat (nnweb-definition 'base) (match-string 1)))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
418 (when more
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
419 (erase-buffer)
69247
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
420 (nnheader-message 7 "Searching google...(%d)" i)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
421 (mm-url-insert more))))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
422 ;; Return the articles in the right order.
69247
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
423 (nnheader-message 7 "Searching google...done")
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
424 (setq nnweb-articles
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
425 (sort nnweb-articles 'car-less-than-car))))))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
426
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
427 (defun nnweb-google-search (search)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
428 (mm-url-insert
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
429 (concat
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
430 (nnweb-definition 'address)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
431 "?"
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
432 (mm-url-encode-www-form-urlencoded
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
433 `(("q" . ,search)
72009
e7287a023d2c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70245
diff changeset
434 ("num" . ,(number-to-string
e7287a023d2c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70245
diff changeset
435 (min 100 nnweb-max-hits)))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
436 ("hq" . "")
60390
d8ddb2b48062 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-155
Miles Bader <miles@gnu.org>
parents: 60356
diff changeset
437 ("hl" . "en")
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
438 ("lr" . "")
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
439 ("safe" . "off")
68521
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
440 ("sites" . "groups")
04c2548593f7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-33
Miles Bader <miles@gnu.org>
parents: 65388
diff changeset
441 ("filter" . "0")))))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
442 t)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
443
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
444 (defun nnweb-google-identity (url)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
445 "Return an unique identifier based on URL."
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
446 (if (string-match "selm=\\([^ &>]+\\)" url)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
447 (match-string 1 url)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
448 url))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
449
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 33322
diff changeset
450 ;;;
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
451 ;;; gmane.org
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
452 ;;;
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
453 (defun nnweb-gmane-create-mapping ()
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
454 "Perform the search and create a number-to-url alist."
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
455 (with-current-buffer nnweb-buffer
69247
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
456 (let ((case-fold-search t)
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
457 (active (or (cadr (assoc nnweb-group nnweb-group-alist))
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
458 (cons 1 0)))
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
459 map)
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
460 (erase-buffer)
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
461 (nnheader-message 7 "Searching Gmane..." )
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
462 (when (funcall (nnweb-definition 'search) nnweb-search)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
463 (goto-char (point-min))
69247
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
464 ;; Skip the status line
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
465 (forward-line 1)
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
466 ;; Thanks to Olly Betts we now have NOV lines in our buffer!
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
467 (while (not (eobp))
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
468 (unless (or (eolp) (looking-at "\x0d"))
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
469 (let ((header (nnheader-parse-nov)))
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
470 (let ((xref (mail-header-xref header))
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
471 (from (mail-header-from header))
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
472 (subject (mail-header-subject header))
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
473 (rfc2047-encoding-type 'mime))
75149
0fd7f29f20d1 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 72425
diff changeset
474 (when (string-match " \\([^:]+\\)[:/]\\([0-9]+\\)" xref)
69247
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
475 (mail-header-set-xref
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
476 header
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
477 (format "http://article.gmane.org/%s/%s/raw"
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
478 (match-string 1 xref)
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
479 (match-string 2 xref))))
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
480
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
481 ;; Add host part to gmane-encrypted addresses
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
482 (when (string-match "@$" from)
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
483 (mail-header-set-from header
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
484 (concat from "public.gmane.org")))
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
485
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
486 (mail-header-set-subject header
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
487 (rfc2047-encode-string subject))
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
488
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
489 (unless (nnweb-get-hashtb (mail-header-xref header))
75149
0fd7f29f20d1 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 72425
diff changeset
490 (mail-header-set-number header (incf (cdr active)))
0fd7f29f20d1 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 72425
diff changeset
491 (push (list (mail-header-number header) header) map)
69247
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
492 (nnweb-set-hashtb (cadar map) (car map))))))
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
493 (forward-line 1)))
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
494 (nnheader-message 7 "Searching Gmane...done")
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
495 (setq nnweb-articles
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
496 (sort (nconc nnweb-articles map) 'car-less-than-car)))))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
497
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
498 (defun nnweb-gmane-wash-article ()
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
499 (let ((case-fold-search t))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
500 (goto-char (point-min))
69247
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
501 (when (search-forward "<!--X-Head-of-Message-->" nil t)
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
502 (delete-region (point-min) (point))
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
503 (goto-char (point-min))
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
504 (while (looking-at "^<li><em>\\([^ ]+\\)</em>.*</li>")
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
505 (replace-match "\\1\\2" t)
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
506 (forward-line 1))
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
507 (mm-url-remove-markup))))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
508
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
509 (defun nnweb-gmane-search (search)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
510 (mm-url-insert
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
511 (concat
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
512 (nnweb-definition 'address)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
513 "?"
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
514 (mm-url-encode-www-form-urlencoded
69247
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
515 `(("query" . ,search)
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
516 ("HITSPERPAGE" . ,(number-to-string nnweb-max-hits))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
517 ;;("TOPDOC" . "1000")
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
518 ))))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
519 (setq buffer-file-name nil)
108287
c0d13767677a Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 106815
diff changeset
520 (unless (featurep 'xemacs) (set-buffer-multibyte t))
69247
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 68606
diff changeset
521 (mm-decode-coding-region (point-min) (point-max) 'utf-8)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
522 t)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
523
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
524 (defun nnweb-gmane-identity (url)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
525 "Return a unique identifier based on URL."
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
526 (if (string-match "group=\\(.+\\)" url)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
527 (match-string 1 url)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
528 url))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
529
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
530 ;;;
31716
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
531 ;;; General web/w3 interface utility functions
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
532 ;;;
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
533
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
534 (defun nnweb-insert-html (parse)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
535 "Insert HTML based on a w3 parse tree."
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
536 (if (stringp parse)
92776
cb44c6d29ee0 (nnweb-insert-html): Remove use of nnheader-string-as-multibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92359
diff changeset
537 ;; We used to call nnheader-string-as-multibyte here, but it cannot
cb44c6d29ee0 (nnweb-insert-html): Remove use of nnheader-string-as-multibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92359
diff changeset
538 ;; be right, so I removed it. If a bug shows up because of this change,
cb44c6d29ee0 (nnweb-insert-html): Remove use of nnheader-string-as-multibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92359
diff changeset
539 ;; please do not blindly revert the change, but help me find the real
cb44c6d29ee0 (nnweb-insert-html): Remove use of nnheader-string-as-multibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92359
diff changeset
540 ;; cause of the bug instead. --Stef
cb44c6d29ee0 (nnweb-insert-html): Remove use of nnheader-string-as-multibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92359
diff changeset
541 (insert parse)
31716
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
542 (insert "<" (symbol-name (car parse)) " ")
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
543 (insert (mapconcat
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
544 (lambda (param)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
545 (concat (symbol-name (car param)) "="
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
546 (prin1-to-string
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
547 (if (consp (cdr param))
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
548 (cadr param)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
549 (cdr param)))))
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
550 (nth 1 parse)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
551 " "))
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
552 (insert ">\n")
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
553 (mapc 'nnweb-insert-html (nth 2 parse))
31716
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
554 (insert "</" (symbol-name (car parse)) ">\n")))
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
555
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
556 (defun nnweb-parse-find (type parse &optional maxdepth)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
557 "Find the element of TYPE in PARSE."
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
558 (catch 'found
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
559 (nnweb-parse-find-1 type parse maxdepth)))
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
560
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
561 (defun nnweb-parse-find-1 (type contents maxdepth)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
562 (when (or (null maxdepth)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
563 (not (zerop maxdepth)))
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
564 (when (consp contents)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
565 (when (eq (car contents) type)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
566 (throw 'found contents))
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
567 (when (listp (cdr contents))
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
568 (dolist (element contents)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
569 (when (consp element)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
570 (nnweb-parse-find-1 type element
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
571 (and maxdepth (1- maxdepth)))))))))
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
572
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
573 (defun nnweb-parse-find-all (type parse)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
574 "Find all elements of TYPE in PARSE."
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
575 (catch 'found
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
576 (nnweb-parse-find-all-1 type parse)))
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
577
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
578 (defun nnweb-parse-find-all-1 (type contents)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
579 (let (result)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
580 (when (consp contents)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
581 (if (eq (car contents) type)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
582 (push contents result)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
583 (when (listp (cdr contents))
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
584 (dolist (element contents)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
585 (when (consp element)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
586 (setq result
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
587 (nconc result (nnweb-parse-find-all-1 type element))))))))
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
588 result))
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
589
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
590 (defvar nnweb-text)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
591 (defun nnweb-text (parse)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
592 "Return a list of text contents in PARSE."
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
593 (let ((nnweb-text nil))
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
594 (nnweb-text-1 parse)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
595 (nreverse nnweb-text)))
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
596
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
597 (defun nnweb-text-1 (contents)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
598 (dolist (element contents)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
599 (if (stringp element)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
600 (push element nnweb-text)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
601 (when (and (consp element)
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
602 (listp (cdr element)))
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
603 (nnweb-text-1 element)))))
9968f55ad26e Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents: 24357
diff changeset
604
17493
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
605 (provide 'nnweb)
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
606
e6935c08cf0b Initial revision
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
607 ;;; nnweb.el ends here