1 ;;; gnus-int.el --- backend interface functions for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
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 3 of the License, or
14 ;; (at your option) any later version.
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.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
28 (eval-when-compile (require 'cl))
34 (autoload 'gnus-agent-expire "gnus-agent")
35 (autoload 'gnus-agent-regenerate-group "gnus-agent")
36 (autoload 'gnus-agent-read-servers-validate-native "gnus-agent")
37 (autoload 'gnus-agent-possibly-synchronize-flags-server "gnus-agent")
39 (defcustom gnus-open-server-hook nil
40 "Hook called just before opening connection to the news server."
44 (defcustom gnus-server-unopen-status nil
45 "The default status if the server is not able to open.
46 If the server is covered by Gnus agent, the possible values are
47 `denied', set the server denied; `offline', set the server offline;
48 nil, ask user. If the server is not covered by Gnus agent, set the
52 :type '(choice (const :tag "Ask" nil)
53 (const :tag "Deny server" denied)
54 (const :tag "Unplug Agent" offline)))
56 (defvar gnus-internal-registry-spool-current-method nil
57 "The current method, for the registry.")
60 (defun gnus-server-opened (gnus-command-method)
61 "Check whether a connection to GNUS-COMMAND-METHOD has been opened."
62 (unless (eq (gnus-server-status gnus-command-method)
64 (when (stringp gnus-command-method)
65 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
66 (funcall (inline (gnus-get-function gnus-command-method 'server-opened))
67 (nth 1 gnus-command-method))))
69 (defun gnus-status-message (gnus-command-method)
70 "Return the status message from GNUS-COMMAND-METHOD.
71 If GNUS-COMMAND-METHOD is a string, it is interpreted as a group
72 name. The method this group uses will be queried."
73 (let ((gnus-command-method
74 (if (stringp gnus-command-method)
75 (gnus-find-method-for-group gnus-command-method)
76 gnus-command-method)))
77 (funcall (gnus-get-function gnus-command-method 'status-message)
78 (nth 1 gnus-command-method))))
81 ;;; Server Communication
84 (defun gnus-start-news-server (&optional confirm)
85 "Open a method for getting news.
86 If CONFIRM is non-nil, the user will be asked for an NNTP server."
88 (if gnus-current-select-method
89 ;; Stream is already opened.
92 (unless gnus-nntp-service
93 (setq gnus-nntp-server nil))
95 ;; Read server name with completion.
96 (setq gnus-nntp-server
97 (completing-read "NNTP server: "
99 (cons (list gnus-nntp-server)
100 gnus-secondary-servers))
101 nil nil gnus-nntp-server)))
103 (when (and gnus-nntp-server
104 (stringp gnus-nntp-server)
105 (not (string= gnus-nntp-server "")))
106 (setq gnus-select-method
107 (cond ((or (string= gnus-nntp-server "")
108 (string= gnus-nntp-server "::"))
109 (list 'nnspool (system-name)))
110 ((string-match "^:" gnus-nntp-server)
111 (list 'nnmh gnus-nntp-server
112 (list 'nnmh-directory
113 (file-name-as-directory
115 (substring gnus-nntp-server 1) "~/")))
116 (list 'nnmh-get-new-mail nil)))
118 (list 'nntp gnus-nntp-server)))))
120 (setq how (car gnus-select-method))
124 (gnus-message 5 "Looking up local news spool..."))
127 (gnus-message 5 "Looking up mh spool..."))
130 (setq gnus-current-select-method gnus-select-method)
131 (gnus-run-hooks 'gnus-open-server-hook)
133 ;; Partially validate agent covered methods now that the
134 ;; gnus-select-method is known.
137 ;; NOTE: This is here for one purpose only. By validating
138 ;; the current select method, it converts the old 5.10.3,
139 ;; and earlier, format to the current format. That enables
140 ;; the agent code within gnus-open-server to function
142 (gnus-agent-read-servers-validate-native gnus-select-method))
145 ;; gnus-open-server-hook might have opened it
146 (gnus-server-opened gnus-select-method)
147 (gnus-open-server gnus-select-method)
151 "%s (%s) open error: '%s'. Continue? "
152 (car gnus-select-method) (cadr gnus-select-method)
153 (gnus-status-message gnus-select-method)))
154 (gnus-error 1 "Couldn't open server on %s"
155 (nth 1 gnus-select-method))))))
157 (defun gnus-check-group (group)
158 "Try to make sure that the server where GROUP exists is alive."
159 (let ((method (gnus-find-method-for-group group)))
160 (or (gnus-server-opened method)
161 (gnus-open-server method))))
163 (defun gnus-check-server (&optional method silent)
164 "Check whether the connection to METHOD is down.
165 If METHOD is nil, use `gnus-select-method'.
166 If it is down, start it up (again)."
167 (let ((method (or method gnus-select-method))
169 ;; Transform virtual server names into select methods.
170 (when (stringp method)
171 (setq method (gnus-server-to-method method)))
172 (if (gnus-server-opened method)
173 ;; The stream is already opened.
177 (gnus-message 5 "Opening %s server%s..." (car method)
178 (if (equal (nth 1 method) "") ""
179 (format " on %s" (nth 1 method)))))
180 (gnus-run-hooks 'gnus-open-server-hook)
182 (setq result (gnus-open-server method))
184 (gnus-message 5 "Opening %s server%s...%s" (car method)
185 (if (equal (nth 1 method) "") ""
186 (format " on %s" (nth 1 method)))
187 (if result "done" "failed")))))))
189 (defun gnus-get-function (method function &optional noerror)
190 "Return a function symbol based on METHOD and FUNCTION."
191 ;; Translate server names into methods.
193 (error "Attempted use of a nil select method"))
194 (when (stringp method)
195 (setq method (gnus-server-to-method method)))
196 ;; Check cache of constructed names.
197 (let* ((method-sym (if gnus-agent
198 (inline (gnus-agent-get-function method))
200 (method-fns (get method-sym 'gnus-method-functions))
201 (func (let ((method-fnlist-elt (assq function method-fns)))
202 (unless method-fnlist-elt
203 (setq method-fnlist-elt
205 (intern (format "%s-%s" method-sym function))))
206 (put method-sym 'gnus-method-functions
207 (cons method-fnlist-elt method-fns)))
208 (cdr method-fnlist-elt))))
209 ;; Maybe complain if there is no function.
210 (unless (fboundp func)
212 (error "Trying to require a method that doesn't exist"))
213 (require (car method))
214 (when (not (fboundp func))
217 (error "No such function: %s" func))))
222 ;;; Interface functions to the backends.
225 (defun gnus-method-denied-p (method)
226 (eq (nth 1 (assoc method gnus-opened-servers))
229 (defun gnus-open-server (gnus-command-method)
230 "Open a connection to GNUS-COMMAND-METHOD."
231 (when (stringp gnus-command-method)
232 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
233 (let ((elem (assoc gnus-command-method gnus-opened-servers))
234 (server (gnus-method-to-server-name gnus-command-method)))
235 ;; If this method was previously denied, we just return nil.
236 (if (eq (nth 1 elem) 'denied)
238 (gnus-message 1 "Denied server %s" server)
241 (let* ((open-server-function (gnus-get-function gnus-command-method 'open-server))
244 (funcall open-server-function
245 (nth 1 gnus-command-method)
246 (nthcdr 2 gnus-command-method))
248 (gnus-message 1 (format
249 "Unable to open server %s due to: %s"
250 server (error-message-string err)))
253 (gnus-message 1 "Quit trying to open server %s" server)
256 ;; If this hasn't been opened before, we add it to the list.
258 (setq elem (list gnus-command-method nil)
259 gnus-opened-servers (cons elem gnus-opened-servers)))
260 ;; Set the status of this server.
263 (if (eq open-server-function #'nnagent-open-server)
264 ;; The agent's backend has a "special" status
268 (gnus-agent-method-p gnus-command-method))
269 (cond (gnus-server-unopen-status
270 ;; Set the server's status to the unopen
271 ;; status. If that status is offline,
272 ;; recurse to open the agent's backend.
273 (setq open-offline (eq gnus-server-unopen-status 'offline))
274 gnus-server-unopen-status)
276 (not gnus-batch-mode)
279 "Unable to open server %s, go offline? "
281 (setq open-offline t)
284 ;; This agentized server was still denied
287 ;; This unagentized server must be denied
290 ;; NOTE: I MUST set the server's status to offline before this
291 ;; recursive call as this status will drive the
292 ;; gnus-get-function (called above) to return the agent's
295 ;; Recursively open this offline server to perform the
296 ;; open-server function of the agent's backend.
297 (let ((gnus-server-unopen-status 'denied))
298 ;; Bind gnus-server-unopen-status to avoid recursively
299 ;; prompting with "go offline?". This is only a concern
300 ;; when the agent's backend fails to open the server.
301 (gnus-open-server gnus-command-method))
302 (when (and (eq (cadr elem) 'ok) gnus-agent
303 (gnus-agent-method-p gnus-command-method))
305 (gnus-agent-possibly-synchronize-flags-server
306 gnus-command-method)))
309 (defun gnus-close-server (gnus-command-method)
310 "Close the connection to GNUS-COMMAND-METHOD."
311 (when (stringp gnus-command-method)
312 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
313 (funcall (gnus-get-function gnus-command-method 'close-server)
314 (nth 1 gnus-command-method)))
316 (defun gnus-request-list (gnus-command-method)
317 "Request the active file from GNUS-COMMAND-METHOD."
318 (when (stringp gnus-command-method)
319 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
320 (funcall (gnus-get-function gnus-command-method 'request-list)
321 (nth 1 gnus-command-method)))
323 (defun gnus-finish-retrieve-group-infos (gnus-command-method infos data)
324 "Read and update infos from GNUS-COMMAND-METHOD."
325 (when (stringp gnus-command-method)
326 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
327 (funcall (gnus-get-function gnus-command-method 'finish-retrieve-group-infos)
328 (nth 1 gnus-command-method)
331 (defun gnus-retrieve-group-data-early (gnus-command-method infos)
332 "Start early async retrival of data from GNUS-COMMAND-METHOD."
333 (when (stringp gnus-command-method)
334 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
335 (funcall (gnus-get-function gnus-command-method 'retrieve-group-data-early)
336 (nth 1 gnus-command-method)
339 (defun gnus-request-list-newsgroups (gnus-command-method)
340 "Request the newsgroups file from GNUS-COMMAND-METHOD."
341 (when (stringp gnus-command-method)
342 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
343 (funcall (gnus-get-function gnus-command-method 'request-list-newsgroups)
344 (nth 1 gnus-command-method)))
346 (defun gnus-request-newgroups (date gnus-command-method)
347 "Request all new groups since DATE from GNUS-COMMAND-METHOD."
348 (when (stringp gnus-command-method)
349 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
350 (let ((func (gnus-get-function gnus-command-method 'request-newgroups t)))
352 (funcall func date (nth 1 gnus-command-method)))))
354 (defun gnus-request-regenerate (gnus-command-method)
355 "Request a data generation from GNUS-COMMAND-METHOD."
356 (when (stringp gnus-command-method)
357 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
358 (funcall (gnus-get-function gnus-command-method 'request-regenerate)
359 (nth 1 gnus-command-method)))
361 (defun gnus-request-compact-group (group)
362 (let* ((method (gnus-find-method-for-group group))
363 (gnus-command-method method)
365 (funcall (gnus-get-function gnus-command-method
366 'request-compact-group)
367 (gnus-group-real-name group)
368 (nth 1 gnus-command-method) t)))
371 (defun gnus-request-compact (gnus-command-method)
372 "Request groups compaction from GNUS-COMMAND-METHOD."
373 (when (stringp gnus-command-method)
374 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
375 (funcall (gnus-get-function gnus-command-method 'request-compact)
376 (nth 1 gnus-command-method)))
378 (defun gnus-request-group (group &optional dont-check gnus-command-method info)
379 "Request GROUP. If DONT-CHECK, no information is required."
380 (let ((gnus-command-method
381 (or gnus-command-method (inline (gnus-find-method-for-group group)))))
382 (when (stringp gnus-command-method)
383 (setq gnus-command-method
384 (inline (gnus-server-to-method gnus-command-method))))
385 (funcall (inline (gnus-get-function gnus-command-method 'request-group))
386 (gnus-group-real-name group) (nth 1 gnus-command-method)
390 (defun gnus-list-active-group (group)
391 "Request active information on GROUP."
392 (let ((gnus-command-method (gnus-find-method-for-group group))
393 (func 'list-active-group))
394 (when (gnus-check-backend-function func group)
395 (funcall (gnus-get-function gnus-command-method func)
396 (gnus-group-real-name group) (nth 1 gnus-command-method)))))
398 (defun gnus-request-group-description (group)
399 "Request a description of GROUP."
400 (let ((gnus-command-method (gnus-find-method-for-group group))
401 (func 'request-group-description))
402 (when (gnus-check-backend-function func group)
403 (funcall (gnus-get-function gnus-command-method func)
404 (gnus-group-real-name group) (nth 1 gnus-command-method)))))
406 (defun gnus-request-group-articles (group)
407 "Request a list of existing articles in GROUP."
408 (let ((gnus-command-method (gnus-find-method-for-group group))
409 (func 'request-group-articles))
410 (when (gnus-check-backend-function func group)
411 (funcall (gnus-get-function gnus-command-method func)
412 (gnus-group-real-name group) (nth 1 gnus-command-method)))))
414 (defun gnus-close-group (group)
415 "Request the GROUP be closed."
416 (let ((gnus-command-method (inline (gnus-find-method-for-group group))))
417 (funcall (gnus-get-function gnus-command-method 'close-group)
418 (gnus-group-real-name group) (nth 1 gnus-command-method))))
420 (defun gnus-retrieve-headers (articles group &optional fetch-old)
421 "Request headers for ARTICLES in GROUP.
422 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
423 (let ((gnus-command-method (gnus-find-method-for-group group)))
425 ((and gnus-use-cache (numberp (car articles)))
426 (gnus-cache-retrieve-headers articles group fetch-old))
427 ((and gnus-agent (gnus-online gnus-command-method)
428 (gnus-agent-method-p gnus-command-method))
429 (gnus-agent-retrieve-headers articles group fetch-old))
431 (funcall (gnus-get-function gnus-command-method 'retrieve-headers)
432 articles (gnus-group-real-name group)
433 (nth 1 gnus-command-method) fetch-old)))))
435 (defun gnus-retrieve-articles (articles group)
436 "Request ARTICLES in GROUP."
437 (let ((gnus-command-method (gnus-find-method-for-group group)))
438 (funcall (gnus-get-function gnus-command-method 'retrieve-articles)
439 articles (gnus-group-real-name group)
440 (nth 1 gnus-command-method))))
442 (defun gnus-retrieve-groups (groups gnus-command-method)
443 "Request active information on GROUPS from GNUS-COMMAND-METHOD."
444 (when (stringp gnus-command-method)
445 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
446 (funcall (gnus-get-function gnus-command-method 'retrieve-groups)
447 groups (nth 1 gnus-command-method)))
449 (defun gnus-request-type (group &optional article)
450 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
451 (let ((gnus-command-method (gnus-find-method-for-group group)))
452 (if (not (gnus-check-backend-function
453 'request-type (car gnus-command-method)))
455 (funcall (gnus-get-function gnus-command-method 'request-type)
456 (gnus-group-real-name group) article))))
458 (defun gnus-request-set-mark (group action)
459 "Set marks on articles in the back end."
460 (let ((gnus-command-method (gnus-find-method-for-group group)))
461 (if (not (gnus-check-backend-function
462 'request-set-mark (car gnus-command-method)))
464 (funcall (gnus-get-function gnus-command-method 'request-set-mark)
465 (gnus-group-real-name group) action
466 (nth 1 gnus-command-method)))))
468 (defun gnus-request-update-mark (group article mark)
469 "Allow the back end to change the mark the user tries to put on an article."
470 (let ((gnus-command-method (gnus-find-method-for-group group)))
471 (if (not (gnus-check-backend-function
472 'request-update-mark (car gnus-command-method)))
474 (funcall (gnus-get-function gnus-command-method 'request-update-mark)
475 (gnus-group-real-name group) article mark))))
477 (defun gnus-request-article (article group &optional buffer)
478 "Request the ARTICLE in GROUP.
479 ARTICLE can either be an article number or an article Message-ID.
480 If BUFFER, insert the article in that group."
481 (let ((gnus-command-method (gnus-find-method-for-group group)))
482 (funcall (gnus-get-function gnus-command-method 'request-article)
483 article (gnus-group-real-name group)
484 (nth 1 gnus-command-method) buffer)))
486 (defun gnus-request-head (article group)
487 "Request the head of ARTICLE in GROUP."
488 (let* ((gnus-command-method (gnus-find-method-for-group group))
489 (head (gnus-get-function gnus-command-method 'request-head t))
495 (gnus-cache-request-article article group))
496 (setq res (cons group article)
498 ;; Check the agent cache.
499 ((gnus-agent-request-article article group)
500 (setq res (cons group article)
502 ;; Use `head' function.
504 (setq res (funcall head article (gnus-group-real-name group)
505 (nth 1 gnus-command-method))))
506 ;; Use `article' function.
508 (setq res (gnus-request-article article group)
511 (with-current-buffer nntp-server-buffer
512 (goto-char (point-min))
513 (when (search-forward "\n\n" nil t)
514 (delete-region (1- (point)) (point-max)))
515 (nnheader-fold-continuation-lines)))
518 (defun gnus-request-body (article group)
519 "Request the body of ARTICLE in GROUP."
520 (let* ((gnus-command-method (gnus-find-method-for-group group))
521 (head (gnus-get-function gnus-command-method 'request-body t))
527 (gnus-cache-request-article article group))
528 (setq res (cons group article)
530 ;; Check the agent cache.
531 ((gnus-agent-request-article article group)
532 (setq res (cons group article)
534 ;; Use `head' function.
536 (setq res (funcall head article (gnus-group-real-name group)
537 (nth 1 gnus-command-method))))
538 ;; Use `article' function.
540 (setq res (gnus-request-article article group)
543 (with-current-buffer nntp-server-buffer
544 (goto-char (point-min))
545 (when (search-forward "\n\n" nil t)
546 (delete-region (point-min) (1- (point))))))
549 (defun gnus-request-post (gnus-command-method)
550 "Post the current buffer using GNUS-COMMAND-METHOD."
551 (when (stringp gnus-command-method)
552 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
553 (funcall (gnus-get-function gnus-command-method 'request-post)
554 (nth 1 gnus-command-method)))
556 (defun gnus-request-scan (group gnus-command-method)
557 "Request a SCAN being performed in GROUP from GNUS-COMMAND-METHOD.
558 If GROUP is nil, all groups on GNUS-COMMAND-METHOD are scanned."
559 (let ((gnus-command-method
560 (if group (gnus-find-method-for-group group) gnus-command-method))
561 (gnus-inhibit-demon t)
562 (mail-source-plugged gnus-plugged))
563 (when (or gnus-plugged
564 (not (gnus-agent-method-p gnus-command-method)))
565 (setq gnus-internal-registry-spool-current-method gnus-command-method)
566 (funcall (gnus-get-function gnus-command-method 'request-scan)
567 (and group (gnus-group-real-name group))
568 (nth 1 gnus-command-method)))))
570 (defsubst gnus-request-update-info (info gnus-command-method)
571 "Request that GNUS-COMMAND-METHOD update INFO."
572 (when (stringp gnus-command-method)
573 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
574 (when (gnus-check-backend-function
575 'request-update-info (car gnus-command-method))
576 (let ((group (gnus-info-group info)))
577 (and (funcall (gnus-get-function gnus-command-method
578 'request-update-info)
579 (gnus-group-real-name group)
580 info (nth 1 gnus-command-method))
581 ;; If the minimum article number is greater than 1, then all
582 ;; smaller article numbers are known not to exist; we'll
583 ;; artificially add those to the 'read range.
584 (let* ((active (gnus-active group))
587 (let* ((range (if (= min 2) 1 (cons 1 (1- min))))
588 (read (gnus-info-read info))
589 (new-read (gnus-range-add read (list range))))
590 (gnus-info-set-read info new-read)))
593 (defun gnus-request-expire-articles (articles group &optional force)
594 (let* ((gnus-command-method (gnus-find-method-for-group group))
597 (gnus-get-function gnus-command-method 'request-expire-articles)
598 articles (gnus-group-real-name group) (nth 1 gnus-command-method)
600 (when (and gnus-agent
601 (gnus-agent-method-p gnus-command-method))
602 (let ((expired-articles (gnus-sorted-difference articles not-deleted)))
603 (when expired-articles
604 (gnus-agent-expire expired-articles group 'force))))
607 (defun gnus-request-move-article (article group server accept-function
608 &optional last move-is-internal)
609 (let* ((gnus-command-method (gnus-find-method-for-group group))
610 (result (funcall (gnus-get-function gnus-command-method
611 'request-move-article)
612 article (gnus-group-real-name group)
613 (nth 1 gnus-command-method) accept-function last move-is-internal)))
614 (when (and result gnus-agent
615 (gnus-agent-method-p gnus-command-method))
616 (gnus-agent-unfetch-articles group (list article)))
619 (defun gnus-request-accept-article (group &optional gnus-command-method last
621 ;; Make sure there's a newline at the end of the article.
622 (when (stringp gnus-command-method)
623 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
624 (when (and (not gnus-command-method)
626 (setq gnus-command-method (or (gnus-find-method-for-group group)
627 (gnus-group-name-to-method group))))
628 (goto-char (point-max))
632 (let ((message-options message-options))
633 (message-options-set-recipient)
635 (message-narrow-to-head)
636 (let ((mail-parse-charset message-default-charset))
637 (mail-encode-encoded-word-buffer)))
638 (message-encode-message-body)))
639 (let ((gnus-command-method (or gnus-command-method
640 (gnus-find-method-for-group group)))
643 (gnus-get-function gnus-command-method 'request-accept-article)
644 (if (stringp group) (gnus-group-real-name group) group)
645 (cadr gnus-command-method)
647 (when (and gnus-agent (gnus-agent-method-p gnus-command-method))
648 (gnus-agent-regenerate-group group (list (cdr result))))
651 (defun gnus-request-replace-article (article group buffer &optional no-encode)
653 (let ((message-options message-options))
654 (message-options-set-recipient)
656 (message-narrow-to-head)
657 (let ((mail-parse-charset message-default-charset))
658 (mail-encode-encoded-word-buffer)))
659 (message-encode-message-body)))
660 (let* ((func (car (gnus-group-name-to-method group)))
661 (result (funcall (intern (format "%s-request-replace-article" func))
662 article (gnus-group-real-name group) buffer)))
663 (when (and gnus-agent (gnus-agent-method-p gnus-command-method))
664 (gnus-agent-regenerate-group group (list article)))
667 (defun gnus-request-associate-buffer (group)
668 (let ((gnus-command-method (gnus-find-method-for-group group)))
669 (funcall (gnus-get-function gnus-command-method 'request-associate-buffer)
670 (gnus-group-real-name group))))
672 (defun gnus-request-restore-buffer (article group)
673 "Request a new buffer restored to the state of ARTICLE."
674 (let ((gnus-command-method (gnus-find-method-for-group group)))
675 (funcall (gnus-get-function gnus-command-method 'request-restore-buffer)
676 article (gnus-group-real-name group)
677 (nth 1 gnus-command-method))))
679 (defun gnus-request-create-group (group &optional gnus-command-method args)
680 (when (stringp gnus-command-method)
681 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
682 (let ((gnus-command-method
683 (or gnus-command-method (gnus-find-method-for-group group))))
684 (funcall (gnus-get-function gnus-command-method 'request-create-group)
685 (gnus-group-real-name group) (nth 1 gnus-command-method) args)))
687 (defun gnus-request-delete-group (group &optional force)
688 (let* ((gnus-command-method (gnus-find-method-for-group group))
690 (funcall (gnus-get-function gnus-command-method 'request-delete-group)
691 (gnus-group-real-name group) force (nth 1 gnus-command-method))))
693 (gnus-cache-delete-group group)
694 (gnus-agent-delete-group group))
697 (defun gnus-request-rename-group (group new-name)
698 (let* ((gnus-command-method (gnus-find-method-for-group group))
700 (funcall (gnus-get-function gnus-command-method 'request-rename-group)
701 (gnus-group-real-name group)
702 (gnus-group-real-name new-name) (nth 1 gnus-command-method))))
704 (gnus-cache-rename-group group new-name)
705 (gnus-agent-rename-group group new-name))
708 (defun gnus-close-backends ()
709 ;; Send a close request to all backends that support such a request.
710 (let ((methods gnus-valid-select-methods)
711 (gnus-inhibit-demon t)
712 func gnus-command-method)
713 (while (setq gnus-command-method (pop methods))
714 (when (fboundp (setq func (intern
715 (concat (car gnus-command-method)
719 (defun gnus-asynchronous-p (gnus-command-method)
720 (let ((func (gnus-get-function gnus-command-method 'asynchronous-p t)))
724 (defun gnus-remove-denial (gnus-command-method)
725 (when (stringp gnus-command-method)
726 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
727 (let* ((elem (assoc gnus-command-method gnus-opened-servers))
728 (status (cadr elem)))
729 ;; If this hasn't been opened before, we add it to the list.
730 (when (eq status 'denied)
731 ;; Set the status of this server.
732 (setcar (cdr elem) 'closed))))
736 ;;; gnus-int.el ends here