Mercurial > emacs
annotate lisp/gnus/gnus-int.el @ 88155:d7ddb3e565de
sync with trunk
author | Henrik Enberg <henrik.enberg@telia.com> |
---|---|
date | Mon, 16 Jan 2006 00:03:54 +0000 |
parents | 139404e9298a |
children |
rev | line source |
---|---|
17493 | 1 ;;; gnus-int.el --- backend interface functions for Gnus |
88155 | 2 |
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 | |
4 ;; 2005 Free Software Foundation, Inc. | |
17493 | 5 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
17493 | 7 ;; Keywords: news |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
88155 | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02110-1301, USA. | |
17493 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;;; Code: | |
29 | |
19531
f5b98be7c142
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
30 (eval-when-compile (require 'cl)) |
f5b98be7c142
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
31 |
17493 | 32 (require 'gnus) |
88155 | 33 (require 'message) |
34 (require 'gnus-range) | |
35 | |
36 (autoload 'gnus-agent-expire "gnus-agent") | |
37 (autoload 'gnus-agent-regenerate-group "gnus-agent") | |
38 (autoload 'gnus-agent-read-servers-validate-native "gnus-agent") | |
17493 | 39 |
40 (defcustom gnus-open-server-hook nil | |
41 "Hook called just before opening connection to the news server." | |
42 :group 'gnus-start | |
43 :type 'hook) | |
44 | |
88155 | 45 (defcustom gnus-server-unopen-status nil |
46 "The default status if the server is not able to open. | |
47 If the server is covered by Gnus agent, the possible values are | |
48 `denied', set the server denied; `offline', set the server offline; | |
49 nil, ask user. If the server is not covered by Gnus agent, set the | |
50 server denied." | |
51 :version "22.1" | |
52 :group 'gnus-start | |
53 :type '(choice (const :tag "Ask" nil) | |
54 (const :tag "Deny server" denied) | |
55 (const :tag "Unplug Agent" offline))) | |
56 | |
57 (defvar gnus-internal-registry-spool-current-method nil | |
58 "The current method, for the registry.") | |
59 | |
17493 | 60 ;;; |
61 ;;; Server Communication | |
62 ;;; | |
63 | |
64 (defun gnus-start-news-server (&optional confirm) | |
65 "Open a method for getting news. | |
66 If CONFIRM is non-nil, the user will be asked for an NNTP server." | |
67 (let (how) | |
68 (if gnus-current-select-method | |
69 ;; Stream is already opened. | |
70 nil | |
71 ;; Open NNTP server. | |
72 (unless gnus-nntp-service | |
73 (setq gnus-nntp-server nil)) | |
74 (when confirm | |
75 ;; Read server name with completion. | |
76 (setq gnus-nntp-server | |
77 (completing-read "NNTP server: " | |
78 (mapcar (lambda (server) (list server)) | |
79 (cons (list gnus-nntp-server) | |
80 gnus-secondary-servers)) | |
81 nil nil gnus-nntp-server))) | |
82 | |
83 (when (and gnus-nntp-server | |
84 (stringp gnus-nntp-server) | |
85 (not (string= gnus-nntp-server ""))) | |
86 (setq gnus-select-method | |
87 (cond ((or (string= gnus-nntp-server "") | |
88 (string= gnus-nntp-server "::")) | |
89 (list 'nnspool (system-name))) | |
90 ((string-match "^:" gnus-nntp-server) | |
91 (list 'nnmh gnus-nntp-server | |
92 (list 'nnmh-directory | |
93 (file-name-as-directory | |
94 (expand-file-name | |
33377
e16be74deee2
(gnus-start-news-server): Use expand-file-name, not
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
95 (substring gnus-nntp-server 1) "~/"))) |
17493 | 96 (list 'nnmh-get-new-mail nil))) |
97 (t | |
98 (list 'nntp gnus-nntp-server))))) | |
99 | |
100 (setq how (car gnus-select-method)) | |
101 (cond | |
102 ((eq how 'nnspool) | |
103 (require 'nnspool) | |
104 (gnus-message 5 "Looking up local news spool...")) | |
105 ((eq how 'nnmh) | |
106 (require 'nnmh) | |
107 (gnus-message 5 "Looking up mh spool...")) | |
108 (t | |
109 (require 'nntp))) | |
110 (setq gnus-current-select-method gnus-select-method) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
111 (gnus-run-hooks 'gnus-open-server-hook) |
88155 | 112 |
113 ;; Partially validate agent covered methods now that the | |
114 ;; gnus-select-method is known. | |
115 | |
116 (if gnus-agent | |
117 ;; NOTE: This is here for one purpose only. By validating | |
118 ;; the current select method, it converts the old 5.10.3, | |
119 ;; and earlier, format to the current format. That enables | |
120 ;; the agent code within gnus-open-server to function | |
121 ;; correctly. | |
122 (gnus-agent-read-servers-validate-native gnus-select-method)) | |
123 | |
17493 | 124 (or |
125 ;; gnus-open-server-hook might have opened it | |
126 (gnus-server-opened gnus-select-method) | |
127 (gnus-open-server gnus-select-method) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
128 gnus-batch-mode |
17493 | 129 (gnus-y-or-n-p |
130 (format | |
131 "%s (%s) open error: '%s'. Continue? " | |
132 (car gnus-select-method) (cadr gnus-select-method) | |
133 (gnus-status-message gnus-select-method))) | |
134 (gnus-error 1 "Couldn't open server on %s" | |
135 (nth 1 gnus-select-method)))))) | |
136 | |
137 (defun gnus-check-group (group) | |
138 "Try to make sure that the server where GROUP exists is alive." | |
139 (let ((method (gnus-find-method-for-group group))) | |
140 (or (gnus-server-opened method) | |
141 (gnus-open-server method)))) | |
142 | |
143 (defun gnus-check-server (&optional method silent) | |
144 "Check whether the connection to METHOD is down. | |
145 If METHOD is nil, use `gnus-select-method'. | |
146 If it is down, start it up (again)." | |
88155 | 147 (let ((method (or method gnus-select-method)) |
148 result) | |
17493 | 149 ;; Transform virtual server names into select methods. |
150 (when (stringp method) | |
151 (setq method (gnus-server-to-method method))) | |
152 (if (gnus-server-opened method) | |
153 ;; The stream is already opened. | |
154 t | |
155 ;; Open the server. | |
156 (unless silent | |
157 (gnus-message 5 "Opening %s server%s..." (car method) | |
158 (if (equal (nth 1 method) "") "" | |
159 (format " on %s" (nth 1 method))))) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
160 (gnus-run-hooks 'gnus-open-server-hook) |
17493 | 161 (prog1 |
88155 | 162 (condition-case () |
163 (setq result (gnus-open-server method)) | |
164 (quit (message "Quit gnus-check-server") | |
165 nil)) | |
17493 | 166 (unless silent |
88155 | 167 (gnus-message 5 "Opening %s server%s...%s" (car method) |
168 (if (equal (nth 1 method) "") "" | |
169 (format " on %s" (nth 1 method))) | |
170 (if result "done" "failed"))))))) | |
17493 | 171 |
172 (defun gnus-get-function (method function &optional noerror) | |
173 "Return a function symbol based on METHOD and FUNCTION." | |
174 ;; Translate server names into methods. | |
175 (unless method | |
176 (error "Attempted use of a nil select method")) | |
177 (when (stringp method) | |
178 (setq method (gnus-server-to-method method))) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
179 ;; Check cache of constructed names. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
180 (let* ((method-sym (if gnus-agent |
88155 | 181 (inline (gnus-agent-get-function method)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
182 (car method))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
183 (method-fns (get method-sym 'gnus-method-functions)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
184 (func (let ((method-fnlist-elt (assq function method-fns))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
185 (unless method-fnlist-elt |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
186 (setq method-fnlist-elt |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
187 (cons function |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
188 (intern (format "%s-%s" method-sym function)))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
189 (put method-sym 'gnus-method-functions |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
190 (cons method-fnlist-elt method-fns))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
191 (cdr method-fnlist-elt)))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
192 ;; Maybe complain if there is no function. |
17493 | 193 (unless (fboundp func) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
194 (unless (car method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
195 (error "Trying to require a method that doesn't exist")) |
17493 | 196 (require (car method)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
197 (when (not (fboundp func)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
198 (if noerror |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
199 (setq func nil) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
200 (error "No such function: %s" func)))) |
17493 | 201 func)) |
202 | |
203 | |
204 ;;; | |
205 ;;; Interface functions to the backends. | |
206 ;;; | |
207 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
208 (defun gnus-open-server (gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
209 "Open a connection to GNUS-COMMAND-METHOD." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
210 (when (stringp gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
211 (setq gnus-command-method (gnus-server-to-method gnus-command-method))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
212 (let ((elem (assoc gnus-command-method gnus-opened-servers))) |
17493 | 213 ;; If this method was previously denied, we just return nil. |
214 (if (eq (nth 1 elem) 'denied) | |
215 (progn | |
216 (gnus-message 1 "Denied server") | |
217 nil) | |
218 ;; Open the server. | |
88155 | 219 (let* ((open-server-function (gnus-get-function gnus-command-method 'open-server)) |
220 (result | |
221 (condition-case err | |
222 (funcall open-server-function | |
223 (nth 1 gnus-command-method) | |
224 (nthcdr 2 gnus-command-method)) | |
225 (error | |
226 (gnus-message 1 (format | |
227 "Unable to open server due to: %s" | |
228 (error-message-string err))) | |
229 nil) | |
230 (quit | |
231 (gnus-message 1 "Quit trying to open server") | |
232 nil))) | |
233 open-offline) | |
17493 | 234 ;; If this hasn't been opened before, we add it to the list. |
235 (unless elem | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
236 (setq elem (list gnus-command-method nil) |
17493 | 237 gnus-opened-servers (cons elem gnus-opened-servers))) |
238 ;; Set the status of this server. | |
88155 | 239 (setcar (cdr elem) |
240 (cond (result | |
241 (if (eq open-server-function #'nnagent-open-server) | |
242 ;; The agent's backend has a "special" status | |
243 'offline | |
244 'ok)) | |
245 ((and gnus-agent | |
246 (gnus-agent-method-p gnus-command-method)) | |
247 (cond (gnus-server-unopen-status | |
248 ;; Set the server's status to the unopen | |
249 ;; status. If that status is offline, | |
250 ;; recurse to open the agent's backend. | |
251 (setq open-offline (eq gnus-server-unopen-status 'offline)) | |
252 gnus-server-unopen-status) | |
253 ((gnus-y-or-n-p | |
254 (format "Unable to open %s:%s, go offline? " | |
255 (car gnus-command-method) | |
256 (cadr gnus-command-method))) | |
257 (setq open-offline t) | |
258 'offline) | |
259 (t | |
260 ;; This agentized server was still denied | |
261 'denied))) | |
262 (t | |
263 ;; This unagentized server must be denied | |
264 'denied))) | |
265 | |
266 ;; NOTE: I MUST set the server's status to offline before this | |
267 ;; recursive call as this status will drive the | |
268 ;; gnus-get-function (called above) to return the agent's | |
269 ;; backend. | |
270 (if open-offline | |
271 ;; Recursively open this offline server to perform the | |
272 ;; open-server function of the agent's backend. | |
273 (let ((gnus-server-unopen-status 'denied)) | |
274 ;; Bind gnus-server-unopen-status to avoid recursively | |
275 ;; prompting with "go offline?". This is only a concern | |
276 ;; when the agent's backend fails to open the server. | |
277 (gnus-open-server gnus-command-method)) | |
278 result))))) | |
17493 | 279 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
280 (defun gnus-close-server (gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
281 "Close the connection to GNUS-COMMAND-METHOD." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
282 (when (stringp gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
283 (setq gnus-command-method (gnus-server-to-method gnus-command-method))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
284 (funcall (gnus-get-function gnus-command-method 'close-server) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
285 (nth 1 gnus-command-method))) |
17493 | 286 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
287 (defun gnus-request-list (gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
288 "Request the active file from GNUS-COMMAND-METHOD." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
289 (when (stringp gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
290 (setq gnus-command-method (gnus-server-to-method gnus-command-method))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
291 (funcall (gnus-get-function gnus-command-method 'request-list) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
292 (nth 1 gnus-command-method))) |
17493 | 293 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
294 (defun gnus-request-list-newsgroups (gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
295 "Request the newsgroups file from GNUS-COMMAND-METHOD." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
296 (when (stringp gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
297 (setq gnus-command-method (gnus-server-to-method gnus-command-method))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
298 (funcall (gnus-get-function gnus-command-method 'request-list-newsgroups) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
299 (nth 1 gnus-command-method))) |
17493 | 300 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
301 (defun gnus-request-newgroups (date gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
302 "Request all new groups since DATE from GNUS-COMMAND-METHOD." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
303 (when (stringp gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
304 (setq gnus-command-method (gnus-server-to-method gnus-command-method))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
305 (let ((func (gnus-get-function gnus-command-method 'request-newgroups t))) |
17493 | 306 (when func |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
307 (funcall func date (nth 1 gnus-command-method))))) |
17493 | 308 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
309 (defun gnus-server-opened (gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
310 "Check whether a connection to GNUS-COMMAND-METHOD has been opened." |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
311 (unless (eq (gnus-server-status gnus-command-method) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
312 'denied) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
313 (when (stringp gnus-command-method) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
314 (setq gnus-command-method (gnus-server-to-method gnus-command-method))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
315 (funcall (inline (gnus-get-function gnus-command-method 'server-opened)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
316 (nth 1 gnus-command-method)))) |
17493 | 317 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
318 (defun gnus-status-message (gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
319 "Return the status message from GNUS-COMMAND-METHOD. |
88155 | 320 If GNUS-COMMAND-METHOD is a string, it is interpreted as a group |
321 name. The method this group uses will be queried." | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
322 (let ((gnus-command-method |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
323 (if (stringp gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
324 (gnus-find-method-for-group gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
325 gnus-command-method))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
326 (funcall (gnus-get-function gnus-command-method 'status-message) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
327 (nth 1 gnus-command-method)))) |
17493 | 328 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
329 (defun gnus-request-regenerate (gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
330 "Request a data generation from GNUS-COMMAND-METHOD." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
331 (when (stringp gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
332 (setq gnus-command-method (gnus-server-to-method gnus-command-method))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
333 (funcall (gnus-get-function gnus-command-method 'request-regenerate) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
334 (nth 1 gnus-command-method))) |
17493 | 335 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
336 (defun gnus-request-group (group &optional dont-check gnus-command-method) |
17493 | 337 "Request GROUP. If DONT-CHECK, no information is required." |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
338 (let ((gnus-command-method |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
339 (or gnus-command-method (inline (gnus-find-method-for-group group))))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
340 (when (stringp gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
341 (setq gnus-command-method |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
342 (inline (gnus-server-to-method gnus-command-method)))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
343 (funcall (inline (gnus-get-function gnus-command-method 'request-group)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
344 (gnus-group-real-name group) (nth 1 gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
345 dont-check))) |
17493 | 346 |
347 (defun gnus-list-active-group (group) | |
348 "Request active information on GROUP." | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
349 (let ((gnus-command-method (gnus-find-method-for-group group)) |
17493 | 350 (func 'list-active-group)) |
351 (when (gnus-check-backend-function func group) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
352 (funcall (gnus-get-function gnus-command-method func) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
353 (gnus-group-real-name group) (nth 1 gnus-command-method))))) |
17493 | 354 |
355 (defun gnus-request-group-description (group) | |
356 "Request a description of GROUP." | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
357 (let ((gnus-command-method (gnus-find-method-for-group group)) |
17493 | 358 (func 'request-group-description)) |
359 (when (gnus-check-backend-function func group) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
360 (funcall (gnus-get-function gnus-command-method func) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
361 (gnus-group-real-name group) (nth 1 gnus-command-method))))) |
17493 | 362 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
363 (defun gnus-request-group-articles (group) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
364 "Request a list of existing articles in GROUP." |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
365 (let ((gnus-command-method (gnus-find-method-for-group group)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
366 (func 'request-group-articles)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
367 (when (gnus-check-backend-function func group) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
368 (funcall (gnus-get-function gnus-command-method func) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
369 (gnus-group-real-name group) (nth 1 gnus-command-method))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
370 |
17493 | 371 (defun gnus-close-group (group) |
372 "Request the GROUP be closed." | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
373 (let ((gnus-command-method (inline (gnus-find-method-for-group group)))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
374 (funcall (gnus-get-function gnus-command-method 'close-group) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
375 (gnus-group-real-name group) (nth 1 gnus-command-method)))) |
17493 | 376 |
377 (defun gnus-retrieve-headers (articles group &optional fetch-old) | |
378 "Request headers for ARTICLES in GROUP. | |
379 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group." | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
380 (let ((gnus-command-method (gnus-find-method-for-group group))) |
88155 | 381 (cond |
382 ((and gnus-use-cache (numberp (car articles))) | |
383 (gnus-cache-retrieve-headers articles group fetch-old)) | |
384 ((and gnus-agent (gnus-online gnus-command-method) | |
385 (gnus-agent-method-p gnus-command-method)) | |
386 (gnus-agent-retrieve-headers articles group fetch-old)) | |
387 (t | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
388 (funcall (gnus-get-function gnus-command-method 'retrieve-headers) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
389 articles (gnus-group-real-name group) |
88155 | 390 (nth 1 gnus-command-method) fetch-old))))) |
17493 | 391 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
392 (defun gnus-retrieve-articles (articles group) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
393 "Request ARTICLES in GROUP." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
394 (let ((gnus-command-method (gnus-find-method-for-group group))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
395 (funcall (gnus-get-function gnus-command-method 'retrieve-articles) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
396 articles (gnus-group-real-name group) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
397 (nth 1 gnus-command-method)))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
398 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
399 (defun gnus-retrieve-groups (groups gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
400 "Request active information on GROUPS from GNUS-COMMAND-METHOD." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
401 (when (stringp gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
402 (setq gnus-command-method (gnus-server-to-method gnus-command-method))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
403 (funcall (gnus-get-function gnus-command-method 'retrieve-groups) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
404 groups (nth 1 gnus-command-method))) |
17493 | 405 |
406 (defun gnus-request-type (group &optional article) | |
407 "Return the type (`post' or `mail') of GROUP (and ARTICLE)." | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
408 (let ((gnus-command-method (gnus-find-method-for-group group))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
409 (if (not (gnus-check-backend-function |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
410 'request-type (car gnus-command-method))) |
17493 | 411 'unknown |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
412 (funcall (gnus-get-function gnus-command-method 'request-type) |
17493 | 413 (gnus-group-real-name group) article)))) |
414 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
415 (defun gnus-request-set-mark (group action) |
88155 | 416 "Set marks on articles in the back end." |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
417 (let ((gnus-command-method (gnus-find-method-for-group group))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
418 (if (not (gnus-check-backend-function |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
419 'request-set-mark (car gnus-command-method))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
420 action |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
421 (funcall (gnus-get-function gnus-command-method 'request-set-mark) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
422 (gnus-group-real-name group) action |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
423 (nth 1 gnus-command-method))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
424 |
17493 | 425 (defun gnus-request-update-mark (group article mark) |
88155 | 426 "Allow the back end to change the mark the user tries to put on an article." |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
427 (let ((gnus-command-method (gnus-find-method-for-group group))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
428 (if (not (gnus-check-backend-function |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
429 'request-update-mark (car gnus-command-method))) |
17493 | 430 mark |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
431 (funcall (gnus-get-function gnus-command-method 'request-update-mark) |
17493 | 432 (gnus-group-real-name group) article mark)))) |
433 | |
434 (defun gnus-request-article (article group &optional buffer) | |
435 "Request the ARTICLE in GROUP. | |
436 ARTICLE can either be an article number or an article Message-ID. | |
437 If BUFFER, insert the article in that group." | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
438 (let ((gnus-command-method (gnus-find-method-for-group group))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
439 (funcall (gnus-get-function gnus-command-method 'request-article) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
440 article (gnus-group-real-name group) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
441 (nth 1 gnus-command-method) buffer))) |
17493 | 442 |
443 (defun gnus-request-head (article group) | |
444 "Request the head of ARTICLE in GROUP." | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
445 (let* ((gnus-command-method (gnus-find-method-for-group group)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
446 (head (gnus-get-function gnus-command-method 'request-head t)) |
17493 | 447 res clean-up) |
448 (cond | |
449 ;; Check the cache. | |
450 ((and gnus-use-cache | |
451 (numberp article) | |
452 (gnus-cache-request-article article group)) | |
453 (setq res (cons group article) | |
454 clean-up t)) | |
88155 | 455 ;; Check the agent cache. |
456 ((gnus-agent-request-article article group) | |
457 (setq res (cons group article) | |
458 clean-up t)) | |
17493 | 459 ;; Use `head' function. |
460 ((fboundp head) | |
461 (setq res (funcall head article (gnus-group-real-name group) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
462 (nth 1 gnus-command-method)))) |
17493 | 463 ;; Use `article' function. |
464 (t | |
465 (setq res (gnus-request-article article group) | |
466 clean-up t))) | |
467 (when clean-up | |
468 (save-excursion | |
469 (set-buffer nntp-server-buffer) | |
470 (goto-char (point-min)) | |
471 (when (search-forward "\n\n" nil t) | |
472 (delete-region (1- (point)) (point-max))) | |
473 (nnheader-fold-continuation-lines))) | |
474 res)) | |
475 | |
476 (defun gnus-request-body (article group) | |
477 "Request the body of ARTICLE in GROUP." | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
478 (let* ((gnus-command-method (gnus-find-method-for-group group)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
479 (head (gnus-get-function gnus-command-method 'request-body t)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
480 res clean-up) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
481 (cond |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
482 ;; Check the cache. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
483 ((and gnus-use-cache |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
484 (numberp article) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
485 (gnus-cache-request-article article group)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
486 (setq res (cons group article) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
487 clean-up t)) |
88155 | 488 ;; Check the agent cache. |
489 ((gnus-agent-request-article article group) | |
490 (setq res (cons group article) | |
491 clean-up t)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
492 ;; Use `head' function. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
493 ((fboundp head) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
494 (setq res (funcall head article (gnus-group-real-name group) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
495 (nth 1 gnus-command-method)))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
496 ;; Use `article' function. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
497 (t |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
498 (setq res (gnus-request-article article group) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
499 clean-up t))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
500 (when clean-up |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
501 (save-excursion |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
502 (set-buffer nntp-server-buffer) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
503 (goto-char (point-min)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
504 (when (search-forward "\n\n" nil t) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
505 (delete-region (point-min) (1- (point)))))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
506 res)) |
17493 | 507 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
508 (defun gnus-request-post (gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
509 "Post the current buffer using GNUS-COMMAND-METHOD." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
510 (when (stringp gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
511 (setq gnus-command-method (gnus-server-to-method gnus-command-method))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
512 (funcall (gnus-get-function gnus-command-method 'request-post) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
513 (nth 1 gnus-command-method))) |
17493 | 514 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
515 (defun gnus-request-scan (group gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
516 "Request a SCAN being performed in GROUP from GNUS-COMMAND-METHOD. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
517 If GROUP is nil, all groups on GNUS-COMMAND-METHOD are scanned." |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
518 (let ((gnus-command-method |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
519 (if group (gnus-find-method-for-group group) gnus-command-method)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
520 (gnus-inhibit-demon t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
521 (mail-source-plugged gnus-plugged)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
522 (if (or gnus-plugged (not (gnus-agent-method-p gnus-command-method))) |
88155 | 523 (progn |
524 (setq gnus-internal-registry-spool-current-method gnus-command-method) | |
525 (funcall (gnus-get-function gnus-command-method 'request-scan) | |
526 (and group (gnus-group-real-name group)) | |
527 (nth 1 gnus-command-method)))))) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
528 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
529 (defsubst gnus-request-update-info (info gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
530 "Request that GNUS-COMMAND-METHOD update INFO." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
531 (when (stringp gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
532 (setq gnus-command-method (gnus-server-to-method gnus-command-method))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
533 (when (gnus-check-backend-function |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
534 'request-update-info (car gnus-command-method)) |
88155 | 535 (let ((group (gnus-info-group info))) |
536 (and (funcall (gnus-get-function gnus-command-method | |
537 'request-update-info) | |
538 (gnus-group-real-name group) | |
539 info (nth 1 gnus-command-method)) | |
540 ;; If the minimum article number is greater than 1, then all | |
541 ;; smaller article numbers are known not to exist; we'll | |
542 ;; artificially add those to the 'read range. | |
543 (let* ((active (gnus-active group)) | |
544 (min (car active))) | |
545 (when (> min 1) | |
546 (let* ((range (if (= min 2) 1 (cons 1 (1- min)))) | |
547 (read (gnus-info-read info)) | |
548 (new-read (gnus-range-add read (list range)))) | |
549 (gnus-info-set-read info new-read))) | |
550 info))))) | |
17493 | 551 |
552 (defun gnus-request-expire-articles (articles group &optional force) | |
88155 | 553 (let* ((gnus-command-method (gnus-find-method-for-group group)) |
554 (not-deleted | |
555 (funcall | |
556 (gnus-get-function gnus-command-method 'request-expire-articles) | |
557 articles (gnus-group-real-name group) (nth 1 gnus-command-method) | |
558 force))) | |
559 (when (and gnus-agent | |
560 (gnus-agent-method-p gnus-command-method)) | |
561 (let ((expired-articles (gnus-sorted-difference articles not-deleted))) | |
562 (when expired-articles | |
563 (gnus-agent-expire expired-articles group 'force)))) | |
564 not-deleted)) | |
17493 | 565 |
88155 | 566 (defun gnus-request-move-article (article group server accept-function |
567 &optional last) | |
568 (let* ((gnus-command-method (gnus-find-method-for-group group)) | |
569 (result (funcall (gnus-get-function gnus-command-method | |
570 'request-move-article) | |
571 article (gnus-group-real-name group) | |
572 (nth 1 gnus-command-method) accept-function last))) | |
573 (when (and result gnus-agent | |
574 (gnus-agent-method-p gnus-command-method)) | |
575 (gnus-agent-unfetch-articles group (list article))) | |
576 result)) | |
17493 | 577 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
578 (defun gnus-request-accept-article (group &optional gnus-command-method last |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
579 no-encode) |
17493 | 580 ;; Make sure there's a newline at the end of the article. |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
581 (when (stringp gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
582 (setq gnus-command-method (gnus-server-to-method gnus-command-method))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
583 (when (and (not gnus-command-method) |
17493 | 584 (stringp group)) |
88155 | 585 (setq gnus-command-method (or (gnus-find-method-for-group group) |
586 (gnus-group-name-to-method group)))) | |
17493 | 587 (goto-char (point-max)) |
588 (unless (bolp) | |
589 (insert "\n")) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
590 (unless no-encode |
88155 | 591 (let ((message-options message-options)) |
592 (message-options-set-recipient) | |
593 (save-restriction | |
594 (message-narrow-to-head) | |
595 (let ((mail-parse-charset message-default-charset)) | |
596 (mail-encode-encoded-word-buffer))) | |
597 (message-encode-message-body))) | |
598 (let ((gnus-command-method (or gnus-command-method | |
599 (gnus-find-method-for-group group))) | |
600 (result | |
601 (funcall | |
602 (gnus-get-function gnus-command-method 'request-accept-article) | |
603 (if (stringp group) (gnus-group-real-name group) group) | |
604 (cadr gnus-command-method) | |
605 last))) | |
606 (when (and gnus-agent (gnus-agent-method-p gnus-command-method)) | |
607 (gnus-agent-regenerate-group group (list (cdr result)))) | |
608 result)) | |
17493 | 609 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
610 (defun gnus-request-replace-article (article group buffer &optional no-encode) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
611 (unless no-encode |
88155 | 612 (let ((message-options message-options)) |
613 (message-options-set-recipient) | |
614 (save-restriction | |
615 (message-narrow-to-head) | |
616 (let ((mail-parse-charset message-default-charset)) | |
617 (mail-encode-encoded-word-buffer))) | |
618 (message-encode-message-body))) | |
619 (let* ((func (car (gnus-group-name-to-method group))) | |
620 (result (funcall (intern (format "%s-request-replace-article" func)) | |
621 article (gnus-group-real-name group) buffer))) | |
622 (when (and gnus-agent (gnus-agent-method-p gnus-command-method)) | |
623 (gnus-agent-regenerate-group group (list article))) | |
624 result)) | |
17493 | 625 |
626 (defun gnus-request-associate-buffer (group) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
627 (let ((gnus-command-method (gnus-find-method-for-group group))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
628 (funcall (gnus-get-function gnus-command-method 'request-associate-buffer) |
17493 | 629 (gnus-group-real-name group)))) |
630 | |
631 (defun gnus-request-restore-buffer (article group) | |
632 "Request a new buffer restored to the state of ARTICLE." | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
633 (let ((gnus-command-method (gnus-find-method-for-group group))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
634 (funcall (gnus-get-function gnus-command-method 'request-restore-buffer) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
635 article (gnus-group-real-name group) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
636 (nth 1 gnus-command-method)))) |
17493 | 637 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
638 (defun gnus-request-create-group (group &optional gnus-command-method args) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
639 (when (stringp gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
640 (setq gnus-command-method (gnus-server-to-method gnus-command-method))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
641 (let ((gnus-command-method |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
642 (or gnus-command-method (gnus-find-method-for-group group)))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
643 (funcall (gnus-get-function gnus-command-method 'request-create-group) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
644 (gnus-group-real-name group) (nth 1 gnus-command-method) args))) |
17493 | 645 |
646 (defun gnus-request-delete-group (group &optional force) | |
88155 | 647 (let* ((gnus-command-method (gnus-find-method-for-group group)) |
648 (result | |
649 (funcall (gnus-get-function gnus-command-method 'request-delete-group) | |
650 (gnus-group-real-name group) force (nth 1 gnus-command-method)))) | |
651 (when result | |
652 (gnus-cache-delete-group group) | |
653 (gnus-agent-delete-group group)) | |
654 result)) | |
17493 | 655 |
656 (defun gnus-request-rename-group (group new-name) | |
88155 | 657 (let* ((gnus-command-method (gnus-find-method-for-group group)) |
658 (result | |
659 (funcall (gnus-get-function gnus-command-method 'request-rename-group) | |
660 (gnus-group-real-name group) | |
661 (gnus-group-real-name new-name) (nth 1 gnus-command-method)))) | |
662 (when result | |
663 (gnus-cache-rename-group group new-name) | |
664 (gnus-agent-rename-group group new-name)) | |
665 result)) | |
17493 | 666 |
667 (defun gnus-close-backends () | |
668 ;; Send a close request to all backends that support such a request. | |
669 (let ((methods gnus-valid-select-methods) | |
670 (gnus-inhibit-demon t) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
671 func gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
672 (while (setq gnus-command-method (pop methods)) |
17493 | 673 (when (fboundp (setq func (intern |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
674 (concat (car gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
675 "-request-close")))) |
17493 | 676 (funcall func))))) |
677 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
678 (defun gnus-asynchronous-p (gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
679 (let ((func (gnus-get-function gnus-command-method 'asynchronous-p t))) |
17493 | 680 (when (fboundp func) |
681 (funcall func)))) | |
682 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
683 (defun gnus-remove-denial (gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
684 (when (stringp gnus-command-method) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
685 (setq gnus-command-method (gnus-server-to-method gnus-command-method))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
686 (let* ((elem (assoc gnus-command-method gnus-opened-servers)) |
17493 | 687 (status (cadr elem))) |
688 ;; If this hasn't been opened before, we add it to the list. | |
689 (when (eq status 'denied) | |
690 ;; Set the status of this server. | |
691 (setcar (cdr elem) 'closed)))) | |
692 | |
693 (provide 'gnus-int) | |
694 | |
88155 | 695 ;;; arch-tag: bbc90087-9b7f-4017-a92c-3abf180ac86d |
17493 | 696 ;;; gnus-int.el ends here |