• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/emacs-92/emacs/lisp/gnus/

Lines Matching +defs:gnus +defs:group +defs:next +defs:group

0 ;;; gnus-async.el --- asynchronous support for Gnus
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
32 (require 'gnus)
33 (require 'gnus-sum)
40 (defgroup gnus-asynchronous nil
42 :group 'gnus)
44 (defcustom gnus-use-article-prefetch 30
48 :group 'gnus-asynchronous
53 (defcustom gnus-asynchronous nil
56 :group 'gnus-asynchronous
59 (defcustom gnus-prefetched-article-deletion-strategy '(read exit)
63 that all articles belonging to a group are removed on exit
64 from that group."
65 :group 'gnus-asynchronous
68 (defcustom gnus-use-header-prefetch nil
69 "*If non-nil, prefetch the headers to the next group."
70 :group 'gnus-asynchronous
73 (defcustom gnus-async-prefetch-article-p 'gnus-async-unread-p
77 :group 'gnus-asynchronous
82 (defvar gnus-async-prefetch-article-buffer " *Async Prefetch Article*")
83 (defvar gnus-async-article-alist nil)
84 (defvar gnus-async-article-semaphore '(nil))
85 (defvar gnus-async-fetch-list nil)
86 (defvar gnus-async-hashtb nil)
87 (defvar gnus-async-current-prefetch-group nil)
88 (defvar gnus-async-current-prefetch-article nil)
89 (defvar gnus-async-timer nil)
91 (defvar gnus-async-prefetch-headers-buffer " *Async Prefetch Headers*")
92 (defvar gnus-async-header-prefetched nil)
96 (defun gnus-group-asynchronous-p (group)
98 (gnus-asynchronous-p (gnus-find-method-for-group group)))
102 (defun gnus-async-get-semaphore (semaphore)
107 (defun gnus-async-release-semaphore (semaphore)
111 (defmacro gnus-async-with-semaphore (&rest forms)
114 (gnus-async-get-semaphore 'gnus-async-article-semaphore)
116 (gnus-async-release-semaphore 'gnus-async-article-semaphore)))
118 (put 'gnus-async-with-semaphore 'lisp-indent-function 0)
119 (put 'gnus-async-with-semaphore 'edebug-form-spec '(body))
125 (gnus-add-shutdown 'gnus-async-close 'gnus)
126 (defun gnus-async-close ()
127 (gnus-kill-buffer gnus-async-prefetch-article-buffer)
128 (gnus-kill-buffer gnus-async-prefetch-headers-buffer)
129 (setq gnus-async-hashtb nil
130 gnus-async-article-alist nil
131 gnus-async-header-prefetched nil))
133 (defun gnus-async-set-buffer ()
134 (nnheader-set-temp-buffer gnus-async-prefetch-article-buffer t)
135 (unless gnus-async-hashtb
136 (setq gnus-async-hashtb (gnus-make-hashtable 1023))))
138 (defun gnus-async-halt-prefetch ()
140 (setq gnus-async-fetch-list nil))
142 (defun gnus-async-prefetch-next (group article summary)
144 (when (and (gnus-buffer-live-p summary)
145 gnus-asynchronous
146 (gnus-group-asynchronous-p group))
148 (set-buffer gnus-summary-buffer)
149 (let ((next (caadr (gnus-data-find-list article))))
150 (when next
155 (gnus-async-prefetch-article group next summary)
156 (when gnus-async-timer
158 (nnheader-cancel-timer 'gnus-async-timer)))
159 (setq gnus-async-timer
161 0.1 nil 'gnus-async-prefetch-article
162 group next summary))))))))
164 (defun gnus-async-prefetch-article (group article summary &optional next)
166 (if (not (gnus-buffer-live-p summary))
167 (gnus-async-with-semaphore
168 (setq gnus-async-fetch-list nil))
169 (when (and gnus-asynchronous
170 (gnus-alive-p))
171 (when next
172 (gnus-async-with-semaphore
173 (pop gnus-async-fetch-list)))
174 (let ((do-fetch next)
175 (do-message t)) ;(eq major-mode 'gnus-summary-mode)))
176 (when (and (gnus-group-asynchronous-p group)
177 (gnus-buffer-live-p summary)
178 (or (not next)
179 gnus-async-fetch-list))
180 (gnus-async-with-semaphore
181 (unless next
182 (setq do-fetch (not gnus-async-fetch-list))
184 (setq gnus-async-fetch-list nil)
186 (let ((n gnus-use-article-prefetch)
187 (data (gnus-data-find-list article))
193 (unless (or (gnus-async-prefetched-article-entry
194 group (setq article (gnus-data-number d)))
196 (not (funcall gnus-async-prefetch-article-p d)))
198 (push article gnus-async-fetch-list)))
199 (setq gnus-async-fetch-list
200 (nreverse gnus-async-fetch-list))))
203 (setq article (car gnus-async-fetch-list))))
210 (gnus-async-set-buffer)
214 (gnus-make-async-article-function
215 group article mark summary next))
217 (get-buffer gnus-async-prefetch-article-buffer)))
219 (gnus-message 9 "Prefetching article %d in group %s"
220 article group))
221 (setq gnus-async-current-prefetch-group group)
222 (setq gnus-async-current-prefetch-article article)
223 (gnus-request-article article group))))))))))
225 (defun gnus-make-async-article-function (group article mark summary next)
228 (gnus-async-article-callback arg ,group ,article ,mark ,summary ,next)))
230 (defun gnus-async-article-callback (arg group article mark summary next)
233 (setq gnus-async-current-prefetch-article nil)
235 (gnus-async-set-buffer)
236 (gnus-async-with-semaphore
238 gnus-async-article-alist
239 (cons (list (intern (format "%s-%d" group article)
240 gnus-async-hashtb)
242 group article)
243 gnus-async-article-alist))))
244 (if (not (gnus-buffer-live-p summary))
245 (gnus-async-with-semaphore
246 (setq gnus-async-fetch-list nil))
247 (gnus-async-prefetch-article group next summary t))))
249 (defun gnus-async-unread-p (data)
251 (gnus-data-unread-p data))
253 (defun gnus-async-request-fetched-article (group article buffer)
256 (when (and (equal group gnus-async-current-prefetch-group)
257 (eq article gnus-async-current-prefetch-article))
258 (gnus-async-wait-for-article article))
259 (let ((entry (gnus-async-prefetched-article-entry group article)))
262 (gnus-async-set-buffer)
265 (when (memq 'read gnus-prefetched-article-deletion-strategy)
266 (gnus-async-delete-prefetched-entry entry))
269 (defun gnus-async-wait-for-article (article)
272 (gnus-async-set-buffer)
283 (while (eq article gnus-async-current-prefetch-article)
289 (gnus-message 5 "Waiting for async article...")
295 (setq gnus-async-current-prefetch-article nil))
298 (gnus-message 5 "")))))
300 (defun gnus-async-delete-prefetched-entry (entry)
306 (gnus-async-with-semaphore
307 (setq gnus-async-article-alist
308 (delq entry gnus-async-article-alist))))
310 (defun gnus-async-prefetch-remove-group (group)
312 (when (and (gnus-group-asynchronous-p group)
313 (memq 'exit gnus-prefetched-article-deletion-strategy))
314 (let ((alist gnus-async-article-alist))
316 (gnus-async-set-buffer)
318 (when (equal group (nth 3 (car alist)))
319 (gnus-async-delete-prefetched-entry (car alist)))
322 (defun gnus-async-prefetched-article-entry (group article)
325 (gnus-async-set-buffer)
326 (assq (intern (format "%s-%d" group article)
327 gnus-async-hashtb)
328 gnus-async-article-alist))))
336 (setq gnus-async-article-alist
337 (delq entry gnus-async-article-alist))
345 (defun gnus-async-prefetch-headers (group)
346 "Prefetch the headers for group GROUP."
349 (when (and gnus-use-header-prefetch
350 gnus-asynchronous
351 (gnus-group-asynchronous-p group)
352 (listp gnus-async-header-prefetched)
353 (setq unread (gnus-list-of-unread-articles group)))
355 (setq gnus-async-header-prefetched t)
356 (nnheader-set-temp-buffer gnus-async-prefetch-headers-buffer t)
361 (setq gnus-async-header-prefetched
362 ,(cons group unread)))))
363 (gnus-retrieve-headers unread group gnus-fetch-old-headers))))))
365 (defun gnus-async-retrieve-fetched-headers (articles group)
367 (when (and gnus-use-header-prefetch
368 (gnus-group-asynchronous-p group)
369 (listp gnus-async-header-prefetched)
370 (equal group (car gnus-async-header-prefetched))
371 (equal articles (cdr gnus-async-header-prefetched)))
373 (nnheader-set-temp-buffer gnus-async-prefetch-headers-buffer t)
377 (setq gnus-async-header-prefetched nil)
380 (provide 'gnus-async)
383 ;;; gnus-async.el ends here