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 (progn (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-open-server (gnus-command-method)
226 "Open a connection to GNUS-COMMAND-METHOD."
227 (when (stringp gnus-command-method)
228 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
229 (let ((elem (assoc gnus-command-method gnus-opened-servers))
230 (server (gnus-method-to-server-name gnus-command-method)))
231 ;; If this method was previously denied, we just return nil.
232 (if (eq (nth 1 elem) 'denied)
234 (gnus-message 1 "Denied server %s" server)
237 (let* ((open-server-function (gnus-get-function gnus-command-method 'open-server))
240 (funcall open-server-function
241 (nth 1 gnus-command-method)
242 (nthcdr 2 gnus-command-method))
244 (gnus-message 1 (format
245 "Unable to open server %s due to: %s"
246 server (error-message-string err)))
249 (gnus-message 1 "Quit trying to open server %s" server)
252 ;; If this hasn't been opened before, we add it to the list.
254 (setq elem (list gnus-command-method nil)
255 gnus-opened-servers (cons elem gnus-opened-servers)))
256 ;; Set the status of this server.
259 (if (eq open-server-function #'nnagent-open-server)
260 ;; The agent's backend has a "special" status
264 (gnus-agent-method-p gnus-command-method))
265 (cond (gnus-server-unopen-status
266 ;; Set the server's status to the unopen
267 ;; status. If that status is offline,
268 ;; recurse to open the agent's backend.
269 (setq open-offline (eq gnus-server-unopen-status 'offline))
270 gnus-server-unopen-status)
272 (not gnus-batch-mode)
275 "Unable to open server %s, go offline? "
277 (setq open-offline t)
280 ;; This agentized server was still denied
283 ;; This unagentized server must be denied
286 ;; NOTE: I MUST set the server's status to offline before this
287 ;; recursive call as this status will drive the
288 ;; gnus-get-function (called above) to return the agent's
291 ;; Recursively open this offline server to perform the
292 ;; open-server function of the agent's backend.
293 (let ((gnus-server-unopen-status 'denied))
294 ;; Bind gnus-server-unopen-status to avoid recursively
295 ;; prompting with "go offline?". This is only a concern
296 ;; when the agent's backend fails to open the server.
297 (gnus-open-server gnus-command-method))
298 (when (and (eq (cadr elem) 'ok) gnus-agent
299 (gnus-agent-method-p gnus-command-method))
301 (gnus-agent-possibly-synchronize-flags-server
302 gnus-command-method)))
305 (defun gnus-close-server (gnus-command-method)
306 "Close the connection to GNUS-COMMAND-METHOD."
307 (when (stringp gnus-command-method)
308 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
309 (funcall (gnus-get-function gnus-command-method 'close-server)
310 (nth 1 gnus-command-method)))
312 (defun gnus-request-list (gnus-command-method)
313 "Request the active file from GNUS-COMMAND-METHOD."
314 (when (stringp gnus-command-method)
315 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
316 (funcall (gnus-get-function gnus-command-method 'request-list)
317 (nth 1 gnus-command-method)))
319 (defun gnus-finish-retrieve-group-infos (gnus-command-method infos data)
320 "Read and update infos from GNUS-COMMAND-METHOD."
321 (when (stringp gnus-command-method)
322 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
323 (funcall (gnus-get-function gnus-command-method 'finish-retrieve-group-infos)
324 (nth 1 gnus-command-method)
327 (defun gnus-retrieve-group-data-early (gnus-command-method infos)
328 "Start early async retrival of data from GNUS-COMMAND-METHOD."
329 (when (stringp gnus-command-method)
330 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
331 (funcall (gnus-get-function gnus-command-method 'retrieve-group-data-early)
332 (nth 1 gnus-command-method)
335 (defun gnus-request-list-newsgroups (gnus-command-method)
336 "Request the newsgroups file from GNUS-COMMAND-METHOD."
337 (when (stringp gnus-command-method)
338 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
339 (funcall (gnus-get-function gnus-command-method 'request-list-newsgroups)
340 (nth 1 gnus-command-method)))
342 (defun gnus-request-newgroups (date gnus-command-method)
343 "Request all new groups since DATE from GNUS-COMMAND-METHOD."
344 (when (stringp gnus-command-method)
345 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
346 (let ((func (gnus-get-function gnus-command-method 'request-newgroups t)))
348 (funcall func date (nth 1 gnus-command-method)))))
350 (defun gnus-request-regenerate (gnus-command-method)
351 "Request a data generation from GNUS-COMMAND-METHOD."
352 (when (stringp gnus-command-method)
353 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
354 (funcall (gnus-get-function gnus-command-method 'request-regenerate)
355 (nth 1 gnus-command-method)))
357 (defun gnus-request-compact-group (group)
358 (let* ((method (gnus-find-method-for-group group))
359 (gnus-command-method method)
361 (funcall (gnus-get-function gnus-command-method
362 'request-compact-group)
363 (gnus-group-real-name group)
364 (nth 1 gnus-command-method) t)))
367 (defun gnus-request-compact (gnus-command-method)
368 "Request groups compaction from GNUS-COMMAND-METHOD."
369 (when (stringp gnus-command-method)
370 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
371 (funcall (gnus-get-function gnus-command-method 'request-compact)
372 (nth 1 gnus-command-method)))
374 (defun gnus-request-group (group &optional dont-check gnus-command-method)
375 "Request GROUP. If DONT-CHECK, no information is required."
376 (let ((gnus-command-method
377 (or gnus-command-method (inline (gnus-find-method-for-group group)))))
378 (when (stringp gnus-command-method)
379 (setq gnus-command-method
380 (inline (gnus-server-to-method gnus-command-method))))
381 (funcall (inline (gnus-get-function gnus-command-method 'request-group))
382 (gnus-group-real-name group) (nth 1 gnus-command-method)
385 (defun gnus-list-active-group (group)
386 "Request active information on GROUP."
387 (let ((gnus-command-method (gnus-find-method-for-group group))
388 (func 'list-active-group))
389 (when (gnus-check-backend-function func group)
390 (funcall (gnus-get-function gnus-command-method func)
391 (gnus-group-real-name group) (nth 1 gnus-command-method)))))
393 (defun gnus-request-group-description (group)
394 "Request a description of GROUP."
395 (let ((gnus-command-method (gnus-find-method-for-group group))
396 (func 'request-group-description))
397 (when (gnus-check-backend-function func group)
398 (funcall (gnus-get-function gnus-command-method func)
399 (gnus-group-real-name group) (nth 1 gnus-command-method)))))
401 (defun gnus-request-group-articles (group)
402 "Request a list of existing articles in GROUP."
403 (let ((gnus-command-method (gnus-find-method-for-group group))
404 (func 'request-group-articles))
405 (when (gnus-check-backend-function func group)
406 (funcall (gnus-get-function gnus-command-method func)
407 (gnus-group-real-name group) (nth 1 gnus-command-method)))))
409 (defun gnus-close-group (group)
410 "Request the GROUP be closed."
411 (let ((gnus-command-method (inline (gnus-find-method-for-group group))))
412 (funcall (gnus-get-function gnus-command-method 'close-group)
413 (gnus-group-real-name group) (nth 1 gnus-command-method))))
415 (defun gnus-retrieve-headers (articles group &optional fetch-old)
416 "Request headers for ARTICLES in GROUP.
417 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
418 (let ((gnus-command-method (gnus-find-method-for-group group)))
420 ((and gnus-use-cache (numberp (car articles)))
421 (gnus-cache-retrieve-headers articles group fetch-old))
422 ((and gnus-agent (gnus-online gnus-command-method)
423 (gnus-agent-method-p gnus-command-method))
424 (gnus-agent-retrieve-headers articles group fetch-old))
426 (funcall (gnus-get-function gnus-command-method 'retrieve-headers)
427 articles (gnus-group-real-name group)
428 (nth 1 gnus-command-method) fetch-old)))))
430 (defun gnus-retrieve-articles (articles group)
431 "Request ARTICLES in GROUP."
432 (let ((gnus-command-method (gnus-find-method-for-group group)))
433 (funcall (gnus-get-function gnus-command-method 'retrieve-articles)
434 articles (gnus-group-real-name group)
435 (nth 1 gnus-command-method))))
437 (defun gnus-retrieve-groups (groups gnus-command-method)
438 "Request active information on GROUPS from GNUS-COMMAND-METHOD."
439 (when (stringp gnus-command-method)
440 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
441 (funcall (gnus-get-function gnus-command-method 'retrieve-groups)
442 groups (nth 1 gnus-command-method)))
444 (defun gnus-request-type (group &optional article)
445 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
446 (let ((gnus-command-method (gnus-find-method-for-group group)))
447 (if (not (gnus-check-backend-function
448 'request-type (car gnus-command-method)))
450 (funcall (gnus-get-function gnus-command-method 'request-type)
451 (gnus-group-real-name group) article))))
453 (defun gnus-request-set-mark (group action)
454 "Set marks on articles in the back end."
455 (let ((gnus-command-method (gnus-find-method-for-group group)))
456 (if (not (gnus-check-backend-function
457 'request-set-mark (car gnus-command-method)))
459 (funcall (gnus-get-function gnus-command-method 'request-set-mark)
460 (gnus-group-real-name group) action
461 (nth 1 gnus-command-method)))))
463 (defun gnus-request-update-mark (group article mark)
464 "Allow the back end to change the mark the user tries to put on an article."
465 (let ((gnus-command-method (gnus-find-method-for-group group)))
466 (if (not (gnus-check-backend-function
467 'request-update-mark (car gnus-command-method)))
469 (funcall (gnus-get-function gnus-command-method 'request-update-mark)
470 (gnus-group-real-name group) article mark))))
472 (defun gnus-request-article (article group &optional buffer)
473 "Request the ARTICLE in GROUP.
474 ARTICLE can either be an article number or an article Message-ID.
475 If BUFFER, insert the article in that group."
476 (let ((gnus-command-method (gnus-find-method-for-group group)))
477 (funcall (gnus-get-function gnus-command-method 'request-article)
478 article (gnus-group-real-name group)
479 (nth 1 gnus-command-method) buffer)))
481 (defun gnus-request-head (article group)
482 "Request the head of ARTICLE in GROUP."
483 (let* ((gnus-command-method (gnus-find-method-for-group group))
484 (head (gnus-get-function gnus-command-method 'request-head t))
490 (gnus-cache-request-article article group))
491 (setq res (cons group article)
493 ;; Check the agent cache.
494 ((gnus-agent-request-article article group)
495 (setq res (cons group article)
497 ;; Use `head' function.
499 (setq res (funcall head article (gnus-group-real-name group)
500 (nth 1 gnus-command-method))))
501 ;; Use `article' function.
503 (setq res (gnus-request-article article group)
507 (set-buffer nntp-server-buffer)
508 (goto-char (point-min))
509 (when (search-forward "\n\n" nil t)
510 (delete-region (1- (point)) (point-max)))
511 (nnheader-fold-continuation-lines)))
514 (defun gnus-request-body (article group)
515 "Request the body of ARTICLE in GROUP."
516 (let* ((gnus-command-method (gnus-find-method-for-group group))
517 (head (gnus-get-function gnus-command-method 'request-body t))
523 (gnus-cache-request-article article group))
524 (setq res (cons group article)
526 ;; Check the agent cache.
527 ((gnus-agent-request-article article group)
528 (setq res (cons group article)
530 ;; Use `head' function.
532 (setq res (funcall head article (gnus-group-real-name group)
533 (nth 1 gnus-command-method))))
534 ;; Use `article' function.
536 (setq res (gnus-request-article article group)
540 (set-buffer nntp-server-buffer)
541 (goto-char (point-min))
542 (when (search-forward "\n\n" nil t)
543 (delete-region (point-min) (1- (point))))))
546 (defun gnus-request-post (gnus-command-method)
547 "Post the current buffer using GNUS-COMMAND-METHOD."
548 (when (stringp gnus-command-method)
549 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
550 (funcall (gnus-get-function gnus-command-method 'request-post)
551 (nth 1 gnus-command-method)))
553 (defun gnus-request-scan (group gnus-command-method)
554 "Request a SCAN being performed in GROUP from GNUS-COMMAND-METHOD.
555 If GROUP is nil, all groups on GNUS-COMMAND-METHOD are scanned."
556 (let ((gnus-command-method
557 (if group (gnus-find-method-for-group group) gnus-command-method))
558 (gnus-inhibit-demon t)
559 (mail-source-plugged gnus-plugged))
560 (when (or gnus-plugged
561 (not (gnus-agent-method-p gnus-command-method)))
562 (setq gnus-internal-registry-spool-current-method gnus-command-method)
563 (funcall (gnus-get-function gnus-command-method 'request-scan)
564 (and group (gnus-group-real-name group))
565 (nth 1 gnus-command-method)))))
567 (defsubst gnus-request-update-info (info gnus-command-method)
568 "Request that GNUS-COMMAND-METHOD update INFO."
569 (when (stringp gnus-command-method)
570 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
571 (when (gnus-check-backend-function
572 'request-update-info (car gnus-command-method))
573 (let ((group (gnus-info-group info)))
574 (and (funcall (gnus-get-function gnus-command-method
575 'request-update-info)
576 (gnus-group-real-name group)
577 info (nth 1 gnus-command-method))
578 ;; If the minimum article number is greater than 1, then all
579 ;; smaller article numbers are known not to exist; we'll
580 ;; artificially add those to the 'read range.
581 (let* ((active (gnus-active group))
584 (let* ((range (if (= min 2) 1 (cons 1 (1- min))))
585 (read (gnus-info-read info))
586 (new-read (gnus-range-add read (list range))))
587 (gnus-info-set-read info new-read)))
590 (defun gnus-request-expire-articles (articles group &optional force)
591 (let* ((gnus-command-method (gnus-find-method-for-group group))
594 (gnus-get-function gnus-command-method 'request-expire-articles)
595 articles (gnus-group-real-name group) (nth 1 gnus-command-method)
597 (when (and gnus-agent
598 (gnus-agent-method-p gnus-command-method))
599 (let ((expired-articles (gnus-sorted-difference articles not-deleted)))
600 (when expired-articles
601 (gnus-agent-expire expired-articles group 'force))))
604 (defun gnus-request-move-article (article group server accept-function
605 &optional last move-is-internal)
606 (let* ((gnus-command-method (gnus-find-method-for-group group))
607 (result (funcall (gnus-get-function gnus-command-method
608 'request-move-article)
609 article (gnus-group-real-name group)
610 (nth 1 gnus-command-method) accept-function last move-is-internal)))
611 (when (and result gnus-agent
612 (gnus-agent-method-p gnus-command-method))
613 (gnus-agent-unfetch-articles group (list article)))
616 (defun gnus-request-accept-article (group &optional gnus-command-method last
618 ;; Make sure there's a newline at the end of the article.
619 (when (stringp gnus-command-method)
620 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
621 (when (and (not gnus-command-method)
623 (setq gnus-command-method (or (gnus-find-method-for-group group)
624 (gnus-group-name-to-method group))))
625 (goto-char (point-max))
629 (let ((message-options message-options))
630 (message-options-set-recipient)
632 (message-narrow-to-head)
633 (let ((mail-parse-charset message-default-charset))
634 (mail-encode-encoded-word-buffer)))
635 (message-encode-message-body)))
636 (let ((gnus-command-method (or gnus-command-method
637 (gnus-find-method-for-group group)))
640 (gnus-get-function gnus-command-method 'request-accept-article)
641 (if (stringp group) (gnus-group-real-name group) group)
642 (cadr gnus-command-method)
644 (when (and gnus-agent (gnus-agent-method-p gnus-command-method))
645 (gnus-agent-regenerate-group group (list (cdr result))))
648 (defun gnus-request-replace-article (article group buffer &optional no-encode)
650 (let ((message-options message-options))
651 (message-options-set-recipient)
653 (message-narrow-to-head)
654 (let ((mail-parse-charset message-default-charset))
655 (mail-encode-encoded-word-buffer)))
656 (message-encode-message-body)))
657 (let* ((func (car (gnus-group-name-to-method group)))
658 (result (funcall (intern (format "%s-request-replace-article" func))
659 article (gnus-group-real-name group) buffer)))
660 (when (and gnus-agent (gnus-agent-method-p gnus-command-method))
661 (gnus-agent-regenerate-group group (list article)))
664 (defun gnus-request-associate-buffer (group)
665 (let ((gnus-command-method (gnus-find-method-for-group group)))
666 (funcall (gnus-get-function gnus-command-method 'request-associate-buffer)
667 (gnus-group-real-name group))))
669 (defun gnus-request-restore-buffer (article group)
670 "Request a new buffer restored to the state of ARTICLE."
671 (let ((gnus-command-method (gnus-find-method-for-group group)))
672 (funcall (gnus-get-function gnus-command-method 'request-restore-buffer)
673 article (gnus-group-real-name group)
674 (nth 1 gnus-command-method))))
676 (defun gnus-request-create-group (group &optional gnus-command-method args)
677 (when (stringp gnus-command-method)
678 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
679 (let ((gnus-command-method
680 (or gnus-command-method (gnus-find-method-for-group group))))
681 (funcall (gnus-get-function gnus-command-method 'request-create-group)
682 (gnus-group-real-name group) (nth 1 gnus-command-method) args)))
684 (defun gnus-request-delete-group (group &optional force)
685 (let* ((gnus-command-method (gnus-find-method-for-group group))
687 (funcall (gnus-get-function gnus-command-method 'request-delete-group)
688 (gnus-group-real-name group) force (nth 1 gnus-command-method))))
690 (gnus-cache-delete-group group)
691 (gnus-agent-delete-group group))
694 (defun gnus-request-rename-group (group new-name)
695 (let* ((gnus-command-method (gnus-find-method-for-group group))
697 (funcall (gnus-get-function gnus-command-method 'request-rename-group)
698 (gnus-group-real-name group)
699 (gnus-group-real-name new-name) (nth 1 gnus-command-method))))
701 (gnus-cache-rename-group group new-name)
702 (gnus-agent-rename-group group new-name))
705 (defun gnus-close-backends ()
706 ;; Send a close request to all backends that support such a request.
707 (let ((methods gnus-valid-select-methods)
708 (gnus-inhibit-demon t)
709 func gnus-command-method)
710 (while (setq gnus-command-method (pop methods))
711 (when (fboundp (setq func (intern
712 (concat (car gnus-command-method)
716 (defun gnus-asynchronous-p (gnus-command-method)
717 (let ((func (gnus-get-function gnus-command-method 'asynchronous-p t)))
721 (defun gnus-remove-denial (gnus-command-method)
722 (when (stringp gnus-command-method)
723 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
724 (let* ((elem (assoc gnus-command-method gnus-opened-servers))
725 (status (cadr elem)))
726 ;; If this hasn't been opened before, we add it to the list.
727 (when (eq status 'denied)
728 ;; Set the status of this server.
729 (setcar (cdr elem) 'closed))))
733 ;;; gnus-int.el ends here