Mercurial > emacs
annotate lisp/gnus/nnoo.el @ 94980:51e9d65c90fc
Merge from gnus--devo--0
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1161
author | Miles Bader <miles@gnu.org> |
---|---|
date | Thu, 15 May 2008 00:26:27 +0000 |
parents | f42ef85caf91 |
children | a9dc0e7c3f2b |
rev | line source |
---|---|
17493 | 1 ;;; nnoo.el --- OO Gnus Backends |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2 |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, |
79708 | 4 ;; 2004, 2005, 2006, 2007, 2008 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 | |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
17493 | 12 ;; it under the terms of the GNU General Public License as published by |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; (at your option) any later version. |
17493 | 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 | |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
17493 | 23 |
24 ;;; Commentary: | |
25 | |
26 ;;; Code: | |
27 | |
28 (require 'nnheader) | |
19494
4280cff25537
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
29 (eval-when-compile (require 'cl)) |
17493 | 30 |
31 (defvar nnoo-definition-alist nil) | |
32 (defvar nnoo-state-alist nil) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
33 (defvar nnoo-parent-backend nil) |
17493 | 34 |
35 (defmacro defvoo (var init &optional doc &rest map) | |
36 "The same as `defvar', only takes list of variables to MAP to." | |
37 `(prog1 | |
38 ,(if doc | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
39 `(defvar ,var ,init ,(concat doc "\n\nThis is a Gnus server variable. See Info node `(gnus)Select Methods'.")) |
17493 | 40 `(defvar ,var ,init)) |
41 (nnoo-define ',var ',map))) | |
42 (put 'defvoo 'lisp-indent-function 2) | |
43 (put 'defvoo 'edebug-form-spec '(var init &optional doc &rest map)) | |
44 | |
45 (defmacro deffoo (func args &rest forms) | |
46 "The same as `defun', only register FUNC." | |
47 `(prog1 | |
48 (defun ,func ,args ,@forms) | |
49 (nnoo-register-function ',func))) | |
50 (put 'deffoo 'lisp-indent-function 2) | |
51 (put 'deffoo 'edebug-form-spec '(&define name lambda-list def-body)) | |
52 | |
53 (defun nnoo-register-function (func) | |
54 (let ((funcs (nthcdr 3 (assoc (nnoo-backend func) | |
55 nnoo-definition-alist)))) | |
56 (unless funcs | |
57 (error "%s belongs to a backend that hasn't been declared" func)) | |
58 (setcar funcs (cons func (car funcs))))) | |
59 | |
60 (defmacro nnoo-declare (backend &rest parents) | |
61 `(eval-and-compile | |
68940
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
62 (if (assq ',backend nnoo-definition-alist) |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
63 (setcar (cdr (assq ',backend nnoo-definition-alist)) |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
64 (mapcar 'list ',parents)) |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
65 (push (list ',backend |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
66 (mapcar 'list ',parents) |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
67 nil nil) |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
68 nnoo-definition-alist)) |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
69 (unless (assq ',backend nnoo-state-alist) |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
70 (push (list ',backend "*internal-non-initialized-backend*") |
808f636eb13e
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents:
68633
diff
changeset
|
71 nnoo-state-alist)))) |
17493 | 72 (put 'nnoo-declare 'lisp-indent-function 1) |
73 | |
74 (defun nnoo-parents (backend) | |
75 (nth 1 (assoc backend nnoo-definition-alist))) | |
76 | |
77 (defun nnoo-variables (backend) | |
78 (nth 2 (assoc backend nnoo-definition-alist))) | |
79 | |
80 (defun nnoo-functions (backend) | |
81 (nth 3 (assoc backend nnoo-definition-alist))) | |
82 | |
83 (defmacro nnoo-import (backend &rest imports) | |
84 `(nnoo-import-1 ',backend ',imports)) | |
85 (put 'nnoo-import 'lisp-indent-function 1) | |
86 | |
87 (defun nnoo-import-1 (backend imports) | |
88 (let ((call-function | |
89 (if (symbolp (car imports)) (pop imports) 'nnoo-parent-function)) | |
90 imp functions function) | |
91 (while (setq imp (pop imports)) | |
92 (setq functions | |
93 (or (cdr imp) | |
94 (nnoo-functions (car imp)))) | |
95 (while functions | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
96 (unless (fboundp |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
97 (setq function |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
98 (nnoo-symbol backend |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
99 (nnoo-rest-symbol (car functions))))) |
17493 | 100 (eval `(deffoo ,function (&rest args) |
101 (,call-function ',backend ',(car functions) args)))) | |
102 (pop functions))))) | |
103 | |
104 (defun nnoo-parent-function (backend function args) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
105 (let ((pbackend (nnoo-backend function)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
106 (nnoo-parent-backend backend)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
107 (nnoo-change-server pbackend |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
108 (nnoo-current-server backend) |
17493 | 109 (cdr (assq pbackend (nnoo-parents backend)))) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
110 (prog1 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
111 (apply function args) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
112 ;; Copy the changed variables back into the child. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
113 (let ((vars (cdr (assq pbackend (nnoo-parents backend))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
114 (while vars |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
115 (set (cadar vars) (symbol-value (caar vars))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
116 (setq vars (cdr vars))))))) |
17493 | 117 |
118 (defun nnoo-execute (backend function &rest args) | |
119 "Execute FUNCTION on behalf of BACKEND." | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
120 (let ((pbackend (nnoo-backend function)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
121 (nnoo-parent-backend backend)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
122 (nnoo-change-server pbackend |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
123 (nnoo-current-server backend) |
17493 | 124 (cdr (assq pbackend (nnoo-parents backend)))) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
125 (prog1 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
126 (apply function args) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
127 ;; Copy the changed variables back into the child. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
128 (let ((vars (cdr (assq pbackend (nnoo-parents backend))))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
129 (while vars |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
130 (set (cadar vars) (symbol-value (caar vars))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
131 (setq vars (cdr vars))))))) |
17493 | 132 |
133 (defmacro nnoo-map-functions (backend &rest maps) | |
134 `(nnoo-map-functions-1 ',backend ',maps)) | |
135 (put 'nnoo-map-functions 'lisp-indent-function 1) | |
136 | |
137 (defun nnoo-map-functions-1 (backend maps) | |
138 (let (m margs i) | |
139 (while (setq m (pop maps)) | |
140 (setq i 0 | |
141 margs nil) | |
142 (while (< i (length (cdr m))) | |
143 (if (numberp (nth i (cdr m))) | |
144 (push `(nth ,i args) margs) | |
145 (push (nth i (cdr m)) margs)) | |
146 (incf i)) | |
147 (eval `(deffoo ,(nnoo-symbol backend (nnoo-rest-symbol (car m))) | |
148 (&rest args) | |
149 (nnoo-parent-function ',backend ',(car m) | |
150 ,(cons 'list (nreverse margs)))))))) | |
151 | |
152 (defun nnoo-backend (symbol) | |
153 (string-match "^[^-]+-" (symbol-name symbol)) | |
154 (intern (substring (symbol-name symbol) 0 (1- (match-end 0))))) | |
155 | |
156 (defun nnoo-rest-symbol (symbol) | |
157 (string-match "^[^-]+-" (symbol-name symbol)) | |
158 (intern (substring (symbol-name symbol) (match-end 0)))) | |
159 | |
160 (defun nnoo-symbol (backend symbol) | |
161 (intern (format "%s-%s" backend symbol))) | |
162 | |
163 (defun nnoo-define (var map) | |
164 (let* ((backend (nnoo-backend var)) | |
165 (def (assq backend nnoo-definition-alist)) | |
166 (parents (nth 1 def))) | |
167 (unless def | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19494
diff
changeset
|
168 (error "%s belongs to a backend that hasn't been declared" var)) |
17493 | 169 (setcar (nthcdr 2 def) |
170 (delq (assq var (nth 2 def)) (nth 2 def))) | |
171 (setcar (nthcdr 2 def) | |
172 (cons (cons var (symbol-value var)) | |
173 (nth 2 def))) | |
174 (while map | |
175 (nconc (assq (nnoo-backend (car map)) parents) | |
176 (list (list (pop map) var)))))) | |
177 | |
178 (defun nnoo-change-server (backend server defs) | |
179 (let* ((bstate (cdr (assq backend nnoo-state-alist))) | |
180 (current (car bstate)) | |
181 (parents (nnoo-parents backend)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
182 (server (if nnoo-parent-backend |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
183 (format "%s+%s" nnoo-parent-backend server) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
184 server)) |
17493 | 185 (bvariables (nnoo-variables backend)) |
186 state def) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
187 ;; If we don't have a current state, we push an empty state |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
188 ;; onto the alist. |
17493 | 189 (unless bstate |
190 (push (setq bstate (list backend nil)) | |
191 nnoo-state-alist) | |
192 (pop bstate)) | |
193 (if (equal server current) | |
194 t | |
195 (nnoo-push-server backend current) | |
196 (setq state (or (cdr (assoc server (cddr bstate))) | |
197 (nnoo-variables backend))) | |
198 (while state | |
199 (set (caar state) (cdar state)) | |
200 (pop state)) | |
201 (setcar bstate server) | |
202 (unless (cdr (assoc server (cddr bstate))) | |
203 (while (setq def (pop defs)) | |
204 (unless (assq (car def) bvariables) | |
205 (nconc bvariables | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
206 (list (cons (car def) (and (boundp (car def)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
207 (symbol-value (car def))))))) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
208 (if (equal server "*internal-non-initialized-backend*") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
209 (set (car def) (symbol-value (cadr def))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
210 (set (car def) (cadr def))))) |
17493 | 211 (while parents |
212 (nnoo-change-server | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
213 (caar parents) (format "%s+%s" backend server) |
17493 | 214 (mapcar (lambda (def) (list (car def) (symbol-value (cadr def)))) |
215 (cdar parents))) | |
216 (pop parents)))) | |
217 t) | |
218 | |
219 (defun nnoo-push-server (backend current) | |
220 (let ((bstate (assq backend nnoo-state-alist)) | |
221 (defs (nnoo-variables backend))) | |
222 ;; Remove the old definition. | |
223 (setcdr (cdr bstate) (delq (assoc current (cddr bstate)) (cddr bstate))) | |
224 ;; If this is the first time we push the server (i. e., this is | |
225 ;; the nil server), then we update the default values of | |
226 ;; all the variables to reflect the current values. | |
227 (when (equal current "*internal-non-initialized-backend*") | |
228 (let ((defaults (nnoo-variables backend)) | |
229 def) | |
230 (while (setq def (pop defaults)) | |
231 (setcdr def (symbol-value (car def)))))) | |
232 (let (state) | |
233 (while defs | |
234 (push (cons (caar defs) (symbol-value (caar defs))) | |
235 state) | |
236 (pop defs)) | |
237 (nconc bstate (list (cons current state)))))) | |
238 | |
239 (defsubst nnoo-current-server-p (backend server) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
240 (equal (nnoo-current-server backend) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
241 (if nnoo-parent-backend |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
242 (format "%s+%s" nnoo-parent-backend server) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
243 server))) |
17493 | 244 |
245 (defun nnoo-current-server (backend) | |
246 (nth 1 (assq backend nnoo-state-alist))) | |
247 | |
248 (defun nnoo-close-server (backend &optional server) | |
249 (unless server | |
250 (setq server (nnoo-current-server backend))) | |
251 (when server | |
252 (let* ((bstate (cdr (assq backend nnoo-state-alist))) | |
253 (defs (assoc server (cdr bstate)))) | |
254 (when bstate | |
255 (setcar bstate nil) | |
256 (setcdr bstate (delq defs (cdr bstate))) | |
257 (pop defs) | |
258 (while defs | |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
259 (set (car (pop defs)) nil))))) |
17493 | 260 t) |
261 | |
262 (defun nnoo-close (backend) | |
263 (setq nnoo-state-alist | |
264 (delq (assq backend nnoo-state-alist) | |
265 nnoo-state-alist)) | |
266 t) | |
267 | |
268 (defun nnoo-status-message (backend server) | |
269 (nnheader-get-report backend)) | |
270 | |
271 (defun nnoo-server-opened (backend server) | |
272 (and (nnoo-current-server-p backend server) | |
273 nntp-server-buffer | |
274 (buffer-name nntp-server-buffer))) | |
275 | |
276 (defmacro nnoo-define-basics (backend) | |
277 "Define `close-server', `server-opened' and `status-message'." | |
278 `(eval-and-compile | |
279 (nnoo-define-basics-1 ',backend))) | |
280 | |
281 (defun nnoo-define-basics-1 (backend) | |
282 (let ((functions '(close-server server-opened status-message))) | |
283 (while functions | |
284 (eval `(deffoo ,(nnoo-symbol backend (car functions)) | |
285 (&optional server) | |
286 (,(nnoo-symbol 'nnoo (pop functions)) ',backend server))))) | |
287 (eval `(deffoo ,(nnoo-symbol backend 'open-server) | |
288 (server &optional defs) | |
289 (nnoo-change-server ',backend server defs)))) | |
290 | |
291 (defmacro nnoo-define-skeleton (backend) | |
292 "Define all required backend functions for BACKEND. | |
293 All functions will return nil and report an error." | |
294 `(eval-and-compile | |
295 (nnoo-define-skeleton-1 ',backend))) | |
296 | |
297 (defun nnoo-define-skeleton-1 (backend) | |
298 (let ((functions '(retrieve-headers | |
299 request-close request-article | |
300 request-group close-group | |
301 request-list request-post request-list-newsgroups)) | |
302 function fun) | |
303 (while (setq function (pop functions)) | |
304 (when (not (fboundp (setq fun (nnoo-symbol backend function)))) | |
305 (eval `(deffoo ,fun | |
306 (&rest args) | |
307 (nnheader-report ',backend ,(format "%s-%s not implemented" | |
308 backend function)))))))) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
309 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
310 (defun nnoo-set (server &rest args) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
311 (let ((parents (nnoo-parents (car server))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
312 (nnoo-parent-backend (car server))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
313 (while parents |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
314 (nnoo-change-server (caar parents) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
315 (cadr server) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
316 (cdar parents)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
317 (pop parents))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
318 (nnoo-change-server (car server) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
319 (cadr server) (cddr server)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
320 (while args |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
321 (set (pop args) (pop args)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
322 |
17493 | 323 (provide 'nnoo) |
324 | |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79708
diff
changeset
|
325 ;; arch-tag: 0196b5ed-6f34-4778-a455-73a971f837e7 |
38413
a26d9b55abb6
Some fixes to follow coding conventions in files from Gnus.
Pavel Janík <Pavel@Janik.cz>
parents:
31716
diff
changeset
|
326 ;;; nnoo.el ends here |