Mercurial > hg > xemacs-beta
comparison lisp/gnus/gnus-picon.el @ 151:59463afc5666 r20-3b2
Import from CVS: tag r20-3b2
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:37:19 +0200 |
parents | 1856695b1fa9 |
children | 43dd3413c7c7 |
comparison
equal
deleted
inserted
replaced
150:8ebb1c0f0f6f | 151:59463afc5666 |
---|---|
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the | 20 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
22 ;; Boston, MA 02111-1307, USA. | 22 ;; Boston, MA 02111-1307, USA. |
23 | 23 |
24 ;;; Commentary: | 24 ;;; Commentary: |
25 | |
26 ;;; TODO: | |
27 ;; See the comment in gnus-picons-remove | |
28 | 25 |
29 ;;; Code: | 26 ;;; Code: |
30 | 27 |
31 (require 'gnus) | 28 (require 'gnus) |
32 (require 'xpm) | 29 (require 'xpm) |
43 gnus-summary-display-hook or to the gnus-article-display-hook | 40 gnus-summary-display-hook or to the gnus-article-display-hook |
44 depending on what gnus-picons-display-where is set to. You must | 41 depending on what gnus-picons-display-where is set to. You must |
45 also add gnus-article-display-picons to gnus-article-display-hook." | 42 also add gnus-article-display-picons to gnus-article-display-hook." |
46 :group 'gnus-visual) | 43 :group 'gnus-visual) |
47 | 44 |
48 (defcustom gnus-picons-buffer "*Icon Buffer*" | |
49 "Buffer name to display the icons in if gnus-picons-display-where is 'picons." | |
50 :type 'string | |
51 :group 'picons) | |
52 | |
53 (defcustom gnus-picons-display-where 'picons | 45 (defcustom gnus-picons-display-where 'picons |
54 "Where to display the group and article icons. | 46 "Where to display the group and article icons. |
55 Legal values are `article' and `picons'." | 47 Legal values are `article' and `picons'." |
56 :type '(choice symbol string) | 48 :type '(choice symbol string) |
49 :group 'picons) | |
50 | |
51 (defcustom gnus-picons-has-modeline-p t | |
52 "Wether the picons window should have a modeline. | |
53 This is only useful if `gnus-picons-display-where' is `picons'." | |
54 :type 'boolean | |
57 :group 'picons) | 55 :group 'picons) |
58 | 56 |
59 (defcustom gnus-picons-database "/usr/local/faces" | 57 (defcustom gnus-picons-database "/usr/local/faces" |
60 "Defines the location of the faces database. | 58 "Defines the location of the faces database. |
61 For information on obtaining this database of pretty pictures, please | 59 For information on obtaining this database of pretty pictures, please |
62 see http://www.cs.indiana.edu/picons/ftp/index.html" | 60 see http://www.cs.indiana.edu/picons/ftp/index.html" |
63 :type 'directory | 61 :type 'directory |
64 :group 'picons) | 62 :group 'picons) |
65 | 63 |
66 (defcustom gnus-picons-news-directory "news" | 64 (defcustom gnus-picons-news-directories '("news") |
67 "Sub-directory of the faces database containing the icons for newsgroups." | 65 "Sub-directory of the faces database containing the icons for newsgroups." |
68 :type 'string | 66 :type '(repeat string) |
69 :group 'picons) | 67 :group 'picons) |
68 (define-obsolete-variable-alias 'gnus-picons-news-directory | |
69 'gnus-picons-news-directories) | |
70 | 70 |
71 (defcustom gnus-picons-user-directories '("local" "users" "usenix" "misc") | 71 (defcustom gnus-picons-user-directories '("local" "users" "usenix" "misc") |
72 "List of directories to search for user faces." | 72 "List of directories to search for user faces." |
73 :type '(repeat string) | 73 :type '(repeat string) |
74 :group 'picons) | 74 :group 'picons) |
150 "Picons file names cache. | 150 "Picons file names cache. |
151 List of pairs (KEY . NAME) where KEY is (USER HOST DBS) and NAME is an URL.") | 151 List of pairs (KEY . NAME) where KEY is (USER HOST DBS) and NAME is an URL.") |
152 | 152 |
153 (defvar gnus-group-annotations nil | 153 (defvar gnus-group-annotations nil |
154 "List of annotations added/removed when selecting/exiting a group") | 154 "List of annotations added/removed when selecting/exiting a group") |
155 (defvar gnus-group-annotations-lock nil) | |
156 (defvar gnus-article-annotations nil | 155 (defvar gnus-article-annotations nil |
157 "List of annotations added/removed when selecting an article") | 156 "List of annotations added/removed when selecting an article") |
158 (defvar gnus-article-annotations-lock nil) | |
159 (defvar gnus-x-face-annotations nil | 157 (defvar gnus-x-face-annotations nil |
160 "List of annotations added/removed when selecting an article with an | 158 "List of annotations added/removed when selecting an article with an |
161 X-Face.") | 159 X-Face.") |
162 (defvar gnus-x-face-annotations-lock nil) | |
163 | 160 |
164 (defvar gnus-picons-jobs-alist nil | 161 (defvar gnus-picons-jobs-alist nil |
165 "List of jobs that still need be done. | 162 "List of jobs that still need be done. |
166 This is a list of (SYM-ANN TAG ARGS...) where SYM-ANN three annotations list, | 163 This is a list of (SYM-ANN TAG ARGS...) where SYM-ANN three annotations list, |
167 TAG is one of `picon' or `search' indicating that the job should query a | 164 TAG is one of `picon' or `search' indicating that the job should query a |
171 (defvar gnus-picons-job-already-running nil | 168 (defvar gnus-picons-job-already-running nil |
172 "Lock to ensure only one stream of http requests is running.") | 169 "Lock to ensure only one stream of http requests is running.") |
173 | 170 |
174 ;;; Functions: | 171 ;;; Functions: |
175 | 172 |
176 (defsubst gnus-picons-lock (symbol) | |
177 (intern (concat (symbol-name symbol) "-lock"))) | |
178 | |
179 (defun gnus-picons-remove (symbol) | 173 (defun gnus-picons-remove (symbol) |
180 "Remove all annotations in variable named SYMBOL. | 174 "Remove all annotations in variable named SYMBOL. |
181 This function is careful to set it to nil before removing anything so that | 175 This function is careful to set it to nil before removing anything so that |
182 asynchronous process don't get crazy." | 176 asynchronous process don't get crazy." |
183 ;; clear the lock | 177 (setq gnus-picons-jobs-alist (remassq symbol gnus-picons-jobs-alist)) |
184 (set (gnus-picons-lock symbol) nil) | 178 ;; notify running job that it may have been preempted |
179 (if (eq (car gnus-picons-job-already-running) symbol) | |
180 (setq gnus-picons-job-already-running t)) | |
185 ;; clear all annotations | 181 ;; clear all annotations |
186 (mapc (function (lambda (item) | 182 (mapc (function (lambda (item) |
187 (if (annotationp item) | 183 (if (annotationp item) |
188 (delete-annotation item)))) | 184 (delete-annotation item)))) |
189 (prog1 (symbol-value symbol) | 185 (prog1 (symbol-value symbol) |
190 (set symbol nil))) | 186 (set symbol nil)))) |
191 ;; FIXME: there's a race condition here. If a job is already | |
192 ;; running, it has already removed itself from this queue... But | |
193 ;; will still display its picon. | |
194 ;; TODO: push a request to clear an annotation. Then | |
195 ;; gnus-picons-next-job will be able to clean up when it gets the | |
196 ;; hand | |
197 (setq gnus-picons-jobs-alist (remassq symbol gnus-picons-jobs-alist))) | |
198 | 187 |
199 (defun gnus-picons-remove-all () | 188 (defun gnus-picons-remove-all () |
200 "Removes all picons from the Gnus display(s)." | 189 "Removes all picons from the Gnus display(s)." |
201 (interactive) | 190 (interactive) |
202 (gnus-picons-remove 'gnus-article-annotations) | 191 (gnus-picons-remove 'gnus-article-annotations) |
203 (gnus-picons-remove 'gnus-group-annotations) | 192 (gnus-picons-remove 'gnus-group-annotations) |
204 (gnus-picons-remove 'gnus-x-face-annotations) | 193 (gnus-picons-remove 'gnus-x-face-annotations)) |
205 (when (bufferp gnus-picons-buffer) | |
206 (kill-buffer gnus-picons-buffer))) | |
207 | 194 |
208 (defun gnus-get-buffer-name (variable) | 195 (defun gnus-get-buffer-name (variable) |
209 "Returns the buffer name associated with the contents of a variable." | 196 "Returns the buffer name associated with the contents of a variable." |
210 (cond ((symbolp variable) (let ((newvar (cdr (assq variable | 197 (cond ((symbolp variable) (let ((newvar (cdr (assq variable |
211 gnus-window-to-buffer)))) | 198 gnus-window-to-buffer)))) |
212 (cond ((symbolp newvar) | 199 (cond ((symbolp newvar) |
213 (symbol-value newvar)) | 200 (symbol-value newvar)) |
214 ((stringp newvar) newvar)))) | 201 ((stringp newvar) newvar)))) |
215 ((stringp variable) variable))) | 202 ((stringp variable) variable))) |
216 | 203 |
204 (defun gnus-picons-set-buffer () | |
205 (set-buffer | |
206 (get-buffer-create (gnus-get-buffer-name gnus-picons-display-where))) | |
207 (gnus-add-current-to-buffer-list) | |
208 (goto-char (point-min)) | |
209 (if (and (eq gnus-picons-display-where 'article) | |
210 gnus-picons-display-article-move-p) | |
211 (if (search-forward "\n\n" nil t) | |
212 (forward-line -1) | |
213 (goto-char (point-max))) | |
214 (setq buffer-read-only t) | |
215 (unless gnus-picons-has-modeline-p | |
216 (set-specifier has-modeline-p | |
217 (list (list (current-buffer) | |
218 (cons nil gnus-picons-has-modeline-p))))))) | |
219 | |
217 (defun gnus-picons-prepare-for-annotations (annotations) | 220 (defun gnus-picons-prepare-for-annotations (annotations) |
218 "Prepare picons buffer for puting annotations memorized in ANNOTATIONS. | 221 "Prepare picons buffer for puting annotations memorized in ANNOTATIONS. |
219 ANNOTATIONS should be a symbol naming a variable wich contains a list of | 222 ANNOTATIONS should be a symbol naming a variable wich contains a list of |
220 annotations. Sets buffer to `gnus-picons-display-where'." | 223 annotations. Sets buffer to `gnus-picons-display-where'." |
221 ;; let drawing catch up | 224 ;; let drawing catch up |
222 (when gnus-picons-refresh-before-display | 225 (when gnus-picons-refresh-before-display |
223 (sit-for 0)) | 226 (sit-for 0)) |
224 (set-buffer (get-buffer-create | 227 (gnus-picons-set-buffer) |
225 (gnus-get-buffer-name gnus-picons-display-where))) | |
226 (gnus-add-current-to-buffer-list) | |
227 (goto-char (point-min)) | |
228 (if (and (eq gnus-picons-display-where 'article) | |
229 gnus-picons-display-article-move-p) | |
230 (when (search-forward "\n\n" nil t) | |
231 (forward-line -1)) | |
232 (make-local-variable 'inhibit-read-only) | |
233 (setq buffer-read-only t | |
234 inhibit-read-only nil)) | |
235 (gnus-picons-remove annotations)) | 228 (gnus-picons-remove annotations)) |
229 | |
230 (defsubst gnus-picons-make-annotation (&rest args) | |
231 (let ((annot (apply 'make-annotation args))) | |
232 (set-extent-property annot 'duplicable nil) | |
233 annot)) | |
236 | 234 |
237 (defun gnus-picons-article-display-x-face () | 235 (defun gnus-picons-article-display-x-face () |
238 "Display the x-face header bitmap in the 'gnus-picons-display-where buffer." | 236 "Display the x-face header bitmap in the 'gnus-picons-display-where buffer." |
239 ;; delete any old ones. | 237 ;; delete any old ones. |
240 ;; This is needed here because gnus-picons-display-x-face will not | 238 ;; This is needed here because gnus-picons-display-x-face will not |
263 ;; Use builtin support | 261 ;; Use builtin support |
264 (let ((buf (current-buffer))) | 262 (let ((buf (current-buffer))) |
265 (save-excursion | 263 (save-excursion |
266 (gnus-picons-prepare-for-annotations 'gnus-x-face-annotations) | 264 (gnus-picons-prepare-for-annotations 'gnus-x-face-annotations) |
267 (setq gnus-x-face-annotations | 265 (setq gnus-x-face-annotations |
268 (cons (make-annotation | 266 (cons (gnus-picons-make-annotation |
269 (vector 'xface | 267 (vector 'xface |
270 :data (concat "X-Face: " | 268 :data (concat "X-Face: " |
271 (buffer-substring beg end buf))) | 269 (buffer-substring beg end buf))) |
272 nil 'text) | 270 nil 'text) |
273 gnus-x-face-annotations)))) | 271 gnus-x-face-annotations)))) |
274 ;; convert the x-face header to a .xbm file | 272 ;; convert the x-face header to a .xbm file |
275 (let* ((process-connection-type nil) | 273 (let* ((process-connection-type nil) |
276 (annot (save-excursion | 274 (annot (save-excursion |
277 (gnus-picons-prepare-for-annotations | 275 (gnus-picons-prepare-for-annotations |
278 'gnus-x-face-annotations) | 276 'gnus-x-face-annotations) |
279 (make-annotation nil nil 'text))) | 277 (gnus-picons-make-annotation nil nil 'text))) |
280 (process (start-process-shell-command "gnus-x-face" nil | 278 (process (start-process-shell-command "gnus-x-face" nil |
281 gnus-picons-convert-x-face))) | 279 gnus-picons-convert-x-face))) |
282 (push annot gnus-x-face-annotations) | 280 (push annot gnus-x-face-annotations) |
283 (push (cons process annot) gnus-picons-processes-alist) | 281 (push (cons process annot) gnus-picons-processes-alist) |
284 (process-kill-without-query process) | 282 (process-kill-without-query process) |
304 (if gnus-local-domain | 302 (if gnus-local-domain |
305 (message-tokenize-header gnus-local-domain ".")) | 303 (message-tokenize-header gnus-local-domain ".")) |
306 (message-tokenize-header (substring from (1+ at-idx)) | 304 (message-tokenize-header (substring from (1+ at-idx)) |
307 ".")))) | 305 ".")))) |
308 (gnus-picons-prepare-for-annotations 'gnus-article-annotations) | 306 (gnus-picons-prepare-for-annotations 'gnus-article-annotations) |
307 ;; if display in article buffer, the group annotations | |
308 ;; wrongly placed. Move them here | |
309 (if (eq gnus-picons-display-where 'article) | |
310 (dolist (ext gnus-group-annotations) | |
311 (set-extent-endpoints ext (point) (point)))) | |
309 (if (null gnus-picons-piconsearch-url) | 312 (if (null gnus-picons-piconsearch-url) |
310 (setq gnus-article-annotations | 313 (setq gnus-article-annotations |
311 (nconc gnus-article-annotations | 314 (nconc gnus-article-annotations |
312 (gnus-picons-display-pairs | 315 (gnus-picons-display-pairs |
313 (gnus-picons-lookup-pairs | 316 (gnus-picons-lookup-pairs |
314 addrs gnus-picons-domain-directories) | 317 addrs gnus-picons-domain-directories) |
315 (not (or gnus-picons-display-as-address | 318 gnus-picons-display-as-address |
316 gnus-article-annotations)) | |
317 "." t) | 319 "." t) |
318 (if (and gnus-picons-display-as-address addrs) | 320 (if (and gnus-picons-display-as-address addrs) |
319 (list (make-annotation [string :data "@"] nil | 321 (list (gnus-picons-make-annotation |
320 'text nil nil nil t))) | 322 [string :data "@"] nil |
323 'text nil nil nil t))) | |
321 (gnus-picons-display-picon-or-name | 324 (gnus-picons-display-picon-or-name |
322 (gnus-picons-lookup-user username addrs) | 325 (gnus-picons-lookup-user username addrs) |
323 username t))) | 326 username t))) |
324 (push (list 'gnus-article-annotations 'search username addrs | 327 (push (list 'gnus-article-annotations 'search username addrs |
325 gnus-picons-domain-directories t) | 328 gnus-picons-domain-directories t) |
338 (if (null gnus-picons-piconsearch-url) | 341 (if (null gnus-picons-piconsearch-url) |
339 (setq gnus-group-annotations | 342 (setq gnus-group-annotations |
340 (gnus-picons-display-pairs | 343 (gnus-picons-display-pairs |
341 (gnus-picons-lookup-pairs (reverse (message-tokenize-header | 344 (gnus-picons-lookup-pairs (reverse (message-tokenize-header |
342 gnus-newsgroup-name ".")) | 345 gnus-newsgroup-name ".")) |
343 gnus-picons-news-directory) | 346 gnus-picons-news-directories) |
344 t ".")) | 347 t ".")) |
345 (push (list 'gnus-group-annotations 'search nil | 348 (push (list 'gnus-group-annotations 'search nil |
346 (message-tokenize-header gnus-newsgroup-name ".") | 349 (message-tokenize-header gnus-newsgroup-name ".") |
347 (if (listp gnus-picons-news-directory) | 350 (if (listp gnus-picons-news-directories) |
348 gnus-picons-news-directory | 351 gnus-picons-news-directories |
349 (list gnus-picons-news-directory)) | 352 (list gnus-picons-news-directories)) |
350 nil) | 353 nil) |
351 gnus-picons-jobs-alist) | 354 gnus-picons-jobs-alist) |
352 (gnus-picons-next-job)) | 355 (gnus-picons-next-job)) |
353 | 356 |
354 (add-hook 'gnus-summary-exit-hook 'gnus-picons-remove-all)))) | 357 (add-hook 'gnus-summary-exit-hook 'gnus-picons-remove-all)))) |
402 picons)) | 405 picons)) |
403 picons)) | 406 picons)) |
404 | 407 |
405 (defun gnus-picons-display-picon-or-name (picon name &optional right-p) | 408 (defun gnus-picons-display-picon-or-name (picon name &optional right-p) |
406 (cond (picon (gnus-picons-display-glyph picon name right-p)) | 409 (cond (picon (gnus-picons-display-glyph picon name right-p)) |
407 (gnus-picons-display-as-address (list (make-annotation | 410 (gnus-picons-display-as-address (list (gnus-picons-make-annotation |
408 (vector 'string :data name) | 411 (vector 'string :data name) |
409 nil 'text | 412 nil 'text |
410 nil nil nil right-p))))) | 413 nil nil nil right-p))))) |
411 | 414 |
412 (defun gnus-picons-display-pairs (pairs &optional bar-p dot-p right-p) | 415 (defun gnus-picons-display-pairs (pairs &optional bar-p dot-p right-p) |
413 "Display picons in list PAIRS." | 416 "Display picons in list PAIRS." |
414 (let ((bar (and bar-p (or gnus-picons-display-as-address | 417 (let ((domain-p (and gnus-picons-display-as-address dot-p)) |
415 (annotations-in-region (point) | |
416 (min (point-max) | |
417 (1+ (point))) | |
418 (current-buffer))))) | |
419 (domain-p (and gnus-picons-display-as-address dot-p)) | |
420 pair picons) | 418 pair picons) |
419 (if (and bar-p domain-p right-p) | |
420 (setq picons (gnus-picons-display-glyph | |
421 (gnus-picons-try-face gnus-xmas-glyph-directory | |
422 "bar.") | |
423 nil right-p))) | |
421 (while pairs | 424 (while pairs |
422 (setq pair (pop pairs) | 425 (setq pair (pop pairs) |
423 picons (nconc (if (and domain-p picons (not right-p)) | 426 picons (nconc picons |
424 (list (make-annotation | |
425 (vector 'string :data dot-p) | |
426 nil 'text nil nil nil right-p))) | |
427 (gnus-picons-display-picon-or-name (car pair) | 427 (gnus-picons-display-picon-or-name (car pair) |
428 (cadr pair) | 428 (cadr pair) |
429 right-p) | 429 right-p) |
430 (if (and domain-p pairs right-p) | 430 (if (and domain-p pairs) |
431 (list (make-annotation | 431 (list (gnus-picons-make-annotation |
432 (vector 'string :data dot-p) | 432 (vector 'string :data dot-p) |
433 nil 'text nil nil nil right-p))) | 433 nil 'text nil nil nil right-p)))))) |
434 (when (and bar domain-p) | 434 (if (and bar-p domain-p (not right-p)) |
435 (setq bar nil) | 435 (setq picons (nconc picons |
436 (gnus-picons-display-glyph | 436 (gnus-picons-display-glyph |
437 (gnus-picons-try-face gnus-xmas-glyph-directory | 437 (gnus-picons-try-face gnus-xmas-glyph-directory |
438 "bar.") | 438 "bar.") |
439 nil t)) | 439 nil right-p)))) |
440 picons))) | |
441 picons)) | 440 picons)) |
442 | 441 |
443 (defun gnus-picons-try-face (dir &optional filebase) | 442 (defun gnus-picons-try-face (dir &optional filebase) |
444 (let* ((dir (file-name-as-directory dir)) | 443 (let* ((dir (file-name-as-directory dir)) |
445 (filebase (or filebase "face.")) | 444 (filebase (or filebase "face.")) |
454 (setq glyph (make-glyph f)) | 453 (setq glyph (make-glyph f)) |
455 (push (cons key glyph) gnus-picons-glyph-alist))) | 454 (push (cons key glyph) gnus-picons-glyph-alist))) |
456 glyph)) | 455 glyph)) |
457 | 456 |
458 (defun gnus-picons-display-glyph (glyph &optional part rightp) | 457 (defun gnus-picons-display-glyph (glyph &optional part rightp) |
459 (let ((new (make-annotation glyph (point) 'text nil nil nil rightp))) | 458 (let ((new (gnus-picons-make-annotation glyph (point) |
459 'text nil nil nil rightp))) | |
460 (when (and part gnus-picons-display-as-address) | 460 (when (and part gnus-picons-display-as-address) |
461 (set-annotation-data new (cons new | 461 (set-annotation-data new (cons new |
462 (make-glyph (vector 'string :data part)))) | 462 (make-glyph (vector 'string :data part)))) |
463 (set-annotation-action new 'gnus-picons-action-toggle)) | 463 (set-annotation-action new 'gnus-picons-action-toggle)) |
464 (nconc | 464 (nconc |
465 (list new) | 465 (list new) |
466 (if (and (eq major-mode 'gnus-article-mode) | 466 (if (and (eq major-mode 'gnus-article-mode) |
467 (not gnus-picons-display-as-address) | 467 (not gnus-picons-display-as-address) |
468 (not part)) | 468 (not part)) |
469 (list (make-annotation [string :data " "] | 469 (list (gnus-picons-make-annotation [string :data " "] (point) |
470 (point) 'text nil nil nil rightp)))))) | 470 'text nil nil nil rightp)))))) |
471 | 471 |
472 (defun gnus-picons-action-toggle (data) | 472 (defun gnus-picons-action-toggle (data) |
473 "Toggle annotation" | 473 "Toggle annotation" |
474 (interactive "e") | 474 (interactive "e") |
475 (let* ((annot (car data)) | 475 (let* ((annot (car data)) |
478 (set-annotation-data annot (cons annot glyph)))) | 478 (set-annotation-data annot (cons annot glyph)))) |
479 | 479 |
480 (defun gnus-picons-clear-cache () | 480 (defun gnus-picons-clear-cache () |
481 "Clear the picons cache" | 481 "Clear the picons cache" |
482 (interactive) | 482 (interactive) |
483 (setq gnus-picons-glyph-alist nil)) | 483 (setq gnus-picons-glyph-alist nil |
484 gnus-picons-url-alist nil)) | |
484 | 485 |
485 (gnus-add-shutdown 'gnus-picons-close 'gnus) | 486 (gnus-add-shutdown 'gnus-picons-close 'gnus) |
486 | 487 |
487 (defun gnus-picons-close () | 488 (defun gnus-picons-close () |
488 "Shut down the picons." | 489 "Shut down the picons." |
495 (require 'w3-forms) | 496 (require 'w3-forms) |
496 | 497 |
497 (defun gnus-picons-url-retrieve (url fn arg) | 498 (defun gnus-picons-url-retrieve (url fn arg) |
498 (let ((old-asynch (default-value 'url-be-asynchronous)) | 499 (let ((old-asynch (default-value 'url-be-asynchronous)) |
499 (url-working-buffer (generate-new-buffer " *picons*")) | 500 (url-working-buffer (generate-new-buffer " *picons*")) |
500 (url-request-method nil) | |
501 (url-package-name "Gnus") | 501 (url-package-name "Gnus") |
502 (url-package-version gnus-version-number)) | 502 (url-package-version gnus-version-number) |
503 url-request-method) | |
503 (setq-default url-be-asynchronous t) | 504 (setq-default url-be-asynchronous t) |
504 (save-excursion | 505 (save-excursion |
505 (set-buffer url-working-buffer) | 506 (set-buffer url-working-buffer) |
506 (setq url-be-asynchronous t | 507 (setq url-be-asynchronous t |
507 url-show-status nil | |
508 url-current-callback-data arg | 508 url-current-callback-data arg |
509 url-current-callback-func fn) | 509 url-current-callback-func fn) |
510 (url-retrieve url t)) | 510 (url-retrieve url t)) |
511 (setq-default url-be-asynchronous old-asynch))) | 511 (setq-default url-be-asynchronous old-asynch))) |
512 | 512 |
586 (nreverse res))) | 586 (nreverse res))) |
587 | 587 |
588 ;;; picon network display functions : | 588 ;;; picon network display functions : |
589 | 589 |
590 (defun gnus-picons-network-display-internal (sym-ann glyph part right-p) | 590 (defun gnus-picons-network-display-internal (sym-ann glyph part right-p) |
591 (set-buffer | 591 (gnus-picons-set-buffer) |
592 (get-buffer-create (gnus-get-buffer-name gnus-picons-display-where))) | |
593 (set sym-ann (nconc (symbol-value sym-ann) | 592 (set sym-ann (nconc (symbol-value sym-ann) |
594 (gnus-picons-display-picon-or-name glyph part right-p))) | 593 (gnus-picons-display-picon-or-name glyph part right-p))) |
595 (gnus-picons-next-job-internal)) | 594 (gnus-picons-next-job-internal)) |
596 | 595 |
597 (defun gnus-picons-network-display-callback (url part sym-ann right-p) | 596 (defun gnus-picons-network-display-callback (url part sym-ann right-p) |
598 (let ((glyph (gnus-picons-make-glyph (cdr (assoc url-current-mime-type | 597 (let ((glyph (gnus-picons-make-glyph (cdr (assoc url-current-mime-type |
599 w3-image-mappings))))) | 598 w3-image-mappings))))) |
600 (kill-buffer (current-buffer)) | 599 (kill-buffer (current-buffer)) |
601 (push (cons url glyph) gnus-picons-glyph-alist) | 600 (push (cons url glyph) gnus-picons-glyph-alist) |
602 (gnus-picons-network-display-internal sym-ann glyph part right-p))) | 601 ;; only do the job if it has not been preempted. |
602 (if (equal gnus-picons-job-already-running | |
603 (list sym-ann 'picon url part right-p)) | |
604 (gnus-picons-network-display-internal sym-ann glyph part right-p) | |
605 (gnus-picons-next-job-internal)))) | |
603 | 606 |
604 (defun gnus-picons-network-display (url part sym-ann right-p) | 607 (defun gnus-picons-network-display (url part sym-ann right-p) |
605 (let ((cache (assoc url gnus-picons-glyph-alist))) | 608 (let ((cache (assoc url gnus-picons-glyph-alist))) |
606 (if (or cache (null url)) | 609 (if (or cache (null url)) |
607 (gnus-picons-network-display-internal sym-ann (cdr cache) part right-p) | 610 (gnus-picons-network-display-internal sym-ann (cdr cache) part right-p) |
663 (push (setq cache (cons curkey (cdr picon))) | 666 (push (setq cache (cons curkey (cdr picon))) |
664 gnus-picons-url-alist))) | 667 gnus-picons-url-alist))) |
665 (if (and gnus-picons-display-as-address new-jobs) | 668 (if (and gnus-picons-display-as-address new-jobs) |
666 (push (list sym-ann "@" right-p) new-jobs)) | 669 (push (list sym-ann "@" right-p) new-jobs)) |
667 (push (list sym-ann 'picon (cdr cache) user right-p) new-jobs)) | 670 (push (list sym-ann 'picon (cdr cache) user right-p) new-jobs)) |
668 (setq gnus-picons-jobs-alist (nconc (nreverse new-jobs) | 671 (if (and gnus-picons-display-as-address (not right-p)) |
669 gnus-picons-jobs-alist)) | 672 (push (list sym-ann 'bar right-p) new-jobs)) |
673 ;; only put the jobs in the queue if this job has not been preempted. | |
674 (if (equal gnus-picons-job-already-running | |
675 (list sym-ann 'search user addrs dbs right-p)) | |
676 (setq gnus-picons-jobs-alist | |
677 (nconc (if (and gnus-picons-display-as-address right-p) | |
678 (list (list sym-ann 'bar right-p))) | |
679 (nreverse new-jobs) | |
680 gnus-picons-jobs-alist))) | |
670 (gnus-picons-next-job-internal))) | 681 (gnus-picons-next-job-internal))) |
671 | 682 |
672 (defun gnus-picons-network-search-callback (user addrs dbs sym-ann right-p) | 683 (defun gnus-picons-network-search-callback (user addrs dbs sym-ann right-p) |
673 (gnus-picons-network-search-internal user addrs dbs sym-ann right-p | 684 (gnus-picons-network-search-internal user addrs dbs sym-ann right-p |
674 (prog1 (gnus-picons-parse-filenames) | 685 (prog1 (gnus-picons-parse-filenames) |
694 'gnus-picons-network-search-callback | 705 'gnus-picons-network-search-callback |
695 (list user addrs dbs sym-ann right-p)) | 706 (list user addrs dbs sym-ann right-p)) |
696 (gnus-picons-network-search-internal user addrs dbs sym-ann right-p)))) | 707 (gnus-picons-network-search-internal user addrs dbs sym-ann right-p)))) |
697 | 708 |
698 ;;; Main jobs dispatcher function | 709 ;;; Main jobs dispatcher function |
699 ;; Given that XEmacs is not really multi threaded, this locking should | |
700 ;; be sufficient | |
701 | 710 |
702 (defun gnus-picons-next-job-internal () | 711 (defun gnus-picons-next-job-internal () |
703 (if gnus-picons-jobs-alist | 712 (if (setq gnus-picons-job-already-running (pop gnus-picons-jobs-alist)) |
704 (let* ((job (pop gnus-picons-jobs-alist)) | 713 (let* ((job gnus-picons-job-already-running) |
705 (sym-ann (pop job)) | 714 (sym-ann (pop job)) |
706 (tag (pop job))) | 715 (tag (pop job))) |
707 (if tag | 716 (if tag |
708 (cond ((stringp tag);; (SYM-ANN "..." RIGHT-P) | 717 (cond ((stringp tag);; (SYM-ANN "..." RIGHT-P) |
709 (gnus-picons-network-display-internal sym-ann nil tag | 718 (gnus-picons-network-display-internal sym-ann nil tag |
710 (pop job))) | 719 (pop job))) |
720 ((eq 'bar tag) | |
721 (gnus-picons-network-display-internal | |
722 sym-ann (gnus-picons-try-face gnus-xmas-glyph-directory | |
723 "bar.") | |
724 nil (pop job))) | |
711 ((eq 'search tag);; (SYM-ANN 'search USER ADDRS DBS RIGHT-P) | 725 ((eq 'search tag);; (SYM-ANN 'search USER ADDRS DBS RIGHT-P) |
712 (gnus-picons-network-search | 726 (gnus-picons-network-search |
713 (pop job) (pop job) (pop job) sym-ann (pop job))) | 727 (pop job) (pop job) (pop job) sym-ann (pop job))) |
714 ((eq 'picon tag);; (SYM-ANN 'picon URL PART RIGHT-P) | 728 ((eq 'picon tag);; (SYM-ANN 'picon URL PART RIGHT-P) |
715 (gnus-picons-network-display | 729 (gnus-picons-network-display |
716 (pop job) (pop job) sym-ann (pop job))) | 730 (pop job) (pop job) sym-ann (pop job))) |
717 (t (error "Unknown picon job tag %s" tag))))) | 731 (t (setq gnus-picons-job-already-running nil) |
718 (setq gnus-picons-job-already-running nil))) | 732 (error "Unknown picon job tag %s" tag))))))) |
719 | 733 |
720 (defun gnus-picons-next-job () | 734 (defun gnus-picons-next-job () |
721 "Start processing the job queue." | 735 "Start processing the job queue if it is not in progress" |
722 (unless gnus-picons-job-already-running | 736 (unless gnus-picons-job-already-running |
723 (setq gnus-picons-job-already-running t) | |
724 (gnus-picons-next-job-internal))) | 737 (gnus-picons-next-job-internal))) |
725 | 738 |
726 (provide 'gnus-picon) | 739 (provide 'gnus-picon) |
727 | 740 |
728 ;;; gnus-picon.el ends here | 741 ;;; gnus-picon.el ends here |