1 ;;; gnus-picon.el --- displaying pretty icons in Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
4 ;; Free Software Foundation, Inc.
6 ;; Author: Wes Hardaker <hardaker@ece.ucdavis.edu>
7 ;; Keywords: news xpm annotation glyph faces
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 2, or (at your option)
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; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
33 (if (featurep 'xemacs)
34 (require 'annotations)))
42 "Show pictures of people, domains, and newsgroups.
43 For this to work, you must switch on the `gnus-treat-display-picons'
47 (defcustom gnus-picons-display-where 'picons
48 "Where to display the group and article icons.
49 Valid values are `article' and `picons'."
50 :type '(choice symbol string)
53 (defcustom gnus-picons-has-modeline-p t
54 "*Whether the picons window should have a modeline.
55 This is only useful if `gnus-picons-display-where' is `picons'."
59 (defcustom gnus-picons-database '("/usr/local/faces" "/usr/lib/picon")
60 "*Defines the location of the faces database.
61 For information on obtaining this database of pretty pictures, please
62 see http://www.cs.indiana.edu/picons/ftp/index.html"
66 (defcustom gnus-picons-news-directories '("news")
67 "*List of directories to search for newsgroups faces."
68 :type '(repeat string)
71 (defcustom gnus-picons-user-directories '("local" "users" "usenix" "misc")
72 "*List of directories to search for user faces."
73 :type '(repeat string)
76 (defcustom gnus-picons-domain-directories '("domains")
77 "*List of directories to search for domain faces.
78 Some people may want to add \"unknown\" to this list."
79 :type '(repeat string)
82 (defcustom gnus-picons-refresh-before-display nil
83 "*If non-nil, display the article buffer before computing the picons."
87 (defcustom gnus-picons-group-excluded-groups nil
88 "*If this regexp matches the group name, group picons will be disabled."
92 (defcustom gnus-picons-display-as-address t
93 "*If t display textual email addresses along with pictures."
97 (defcustom gnus-picons-file-suffixes
99 (let ((types (list "xbm")))
100 (when (featurep 'gif)
102 (when (featurep 'xpm)
105 "*List of suffixes on picon file names to try."
106 :type '(repeat string)
109 (defcustom gnus-picons-display-article-move-p nil
110 "*Whether to move point to first empty line when displaying picons.
111 This has only an effect if `gnus-picons-display-where' has value `article'."
115 (defcustom gnus-picons-clear-cache-on-shutdown t
116 "*Whether to clear the picons cache when exiting gnus.
117 Gnus caches every picons it finds while it is running. This saves
118 some time in the search process but eats some memory. If this
119 variable is set to nil, Gnus will never clear the cache itself; you
120 will have to manually call `gnus-picons-clear-cache' to clear it.
121 Otherwise the cache will be cleared every time you exit Gnus."
125 (defcustom gnus-picons-piconsearch-url nil
126 "*The url to query for picons. Setting this to nil will disable it.
127 The only publicly available address currently known is
128 http://www.cs.indiana.edu:800/piconsearch. If you know of any other,
129 please tell me so that we can list it."
130 :type '(choice (const :tag "Disable" :value nil)
131 (const :tag "www.cs.indiana.edu"
132 :value "http://www.cs.indiana.edu:800/piconsearch")
136 (defface gnus-picons-xbm-face '((t (:foreground "black" :background "white")))
137 "Face to show xbm picons in."
140 (defface gnus-picons-face '((t (:foreground "black" :background "white")))
141 "Face to show picons in."
144 (defcustom gnus-picons-setup-hook nil
145 "Hook run in Picons buffers."
149 ;;; Internal variables:
151 (defvar gnus-picons-setup-p nil)
152 (defvar gnus-picons-processes-alist nil
153 "Picons processes currently running and their environment.")
154 (defvar gnus-picons-glyph-alist nil
155 "Picons glyphs cache.
156 List of pairs (KEY . GLYPH) where KEY is either a filename or an URL.")
157 (defvar gnus-picons-url-alist nil
158 "Picons file names cache.
159 List of pairs (KEY . NAME) where KEY is (USER HOST DBS) and NAME is an URL.")
161 (defvar gnus-picons-jobs-alist nil
162 "List of jobs that still need be done.
163 This is a list of (SYM-ANN TAG ARGS...) where SYM-ANN three annotations list,
164 TAG is one of `picon' or `search' indicating that the job should query a
165 picon or do a search for picons file names, and ARGS is some additionnal
166 arguments necessary for the job.")
168 (defvar gnus-picons-job-already-running nil
169 "Lock to ensure only one stream of http requests is running.")
173 (defun gnus-picons-remove-all ()
174 "Removes all picons from the Gnus display(s)."
176 ;;(map-extents (function (lambda (ext unused) (delete-annotation ext) nil))
177 ;; nil nil nil nil nil 'gnus-picon)
178 (setq gnus-picons-jobs-alist '())
179 ;; notify running job that it may have been preempted
180 (if (and (listp gnus-picons-job-already-running)
181 gnus-picons-job-already-running)
182 (setq gnus-picons-job-already-running t)))
184 (defun gnus-get-buffer-name (variable)
185 "Returns the buffer name associated with the contents of a variable."
186 (let ((buf (gnus-get-buffer-create
187 (gnus-window-to-buffer-helper
188 (cdr (assq variable gnus-window-to-buffer))))))
192 (defun gnus-picons-buffer-name ()
193 (cond ((or (stringp gnus-picons-display-where)
194 (bufferp gnus-picons-display-where))
195 gnus-picons-display-where)
196 ((eq gnus-picons-display-where 'picons)
197 (if gnus-single-article-buffer
199 (concat "*Picons " gnus-newsgroup-name "*")))
201 (gnus-get-buffer-name gnus-picons-display-where))))
203 (defun gnus-picons-kill-buffer ()
204 (let ((buf (get-buffer (gnus-picons-buffer-name))))
205 (when (and (buffer-live-p buf)
206 (string-match "Picons" (buffer-name buf)))
209 (defun gnus-picons-setup-buffer ()
210 (let ((name (gnus-picons-buffer-name)))
212 (if (and (get-buffer name)
213 (with-current-buffer name
214 gnus-picons-setup-p))
216 (set-buffer (gnus-get-buffer-create name))
217 (buffer-disable-undo)
218 (setq buffer-read-only t)
219 (run-hooks 'gnus-picons-setup-hook)
220 (set (make-local-variable 'gnus-picons-setup-p) t)
221 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-picons-kill-buffer))
224 (defun gnus-picons-set-buffer ()
225 (set-buffer (gnus-picons-setup-buffer))
226 (goto-char (point-min))
227 (if (and (eq gnus-picons-display-where 'article)
228 gnus-picons-display-article-move-p)
229 (if (search-forward "\n\n" nil t)
231 (goto-char (point-max)))
232 (setq buffer-read-only t)
233 (unless gnus-picons-has-modeline-p
234 (set-specifier has-modeline-p
235 (list (list (current-buffer)
236 (cons nil gnus-picons-has-modeline-p)))))))
238 (defun gnus-picons-prepare-for-annotations ()
239 "Prepare picons buffer for putting annotations."
240 ;; let drawing catch up
241 (when gnus-picons-refresh-before-display
243 (gnus-picons-set-buffer)
244 (gnus-picons-remove-all))
246 ;; (defun gnus-picons-make-annotation (&rest args)
247 ;; (let ((annot (apply 'make-annotation args)))
248 ;; (set-extent-property annot 'gnus-picon t)
249 ;; (set-extent-property annot 'duplicable t)
252 (defun gnus-picons-make-annotation (&rest args)
255 (defun gnus-article-display-picons ()
256 "Display faces for an author and her domain in gnus-picons-display-where."
259 (when (and (or (not (fboundp 'device-type)) (equal (device-type) 'x))
260 (setq from (mail-fetch-field "from"))
261 (setq from (downcase (or (cadr (mail-extract-address-components
264 (or (setq at-idx (string-match "@" from))
265 (setq at-idx (length from))))
267 (let ((username (downcase (substring from 0 at-idx)))
268 (addrs (if (eq at-idx (length from))
269 (if gnus-local-domain
270 (message-tokenize-header gnus-local-domain "."))
271 (message-tokenize-header (substring from (1+ at-idx))
273 (gnus-picons-prepare-for-annotations)
274 (gnus-group-display-picons)
275 (unless gnus-picons-display-article-move-p
276 (let ((buffer-read-only nil)
277 (case-fold-search t))
278 (when (re-search-forward "^From *: *" nil t)
279 (when (search-forward from (gnus-point-at-eol) t)
280 (gnus-put-text-property
281 (match-beginning 0) (match-end 0)
283 (if (null gnus-picons-piconsearch-url)
285 (gnus-picons-display-pairs (gnus-picons-lookup-pairs
287 gnus-picons-domain-directories)
288 gnus-picons-display-as-address
290 (if (and gnus-picons-display-as-address addrs)
291 (gnus-picons-make-annotation
292 [string :data "@"] nil 'text nil nil nil t))
293 (gnus-picons-display-picon-or-name
294 (gnus-picons-lookup-user username addrs)
296 (push (list 'gnus-article-annotations 'search username addrs
297 gnus-picons-domain-directories t (point-marker))
298 gnus-picons-jobs-alist)
299 (gnus-picons-next-job)))))))
301 (defun gnus-group-display-picons ()
302 "Display icons for the group in the `gnus-picons-display-where' buffer."
304 (when (and (featurep 'xpm)
305 (or (not (fboundp 'device-type)) (equal (device-type) 'x))
306 (or (null gnus-picons-group-excluded-groups)
307 (not (string-match gnus-picons-group-excluded-groups
308 gnus-newsgroup-name))))
309 (let* ((newsgroups (mail-fetch-field "newsgroups"))
311 (if (or gnus-picons-display-article-move-p
313 (list (gnus-group-real-name gnus-newsgroup-name))
314 (split-string newsgroups ",")))
317 (gnus-picons-prepare-for-annotations)
318 (while (setq group (pop groups))
319 (unless gnus-picons-display-article-move-p
320 (let ((buffer-read-only nil)
321 (case-fold-search t))
322 (goto-char (point-min))
323 (if (and (re-search-forward "^Newsgroups *: *" nil t)
324 (search-forward group (gnus-point-at-eol) t))
325 (gnus-put-text-property
326 (match-beginning 0) (match-end 0)
328 (let ((article-goto-body-goes-to-point-min-p nil))
331 (backward-char 1)))))
332 (if (null gnus-picons-piconsearch-url)
333 (gnus-picons-display-pairs
334 (gnus-picons-lookup-pairs
335 (reverse (split-string group "\\."))
336 gnus-picons-news-directories)
338 (push (list 'gnus-group-annotations 'search nil
339 (split-string group "\\.")
340 (if (listp gnus-picons-news-directories)
341 gnus-picons-news-directories
342 (list gnus-picons-news-directories))
344 gnus-picons-jobs-alist)
345 (gnus-picons-next-job))
347 (add-hook 'gnus-summary-exit-hook 'gnus-picons-remove-all))))))
349 (defun gnus-picons-lookup-internal (addrs directory)
350 (let ((dbs gnus-picons-database)
353 (setq dbs (list dbs)))
354 (while (and (not result)
356 (setq dir (expand-file-name directory gnus-picons-database))
358 (gnus-picons-try-face
359 (dolist (part (reverse addrs) dir)
360 (setq dir (expand-file-name part dir))))))
363 (defun gnus-picons-lookup (addrs dirs)
364 "Lookup the picon for ADDRS in databases DIRS.
365 Returns the picon filename or nil if none found."
367 (while (and dirs (null result))
368 (setq result (gnus-picons-lookup-internal addrs (pop dirs))))
371 (defun gnus-picons-lookup-user-internal (user domains)
372 (let ((dirs gnus-picons-user-directories)
373 domains-tmp dir picon)
374 (while (and dirs (null picon))
375 (setq domains-tmp domains
377 (while (and domains-tmp
378 (null (setq picon (gnus-picons-lookup-internal
379 (cons user domains-tmp) dir))))
381 ;; Also make a try in MISC subdir
383 (setq picon (gnus-picons-lookup-internal (list user "MISC") dir))))
386 (defun gnus-picons-lookup-user (user domains)
387 "Lookup the picon for USER at DOMAINS.
388 USER is a string containing a name.
389 DOMAINS is a list of strings from the fully qualified domain name."
390 (or (gnus-picons-lookup-user-internal user domains)
391 (gnus-picons-lookup-user-internal "unknown" domains)))
393 (defun gnus-picons-lookup-pairs (domains directories)
394 "Lookup picons for DOMAINS and all its parents in DIRECTORIES.
395 Returns a list of PAIRS whose CAR is the picon filename or nil if
396 none, and whose CDR is the corresponding element of DOMAINS."
398 (setq directories (if (listp directories)
402 (push (list (gnus-picons-lookup (cons "unknown" domains) directories)
407 (defun gnus-picons-display-picon-or-name (picon name &optional right-p)
408 (cond (picon (gnus-picons-display-glyph picon name right-p))
409 (gnus-picons-display-as-address (list (gnus-picons-make-annotation
410 (vector 'string :data name)
412 nil nil nil right-p)))))
414 (defun gnus-picons-display-pairs (pairs &optional bar-p dot-p right-p)
415 "Display picons in list PAIRS."
416 (let ((domain-p (and gnus-picons-display-as-address dot-p))
418 (when (and bar-p domain-p right-p
419 gnus-picons-display-article-move-p)
420 (setq picons (gnus-picons-display-glyph
421 (let ((gnus-picons-file-suffixes '("xbm")))
422 (gnus-picons-try-face
423 gnus-xmas-glyph-directory "bar."))
425 (while (setq pair (pop pairs))
426 (setq picons (nconc picons
427 (gnus-picons-display-picon-or-name
428 (car pair) (cadr pair) right-p)
429 (if (and domain-p pairs)
430 (list (gnus-picons-make-annotation
431 (vector 'string :data dot-p)
432 nil 'text nil nil nil right-p))))))
435 (defun gnus-picons-try-face (dir &optional filebase)
436 (let* ((dir (file-name-as-directory dir))
437 (filebase (or filebase "face."))
438 (key (concat dir filebase))
439 (glyph (cdr (assoc key gnus-picons-glyph-alist)))
440 (suffixes gnus-picons-file-suffixes)
442 (while (setq suf (pop suffixes))
443 (when (file-exists-p (setq f (expand-file-name
444 (concat filebase suf)
447 glyph (make-glyph f))
448 (if (equal suf "xbm")
449 (set-glyph-face glyph 'gnus-picons-xbm-face)
450 (set-glyph-face glyph 'gnus-picons-face))
451 (push (cons key glyph) gnus-picons-glyph-alist)))
454 (defun gnus-picons-display-glyph (glyph &optional part rightp)
455 (set-glyph-baseline glyph 70)
456 (let ((new (gnus-picons-make-annotation
457 glyph (point) 'text nil nil nil rightp)))
458 (when (and part gnus-picons-display-as-address)
460 new (cons new (make-glyph (vector 'string :data part))))
461 (set-annotation-action new 'gnus-picons-action-toggle))
464 (if (and (eq major-mode 'gnus-article-mode)
465 (not gnus-picons-display-as-address)
467 (list (gnus-picons-make-annotation [string :data " "] (point)
468 'text nil nil nil rightp))))))
470 (defun gnus-picons-action-toggle (data)
473 (let* ((annot (car data))
474 (glyph (annotation-glyph annot)))
475 (set-annotation-glyph annot (cdr data))
476 (set-annotation-data annot (cons annot glyph))))
478 (defun gnus-picons-clear-cache ()
479 "Clear the picons cache."
481 (setq gnus-picons-glyph-alist nil
482 gnus-picons-url-alist nil))
484 (gnus-add-shutdown 'gnus-picons-close 'gnus)
486 (defun gnus-picons-close ()
487 "Shut down the picons."
488 (if gnus-picons-clear-cache-on-shutdown
489 (gnus-picons-clear-cache)))
491 ;;; Query a remote DB. This requires some stuff from w3 !
496 (require 'w3-forms)))
498 (defun gnus-picons-url-retrieve (url fn arg)
499 (let ((old-asynch (default-value 'url-be-asynchronous))
500 (url-working-buffer (generate-new-buffer " *picons*"))
501 (url-package-name "Gnus")
502 (url-package-version gnus-version-number)
504 (setq-default url-be-asynchronous t)
506 (set-buffer url-working-buffer)
507 (setq url-be-asynchronous t
508 url-current-callback-data arg
509 url-current-callback-func fn)
510 (url-retrieve url t))
511 (setq-default url-be-asynchronous old-asynch)))
513 (defun gnus-picons-make-glyph (type)
514 "Make a TYPE glyph using current buffer as data. Handles xbm nicely."
515 (cond ((null type) nil)
516 ((eq type 'xbm) (let ((fname (make-temp-name "/tmp/picon")))
517 (write-region (point-min) (point-max) fname
519 (prog1 (make-glyph (vector 'xbm :file fname))
520 (delete-file fname))))
521 (t (make-glyph (vector type :data (buffer-string))))))
523 ;;; Parsing of piconsearch result page.
526 ;; 1 - each value field has the form: "<strong>key</strong> = <kbd>value</kbd>"
527 ;; 2 - a "<p>" separates the keywords from the results
528 ;; 3 - every results begins by the path within the database at the beginning
529 ;; of the line in raw text.
530 ;; 3b - and the href following it is the preferred image type.
532 ;; if 1 or 2 is not met, it will probably cause an error. The other
533 ;; will go undetected
535 (defun gnus-picons-parse-value (name)
536 (goto-char (point-min))
537 (if (re-search-forward (concat "<strong>"
539 "</strong> *= *<kbd> *\\([^ <][^<]*\\) *</kbd>")
541 (buffer-substring (match-beginning 1) (match-end 1))))
543 (defun gnus-picons-parse-filenames ()
544 ;; returns an alist of ((USER ADDRS DB) . URL)
545 (let ((case-fold-search t)
546 (user (gnus-picons-parse-value "user"))
547 (host (gnus-picons-parse-value "host"))
548 (dbs (message-tokenize-header (gnus-picons-parse-value "db") " "))
549 start-re cur-db cur-host cur-user types res)
550 ;; now point will be somewhere in the header. Find beginning of
552 (when (and user host dbs)
556 "^\\(" (mapconcat 'regexp-quote dbs "\\|") "\\)/"
558 "\\(\\(" (mapconcat 'regexp-quote
559 (message-tokenize-header host ".") "/\\|")
562 "\\(" (regexp-quote user) "\\|unknown\\)/"
564 (re-search-forward "<p>[ \t\n]*")
565 (while (re-search-forward start-re nil t)
566 (setq cur-db (buffer-substring (match-beginning 1) (match-end 1))
567 cur-host (buffer-substring (match-beginning 2) (match-end 2))
568 cur-user (buffer-substring (match-beginning 4) (match-end 4))
569 cur-host (nreverse (message-tokenize-header cur-host "/")))
570 ;; XXX - KLUDGE: there is a blank picon in news/MISC/unknown
571 (unless (and (string-equal cur-db "news")
572 (string-equal cur-user "unknown")
573 (equal cur-host '("MISC")))
574 ;; ok now we have found an entry (USER HOST DB), find the
575 ;; corresponding picon URL
577 ;; restrict region to this entry
578 (narrow-to-region (point) (search-forward "<br>"))
579 (goto-char (point-min))
580 (setq types gnus-picons-file-suffixes)
582 (not (re-search-forward
583 (concat "<a[ \t\n]+href=\"\\([^\"]*\\."
584 (regexp-quote (car types)) "\\)\"")
587 (push (cons (list cur-user cur-host cur-db)
588 (buffer-substring (match-beginning 1) (match-end 1)))
592 ;;; picon network display functions :
594 (defun gnus-picons-network-display-internal (sym-ann glyph part right-p marker)
595 (let ((buf (marker-buffer marker))
596 (pos (marker-position marker)))
601 (gnus-picons-display-picon-or-name glyph part right-p))))
602 (gnus-picons-next-job-internal))
604 (defun gnus-picons-network-display-callback (url part sym-ann right-p marker)
605 (let ((glyph (gnus-picons-make-glyph (cdr (assoc url-current-mime-type
606 w3-image-mappings)))))
607 (kill-buffer (current-buffer))
608 (push (cons url glyph) gnus-picons-glyph-alist)
609 ;; only do the job if it has not been preempted.
610 (if (equal gnus-picons-job-already-running
611 (list sym-ann 'picon url part right-p marker))
612 (gnus-picons-network-display-internal
613 sym-ann glyph part right-p marker)
614 (gnus-picons-next-job-internal))))
616 (defun gnus-picons-network-display (url part sym-ann right-p marker)
617 (let ((cache (assoc url gnus-picons-glyph-alist)))
618 (if (or cache (null url))
619 (gnus-picons-network-display-internal
620 sym-ann (cdr cache) part right-p marker)
621 (gnus-picons-url-retrieve url 'gnus-picons-network-display-callback
622 (list url part sym-ann right-p marker)))))
624 ;;; search job functions
626 (defun gnus-picons-display-bar-p ()
627 (if (eq gnus-picons-display-where 'article)
628 gnus-picons-display-article-move-p
629 gnus-picons-display-as-address))
631 (defun gnus-picons-network-search-internal (user addrs dbs sym-ann right-p
632 marker &optional fnames)
633 (let (curkey dom pfx url dbs-tmp cache new-jobs)
634 ;; First do the domain search
635 (dolist (part (if right-p
638 (setq pfx (nconc (list part) pfx)
639 dom (cond ((and dom right-p) (concat part "." dom))
640 (dom (concat dom "." part))
642 curkey (list "unknown" dom dbs))
643 (when (null (setq cache (assoc curkey gnus-picons-url-alist)))
644 ;; This one is not yet in the cache, create a new entry
645 ;; Search for an entry
648 (while (and dbs-tmp (null url))
649 (setq url (or (cdr (assoc (list "unknown" pfx (car dbs-tmp)) fnames))
651 ;; This is the first component. Try the
652 ;; catch-all MISC component
653 (cdr (assoc (list "unknown"
658 (push (setq cache (cons curkey url)) gnus-picons-url-alist))
659 ;; Put this glyph in the job list
660 (if (and (not (eq dom part)) gnus-picons-display-as-address)
661 (push (list sym-ann "." right-p marker) new-jobs))
662 (push (list sym-ann 'picon (cdr cache) part right-p marker) new-jobs))
663 ;; next, the user search
665 (setq curkey (list user dom gnus-picons-user-directories))
666 (if (null (setq cache (assoc curkey gnus-picons-url-alist)))
667 (let ((users (list user "unknown"))
668 dirs usr domains-tmp dir picon)
669 (while (and users (null picon))
670 (setq dirs gnus-picons-user-directories
672 (while (and dirs (null picon))
673 (setq domains-tmp addrs
675 (while (and domains-tmp
676 (null (setq picon (assoc (list usr domains-tmp dir)
680 (setq picon (assoc (list usr '("MISC") dir) fnames)))))
681 (push (setq cache (cons curkey (cdr picon)))
682 gnus-picons-url-alist)))
683 (if (and gnus-picons-display-as-address new-jobs)
684 (push (list sym-ann "@" right-p marker) new-jobs))
685 (push (list sym-ann 'picon (cdr cache) user right-p marker) new-jobs))
686 (if (and (gnus-picons-display-bar-p) (not right-p))
687 (push (list sym-ann 'bar right-p marker) new-jobs))
688 ;; only put the jobs in the queue if this job has not been preempted.
689 (if (equal gnus-picons-job-already-running
690 (list sym-ann 'search user addrs dbs right-p marker))
691 (setq gnus-picons-jobs-alist
692 (nconc (if (and (gnus-picons-display-bar-p) right-p)
693 (list (list sym-ann 'bar right-p marker)))
695 gnus-picons-jobs-alist)))
696 (gnus-picons-next-job-internal)))
698 (defun gnus-picons-network-search-callback (user addrs dbs sym-ann right-p
700 (gnus-picons-network-search-internal
701 user addrs dbs sym-ann right-p marker
703 (gnus-picons-parse-filenames)
704 (kill-buffer (current-buffer)))))
706 ;; Initiate a query on the picon database
707 (defun gnus-picons-network-search (user addrs dbs sym-ann right-p marker)
708 (let* ((host (mapconcat 'identity addrs "."))
709 (key (list (or user "unknown") host (if user
710 gnus-picons-user-directories
712 (cache (assoc key gnus-picons-url-alist)))
714 (gnus-picons-url-retrieve
715 (concat gnus-picons-piconsearch-url
716 "?user=" (w3-form-encode-xwfu (or user "unknown"))
717 "&host=" (w3-form-encode-xwfu host)
718 "&db=" (mapconcat 'w3-form-encode-xwfu
721 gnus-picons-user-directories)
724 'gnus-picons-network-search-callback
725 (list user addrs dbs sym-ann right-p marker))
726 (gnus-picons-network-search-internal
727 user addrs dbs sym-ann right-p marker))))
729 ;;; Main jobs dispatcher function
731 (defun gnus-picons-next-job-internal ()
732 (when (setq gnus-picons-job-already-running (pop gnus-picons-jobs-alist))
733 (let* ((job gnus-picons-job-already-running)
738 ((stringp tag);; (SYM-ANN "..." RIGHT-P MARKER)
739 (gnus-picons-network-display-internal
740 sym-ann nil tag (pop job) (pop job)))
741 ((eq 'bar tag);; (SYM-ANN 'bar RIGHT-P MARKER)
742 (gnus-picons-network-display-internal
744 (let ((gnus-picons-file-suffixes '("xbm")))
745 (gnus-picons-try-face
746 gnus-xmas-glyph-directory "bar."))
747 nil (pop job) (pop job)))
748 ((eq 'search tag);; (SYM-ANN 'search USER ADDRS DBS RIGHT-P MARKER)
749 (gnus-picons-network-search
750 (pop job) (pop job) (pop job) sym-ann (pop job) (pop job)))
751 ((eq 'picon tag);; (SYM-ANN 'picon URL PART RIGHT-P MARKER)
752 (gnus-picons-network-display
753 (pop job) (pop job) sym-ann (pop job) (pop job)))
755 (setq gnus-picons-job-already-running nil)
756 (error "Unknown picon job tag %s" tag)))))))
758 (defun gnus-picons-next-job ()
759 "Start processing the job queue if it is not in progress."
760 (unless gnus-picons-job-already-running
761 (gnus-picons-next-job-internal)))
763 (provide 'gnus-picon)
765 ;;; gnus-picon.el ends here