annotate lisp/gnus/nnoo.el @ 143:50e7fedfe353

Added tag r20-2b5 for changeset 1856695b1fa9
author cvs
date Mon, 13 Aug 2007 09:33:20 +0200
parents fe104dbd9147
children 15872534500d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; nnoo.el --- OO Gnus Backends
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
2 ;; Copyright (C) 1996,97 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: news
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; Boston, MA 02111-1307, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
28 (require 'nnheader)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
29 (require 'cl)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (defvar nnoo-definition-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (defvar nnoo-state-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (defmacro defvoo (var init &optional doc &rest map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 "The same as `defvar', only takes list of variables to MAP to."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 `(prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ,(if doc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 `(defvar ,var ,init ,doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 `(defvar ,var ,init))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (nnoo-define ',var ',map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (put 'defvoo 'lisp-indent-function 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (put 'defvoo 'edebug-form-spec '(var init &optional doc &rest map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (defmacro deffoo (func args &rest forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 "The same as `defun', only register FUNC."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 `(prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (defun ,func ,args ,@forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (nnoo-register-function ',func)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (put 'deffoo 'lisp-indent-function 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (put 'deffoo 'edebug-form-spec '(&define name lambda-list def-body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (defun nnoo-register-function (func)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
53 (let ((funcs (nthcdr 3 (assoc (nnoo-backend func)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 nnoo-definition-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (unless funcs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (error "%s belongs to a backend that hasn't been declared" func))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (setcar funcs (cons func (car funcs)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (defmacro nnoo-declare (backend &rest parents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 `(eval-and-compile
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
61 (push (list ',backend
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (mapcar (lambda (p) (list p)) ',parents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 nil nil)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
64 nnoo-definition-alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
65 (push (list ',backend "*internal-non-initialized-backend*")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
66 nnoo-state-alist)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (put 'nnoo-declare 'lisp-indent-function 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (defun nnoo-parents (backend)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (nth 1 (assoc backend nnoo-definition-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (defun nnoo-variables (backend)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (nth 2 (assoc backend nnoo-definition-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (defun nnoo-functions (backend)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (nth 3 (assoc backend nnoo-definition-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (defmacro nnoo-import (backend &rest imports)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 `(nnoo-import-1 ',backend ',imports))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (put 'nnoo-import 'lisp-indent-function 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (defun nnoo-import-1 (backend imports)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (let ((call-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (if (symbolp (car imports)) (pop imports) 'nnoo-parent-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 imp functions function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (while (setq imp (pop imports))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (setq functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (or (cdr imp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (nnoo-functions (car imp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (while functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (unless (fboundp (setq function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (nnoo-symbol backend (nnoo-rest-symbol
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
93 (car functions)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (eval `(deffoo ,function (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (,call-function ',backend ',(car functions) args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (pop functions)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (defun nnoo-parent-function (backend function args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (let* ((pbackend (nnoo-backend function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (nnoo-change-server pbackend (nnoo-current-server backend)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (cdr (assq pbackend (nnoo-parents backend))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (apply function args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (defun nnoo-execute (backend function &rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 "Execute FUNCTION on behalf of BACKEND."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (let* ((pbackend (nnoo-backend function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (nnoo-change-server pbackend (nnoo-current-server backend)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (cdr (assq pbackend (nnoo-parents backend))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (apply function args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (defmacro nnoo-map-functions (backend &rest maps)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 `(nnoo-map-functions-1 ',backend ',maps))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (put 'nnoo-map-functions 'lisp-indent-function 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (defun nnoo-map-functions-1 (backend maps)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (let (m margs i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (while (setq m (pop maps))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (setq i 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 margs nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (while (< i (length (cdr m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (if (numberp (nth i (cdr m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (push `(nth ,i args) margs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (push (nth i (cdr m)) margs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (incf i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (eval `(deffoo ,(nnoo-symbol backend (nnoo-rest-symbol (car m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (&rest args)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
127 (nnoo-parent-function ',backend ',(car m)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ,(cons 'list (nreverse margs))))))))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
129
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (defun nnoo-backend (symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (string-match "^[^-]+-" (symbol-name symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (intern (substring (symbol-name symbol) 0 (1- (match-end 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (defun nnoo-rest-symbol (symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (string-match "^[^-]+-" (symbol-name symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (intern (substring (symbol-name symbol) (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (defun nnoo-symbol (backend symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (intern (format "%s-%s" backend symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (defun nnoo-define (var map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (let* ((backend (nnoo-backend var))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (def (assq backend nnoo-definition-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (parents (nth 1 def)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (unless def
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (error "%s belongs to a backend that hasn't been declared." var))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
147 (setcar (nthcdr 2 def)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (delq (assq var (nth 2 def)) (nth 2 def)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (setcar (nthcdr 2 def)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (cons (cons var (symbol-value var))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (nth 2 def)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (while map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (nconc (assq (nnoo-backend (car map)) parents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (list (list (pop map) var))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (defun nnoo-change-server (backend server defs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (let* ((bstate (cdr (assq backend nnoo-state-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (current (car bstate))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (parents (nnoo-parents backend))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
160 (bvariables (nnoo-variables backend))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
161 state def)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (unless bstate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (push (setq bstate (list backend nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 nnoo-state-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (pop bstate))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (if (equal server current)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (nnoo-push-server backend current)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (setq state (or (cdr (assoc server (cddr bstate)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (nnoo-variables backend)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (while state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (set (caar state) (cdar state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (pop state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (setcar bstate server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (unless (cdr (assoc server (cddr bstate)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
176 (while (setq def (pop defs))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
177 (unless (assq (car def) bvariables)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
178 (nconc bvariables
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
179 (list (cons (car def) (and (boundp (car def))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
180 (symbol-value (car def)))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
181 (set (car def) (cadr def))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (while parents
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
183 (nnoo-change-server
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
184 (caar parents) server
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (mapcar (lambda (def) (list (car def) (symbol-value (cadr def))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (cdar parents)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (pop parents))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (defun nnoo-push-server (backend current)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (let ((bstate (assq backend nnoo-state-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (defs (nnoo-variables backend)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;; Remove the old definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (setcdr (cdr bstate) (delq (assoc current (cddr bstate)) (cddr bstate)))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
195 ;; If this is the first time we push the server (i. e., this is
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
196 ;; the nil server), then we update the default values of
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
197 ;; all the variables to reflect the current values.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
198 (when (equal current "*internal-non-initialized-backend*")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
199 (let ((defaults (nnoo-variables backend))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
200 def)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
201 (while (setq def (pop defaults))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
202 (setcdr def (symbol-value (car def))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (let (state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (while defs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (push (cons (caar defs) (symbol-value (caar defs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (pop defs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (nconc bstate (list (cons current state))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
210 (defsubst nnoo-current-server-p (backend server)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (equal (nnoo-current-server backend) server))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (defun nnoo-current-server (backend)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (nth 1 (assq backend nnoo-state-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (defun nnoo-close-server (backend &optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (unless server
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (setq server (nnoo-current-server backend)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (when server
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (let* ((bstate (cdr (assq backend nnoo-state-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (defs (assoc server (cdr bstate))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (when bstate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (setcar bstate nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (setcdr bstate (delq defs (cdr bstate)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (pop defs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (while defs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (set (car (pop defs)) nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (defun nnoo-close (backend)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (setq nnoo-state-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (delq (assq backend nnoo-state-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 nnoo-state-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (defun nnoo-status-message (backend server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (nnheader-get-report backend))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (defun nnoo-server-opened (backend server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (and (nnoo-current-server-p backend server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 nntp-server-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (buffer-name nntp-server-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (defmacro nnoo-define-basics (backend)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
245 "Define `close-server', `server-opened' and `status-message'."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 `(eval-and-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (nnoo-define-basics-1 ',backend)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (defun nnoo-define-basics-1 (backend)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (let ((functions '(close-server server-opened status-message)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (while functions
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
252 (eval `(deffoo ,(nnoo-symbol backend (car functions))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (&optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (,(nnoo-symbol 'nnoo (pop functions)) ',backend server)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (eval `(deffoo ,(nnoo-symbol backend 'open-server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (server &optional defs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (nnoo-change-server ',backend server defs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
259 (defmacro nnoo-define-skeleton (backend)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
260 "Define all required backend functions for BACKEND.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
261 All functions will return nil and report an error."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
262 `(eval-and-compile
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
263 (nnoo-define-skeleton-1 ',backend)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
264
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
265 (defun nnoo-define-skeleton-1 (backend)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
266 (let ((functions '(retrieve-headers
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
267 request-close request-article
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
268 request-group close-group
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
269 request-list request-post request-list-newsgroups))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
270 function fun)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
271 (while (setq function (pop functions))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
272 (when (not (fboundp (setq fun (nnoo-symbol backend function))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
273 (eval `(deffoo ,fun
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
274 (&rest args)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
275 (nnheader-report ',backend ,(format "%s-%s not implemented"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
276 backend function))))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (provide 'nnoo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 ;;; nnoo.el ends here.