1 ;;; gnus-picon.el --- displaying pretty icons in Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000
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.
30 (eval-when-compile (require 'cl))
34 (require 'annotations)
42 "Show pictures of people, domains, and newsgroups (XEmacs).
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"
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)
70 (define-obsolete-variable-alias 'gnus-picons-news-directory
71 'gnus-picons-news-directories)
73 (defcustom gnus-picons-user-directories '("local" "users" "usenix" "misc")
74 "*List of directories to search for user faces."
75 :type '(repeat string)
78 (defcustom gnus-picons-domain-directories '("domains")
79 "*List of directories to search for domain faces.
80 Some people may want to add \"unknown\" to this list."
81 :type '(repeat string)
84 (defcustom gnus-picons-refresh-before-display nil
85 "*If non-nil, display the article buffer before computing the picons."
89 (defcustom gnus-picons-group-excluded-groups nil
90 "*If this regexp matches the group name, group picons will be disabled."
94 (defcustom gnus-picons-display-as-address t
95 "*If t display textual email addresses along with pictures."
99 (defcustom gnus-picons-file-suffixes
101 (let ((types (list "xbm")))
102 (when (featurep 'gif)
103 (setq types (cons "gif" types)))
104 (when (featurep 'xpm)
105 (setq types (cons "xpm" types)))
107 "*List of suffixes on picon file names to try."
108 :type '(repeat string)
111 (defcustom gnus-picons-display-article-move-p nil
112 "*Whether to move point to first empty line when displaying picons.
113 This has only an effect if `gnus-picons-display-where' has value `article'."
117 (defcustom gnus-picons-clear-cache-on-shutdown t
118 "*Whether to clear the picons cache when exiting gnus.
119 Gnus caches every picons it finds while it is running. This saves
120 some time in the search process but eats some memory. If this
121 variable is set to nil, Gnus will never clear the cache itself; you
122 will have to manually call `gnus-picons-clear-cache' to clear it.
123 Otherwise the cache will be cleared every time you exit Gnus."
127 (defcustom gnus-picons-piconsearch-url nil
128 "*The url to query for picons. Setting this to nil will disable it.
129 The only publicly available address currently known is
130 http://www.cs.indiana.edu:800/piconsearch. If you know of any other,
131 please tell me so that we can list it."
132 :type '(choice (const :tag "Disable" :value nil)
133 (const :tag "www.cs.indiana.edu"
134 :value "http://www.cs.indiana.edu:800/piconsearch")
138 (defface gnus-picons-xbm-face '((t (:foreground "black" :background "white")))
139 "Face to show xbm picons in."
142 (defface gnus-picons-face '((t (:foreground "black" :background "white")))
143 "Face to show picons in."
146 (defcustom gnus-picons-setup-hook nil
147 "Hook run in Picons buffers."
151 ;;; Internal variables:
153 (defvar gnus-picons-setup-p nil)
154 (defvar gnus-picons-processes-alist nil
155 "Picons processes currently running and their environment.")
156 (defvar gnus-picons-glyph-alist nil
157 "Picons glyphs cache.
158 List of pairs (KEY . GLYPH) where KEY is either a filename or an URL.")
159 (defvar gnus-picons-url-alist nil
160 "Picons file names cache.
161 List of pairs (KEY . NAME) where KEY is (USER HOST DBS) and NAME is an URL.")
163 (defvar gnus-picons-jobs-alist nil
164 "List of jobs that still need be done.
165 This is a list of (SYM-ANN TAG ARGS...) where SYM-ANN three annotations list,
166 TAG is one of `picon' or `search' indicating that the job should query a
167 picon or do a search for picons file names, and ARGS is some additionnal
168 arguments necessary for the job.")
170 (defvar gnus-picons-job-already-running nil
171 "Lock to ensure only one stream of http requests is running.")
175 (defun gnus-picons-remove-all ()
176 "Removes all picons from the Gnus display(s)."
178 (map-extents (function (lambda (ext unused) (delete-annotation ext) nil))
179 nil nil nil nil nil 'gnus-picon)
180 (setq gnus-picons-jobs-alist '())
181 ;; notify running job that it may have been preempted
182 (if (and (listp gnus-picons-job-already-running)
183 gnus-picons-job-already-running)
184 (setq gnus-picons-job-already-running t)))
186 (defun gnus-get-buffer-name (variable)
187 "Returns the buffer name associated with the contents of a variable."
188 (let ((buf (gnus-get-buffer-create
189 (gnus-window-to-buffer-helper
190 (cdr (assq variable gnus-window-to-buffer))))))
194 (defun gnus-picons-buffer-name ()
195 (cond ((or (stringp gnus-picons-display-where)
196 (bufferp gnus-picons-display-where))
197 gnus-picons-display-where)
198 ((eq gnus-picons-display-where 'picons)
199 (if gnus-single-article-buffer
201 (concat "*Picons " gnus-newsgroup-name "*")))
203 (gnus-get-buffer-name gnus-picons-display-where))))
205 (defun gnus-picons-kill-buffer ()
206 (let ((buf (get-buffer (gnus-picons-buffer-name))))
207 (when (and (buffer-live-p buf)
208 (string-match "Picons" (buffer-name buf)))
211 (defun gnus-picons-setup-buffer ()
212 (let ((name (gnus-picons-buffer-name)))
214 (if (and (get-buffer name)
215 (with-current-buffer name
216 gnus-picons-setup-p))
218 (set-buffer (gnus-get-buffer-create name))
219 (buffer-disable-undo)
220 (setq buffer-read-only t)
221 (run-hooks 'gnus-picons-setup-hook)
222 (set (make-local-variable 'gnus-picons-setup-p) t)
223 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-picons-kill-buffer))
226 (defun gnus-picons-set-buffer ()
227 (set-buffer (gnus-picons-setup-buffer))
228 (goto-char (point-min))
229 (if (and (eq gnus-picons-display-where 'article)
230 gnus-picons-display-article-move-p)
231 (if (search-forward "\n\n" nil t)
233 (goto-char (point-max)))
234 (setq buffer-read-only t)
235 (unless gnus-picons-has-modeline-p
236 (set-specifier has-modeline-p
237 (list (list (current-buffer)
238 (cons nil gnus-picons-has-modeline-p)))))))
240 (defun gnus-picons-prepare-for-annotations ()
241 "Prepare picons buffer for putting annotations."
242 ;; let drawing catch up
243 (when gnus-picons-refresh-before-display
245 (gnus-picons-set-buffer)
246 (gnus-picons-remove-all))
248 (defun gnus-picons-make-annotation (&rest args)
249 (let ((annot (apply 'make-annotation args)))
250 (set-extent-property annot 'gnus-picon t)
251 (set-extent-property annot 'duplicable t)
254 (defun gnus-article-display-picons ()
255 "Display faces for an author and her domain in gnus-picons-display-where."
258 (when (and (featurep 'xpm)
259 (or (not (fboundp 'device-type)) (equal (device-type) 'x))
260 (setq from (mail-fetch-field "from"))
261 (setq from (downcase (or (cadr
262 (funcall gnus-extract-address-components
265 (or (setq at-idx (string-match "@" from))
266 (setq at-idx (length from))))
268 (let ((username (downcase (substring from 0 at-idx)))
269 (addrs (if (eq at-idx (length from))
270 (if gnus-local-domain
271 (message-tokenize-header gnus-local-domain "."))
272 (message-tokenize-header (substring from (1+ at-idx))
274 (gnus-picons-prepare-for-annotations)
275 (gnus-group-display-picons)
276 (unless gnus-picons-display-article-move-p
277 (let ((buffer-read-only nil)
278 (case-fold-search t))
279 (when (re-search-forward "^From *: *" nil t)
280 (when (search-forward from (gnus-point-at-eol) t)
281 (gnus-put-text-property
282 (match-beginning 0) (match-end 0)
284 (if (null gnus-picons-piconsearch-url)
286 (gnus-picons-display-pairs (gnus-picons-lookup-pairs
288 gnus-picons-domain-directories)
289 gnus-picons-display-as-address
291 (if (and gnus-picons-display-as-address addrs)
292 (gnus-picons-make-annotation
293 [string :data "@"] nil 'text nil nil nil t))
294 (gnus-picons-display-picon-or-name
295 (gnus-picons-lookup-user username addrs)
297 (push (list 'gnus-article-annotations 'search username addrs
298 gnus-picons-domain-directories t (point-marker))
299 gnus-picons-jobs-alist)
300 (gnus-picons-next-job)))))))
302 (defun gnus-group-display-picons ()
303 "Display icons for the group in the `gnus-picons-display-where' buffer."
305 (when (and (featurep 'xpm)
306 (or (not (fboundp 'device-type)) (equal (device-type) 'x))
307 (or (null gnus-picons-group-excluded-groups)
308 (not (string-match gnus-picons-group-excluded-groups
309 gnus-newsgroup-name))))
310 (let* ((newsgroups (mail-fetch-field "newsgroups"))
312 (if (or gnus-picons-display-article-move-p
314 (list (gnus-group-real-name gnus-newsgroup-name))
315 (split-string newsgroups ",")))
318 (gnus-picons-prepare-for-annotations)
319 (while (setq group (pop groups))
320 (unless gnus-picons-display-article-move-p
321 (let ((buffer-read-only nil)
322 (case-fold-search t))
323 (goto-char (point-min))
324 (if (and (re-search-forward "^Newsgroups *: *" nil t)
325 (search-forward group (gnus-point-at-eol) t))
326 (gnus-put-text-property
327 (match-beginning 0) (match-end 0)
329 (let ((article-goto-body-goes-to-point-min-p nil))
332 (backward-char 1)))))
333 (if (null gnus-picons-piconsearch-url)
334 (gnus-picons-display-pairs
335 (gnus-picons-lookup-pairs
336 (reverse (split-string group "\\."))
337 gnus-picons-news-directories)
339 (push (list 'gnus-group-annotations 'search nil
340 (split-string group "\\.")
341 (if (listp gnus-picons-news-directories)
342 gnus-picons-news-directories
343 (list gnus-picons-news-directories))
345 gnus-picons-jobs-alist)
346 (gnus-picons-next-job))
348 (add-hook 'gnus-summary-exit-hook 'gnus-picons-remove-all))))))
350 (defun gnus-picons-lookup-internal (addrs dir)
351 (setq dir (expand-file-name dir gnus-picons-database))
352 (gnus-picons-try-face (dolist (part (reverse addrs) dir)
353 (setq dir (expand-file-name part dir)))))
355 (defun gnus-picons-lookup (addrs dirs)
356 "Lookup the picon for ADDRS in databases DIRS.
357 Returns the picon filename or NIL if none found."
359 (while (and dirs (null result))
360 (setq result (gnus-picons-lookup-internal addrs (pop dirs))))
363 (defun gnus-picons-lookup-user-internal (user domains)
364 (let ((dirs gnus-picons-user-directories)
365 domains-tmp dir picon)
366 (while (and dirs (null picon))
367 (setq domains-tmp domains
369 (while (and domains-tmp
370 (null (setq picon (gnus-picons-lookup-internal
371 (cons user domains-tmp) dir))))
373 ;; Also make a try in MISC subdir
375 (setq picon (gnus-picons-lookup-internal (list user "MISC") dir))))
378 (defun gnus-picons-lookup-user (user domains)
379 "Lookup the picon for USER at DOMAINS.
380 USER is a string containing a name.
381 DOMAINS is a list of strings from the fully qualified domain name."
382 (or (gnus-picons-lookup-user-internal user domains)
383 (gnus-picons-lookup-user-internal "unknown" domains)))
385 (defun gnus-picons-lookup-pairs (domains directories)
386 "Lookup picons for DOMAINS and all its parents in DIRECTORIES.
387 Returns a list of PAIRS whose CAR is the picon filename or NIL if
388 none, and whose CDR is the corresponding element of DOMAINS."
390 (setq directories (if (listp directories)
394 (push (list (gnus-picons-lookup (cons "unknown" domains) directories)
399 (defun gnus-picons-display-picon-or-name (picon name &optional right-p)
400 (cond (picon (gnus-picons-display-glyph picon name right-p))
401 (gnus-picons-display-as-address (list (gnus-picons-make-annotation
402 (vector 'string :data name)
404 nil nil nil right-p)))))
406 (defun gnus-picons-display-pairs (pairs &optional bar-p dot-p right-p)
407 "Display picons in list PAIRS."
408 (let ((domain-p (and gnus-picons-display-as-address dot-p))
410 (when (and bar-p domain-p right-p
411 gnus-picons-display-article-move-p)
412 (setq picons (gnus-picons-display-glyph
413 (let ((gnus-picons-file-suffixes '("xbm")))
414 (gnus-picons-try-face
415 gnus-xmas-glyph-directory "bar."))
417 (while (setq pair (pop pairs))
418 (setq picons (nconc picons
419 (gnus-picons-display-picon-or-name
420 (car pair) (cadr pair) right-p)
421 (if (and domain-p pairs)
422 (list (gnus-picons-make-annotation
423 (vector 'string :data dot-p)
424 nil 'text nil nil nil right-p))))))
427 (defun gnus-picons-try-face (dir &optional filebase)
428 (let* ((dir (file-name-as-directory dir))
429 (filebase (or filebase "face."))
430 (key (concat dir filebase))
431 (glyph (cdr (assoc key gnus-picons-glyph-alist)))
432 (suffixes gnus-picons-file-suffixes)
434 (while (setq suf (pop suffixes))
435 (when (file-exists-p (setq f (expand-file-name
436 (concat filebase suf)
439 glyph (make-glyph f))
440 (if (equal suf "xbm")
441 (set-glyph-face glyph 'gnus-picons-xbm-face)
442 (set-glyph-face glyph 'gnus-picons-face))
443 (push (cons key glyph) gnus-picons-glyph-alist)))
446 (defun gnus-picons-display-glyph (glyph &optional part rightp)
447 (set-glyph-baseline glyph 70)
448 (let ((new (gnus-picons-make-annotation
449 glyph (point) 'text nil nil nil rightp)))
450 (when (and part gnus-picons-display-as-address)
452 new (cons new (make-glyph (vector 'string :data part))))
453 (set-annotation-action new 'gnus-picons-action-toggle))
456 (if (and (eq major-mode 'gnus-article-mode)
457 (not gnus-picons-display-as-address)
459 (list (gnus-picons-make-annotation [string :data " "] (point)
460 'text nil nil nil rightp))))))
462 (defun gnus-picons-action-toggle (data)
465 (let* ((annot (car data))
466 (glyph (annotation-glyph annot)))
467 (set-annotation-glyph annot (cdr data))
468 (set-annotation-data annot (cons annot glyph))))
470 (defun gnus-picons-clear-cache ()
471 "Clear the picons cache."
473 (setq gnus-picons-glyph-alist nil
474 gnus-picons-url-alist nil))
476 (gnus-add-shutdown 'gnus-picons-close 'gnus)
478 (defun gnus-picons-close ()
479 "Shut down the picons."
480 (if gnus-picons-clear-cache-on-shutdown
481 (gnus-picons-clear-cache)))
483 ;;; Query a remote DB. This requires some stuff from w3 !
488 (require 'w3-forms)))
490 (defun gnus-picons-url-retrieve (url fn arg)
491 (let ((old-asynch (default-value 'url-be-asynchronous))
492 (url-working-buffer (generate-new-buffer " *picons*"))
493 (url-package-name "Gnus")
494 (url-package-version gnus-version-number)
496 (setq-default url-be-asynchronous t)
498 (set-buffer url-working-buffer)
499 (setq url-be-asynchronous t
500 url-current-callback-data arg
501 url-current-callback-func fn)
502 (url-retrieve url t))
503 (setq-default url-be-asynchronous old-asynch)))
505 (defun gnus-picons-make-glyph (type)
506 "Make a TYPE glyph using current buffer as data. Handles xbm nicely."
507 (cond ((null type) nil)
508 ((eq type 'xbm) (let ((fname (make-temp-name "/tmp/picon")))
509 (write-region (point-min) (point-max) fname
511 (prog1 (make-glyph (vector 'xbm :file fname))
512 (delete-file fname))))
513 (t (make-glyph (vector type :data (buffer-string))))))
515 ;;; Parsing of piconsearch result page.
518 ;; 1 - each value field has the form: "<strong>key</strong> = <kbd>value</kbd>"
519 ;; 2 - a "<p>" separates the keywords from the results
520 ;; 3 - every results begins by the path within the database at the beginning
521 ;; of the line in raw text.
522 ;; 3b - and the href following it is the preferred image type.
524 ;; if 1 or 2 is not met, it will probably cause an error. The other
525 ;; will go undetected
527 (defun gnus-picons-parse-value (name)
528 (goto-char (point-min))
529 (if (re-search-forward (concat "<strong>"
531 "</strong> *= *<kbd> *\\([^ <][^<]*\\) *</kbd>")
533 (buffer-substring (match-beginning 1) (match-end 1))))
535 (defun gnus-picons-parse-filenames ()
536 ;; returns an alist of ((USER ADDRS DB) . URL)
537 (let ((case-fold-search t)
538 (user (gnus-picons-parse-value "user"))
539 (host (gnus-picons-parse-value "host"))
540 (dbs (message-tokenize-header (gnus-picons-parse-value "db") " "))
541 start-re cur-db cur-host cur-user types res)
542 ;; now point will be somewhere in the header. Find beginning of
544 (when (and user host dbs)
548 "^\\(" (mapconcat 'regexp-quote dbs "\\|") "\\)/"
550 "\\(\\(" (mapconcat 'regexp-quote
551 (message-tokenize-header host ".") "/\\|")
554 "\\(" (regexp-quote user) "\\|unknown\\)/"
556 (re-search-forward "<p>[ \t\n]*")
557 (while (re-search-forward start-re nil t)
558 (setq cur-db (buffer-substring (match-beginning 1) (match-end 1))
559 cur-host (buffer-substring (match-beginning 2) (match-end 2))
560 cur-user (buffer-substring (match-beginning 4) (match-end 4))
561 cur-host (nreverse (message-tokenize-header cur-host "/")))
562 ;; XXX - KLUDGE: there is a blank picon in news/MISC/unknown
563 (unless (and (string-equal cur-db "news")
564 (string-equal cur-user "unknown")
565 (equal cur-host '("MISC")))
566 ;; ok now we have found an entry (USER HOST DB), find the
567 ;; corresponding picon URL
569 ;; restrict region to this entry
570 (narrow-to-region (point) (search-forward "<br>"))
571 (goto-char (point-min))
572 (setq types gnus-picons-file-suffixes)
574 (not (re-search-forward
575 (concat "<a[ \t\n]+href=\"\\([^\"]*\\."
576 (regexp-quote (car types)) "\\)\"")
579 (push (cons (list cur-user cur-host cur-db)
580 (buffer-substring (match-beginning 1) (match-end 1)))
584 ;;; picon network display functions :
586 (defun gnus-picons-network-display-internal (sym-ann glyph part right-p marker)
587 (let ((buf (marker-buffer marker))
588 (pos (marker-position marker)))
593 (gnus-picons-display-picon-or-name glyph part right-p))))
594 (gnus-picons-next-job-internal))
596 (defun gnus-picons-network-display-callback (url part sym-ann right-p marker)
597 (let ((glyph (gnus-picons-make-glyph (cdr (assoc url-current-mime-type
598 w3-image-mappings)))))
599 (kill-buffer (current-buffer))
600 (push (cons url glyph) gnus-picons-glyph-alist)
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 marker))
604 (gnus-picons-network-display-internal
605 sym-ann glyph part right-p marker)
606 (gnus-picons-next-job-internal))))
608 (defun gnus-picons-network-display (url part sym-ann right-p marker)
609 (let ((cache (assoc url gnus-picons-glyph-alist)))
610 (if (or cache (null url))
611 (gnus-picons-network-display-internal
612 sym-ann (cdr cache) part right-p marker)
613 (gnus-picons-url-retrieve url 'gnus-picons-network-display-callback
614 (list url part sym-ann right-p marker)))))
616 ;;; search job functions
618 (defun gnus-picons-display-bar-p ()
619 (if (eq gnus-picons-display-where 'article)
620 gnus-picons-display-article-move-p
621 gnus-picons-display-as-address))
623 (defun gnus-picons-network-search-internal (user addrs dbs sym-ann right-p
624 marker &optional fnames)
625 (let (curkey dom pfx url dbs-tmp cache new-jobs)
626 ;; First do the domain search
627 (dolist (part (if right-p
630 (setq pfx (nconc (list part) pfx)
631 dom (cond ((and dom right-p) (concat part "." dom))
632 (dom (concat dom "." part))
634 curkey (list "unknown" dom dbs))
635 (when (null (setq cache (assoc curkey gnus-picons-url-alist)))
636 ;; This one is not yet in the cache, create a new entry
637 ;; Search for an entry
640 (while (and dbs-tmp (null url))
641 (setq url (or (cdr (assoc (list "unknown" pfx (car dbs-tmp)) fnames))
643 ;; This is the first component. Try the
644 ;; catch-all MISC component
645 (cdr (assoc (list "unknown"
650 (push (setq cache (cons curkey url)) gnus-picons-url-alist))
651 ;; Put this glyph in the job list
652 (if (and (not (eq dom part)) gnus-picons-display-as-address)
653 (push (list sym-ann "." right-p marker) new-jobs))
654 (push (list sym-ann 'picon (cdr cache) part right-p marker) new-jobs))
655 ;; next, the user search
657 (setq curkey (list user dom gnus-picons-user-directories))
658 (if (null (setq cache (assoc curkey gnus-picons-url-alist)))
659 (let ((users (list user "unknown"))
660 dirs usr domains-tmp dir picon)
661 (while (and users (null picon))
662 (setq dirs gnus-picons-user-directories
664 (while (and dirs (null picon))
665 (setq domains-tmp addrs
667 (while (and domains-tmp
668 (null (setq picon (assoc (list usr domains-tmp dir)
672 (setq picon (assoc (list usr '("MISC") dir) fnames)))))
673 (push (setq cache (cons curkey (cdr picon)))
674 gnus-picons-url-alist)))
675 (if (and gnus-picons-display-as-address new-jobs)
676 (push (list sym-ann "@" right-p marker) new-jobs))
677 (push (list sym-ann 'picon (cdr cache) user right-p marker) new-jobs))
678 (if (and (gnus-picons-display-bar-p) (not right-p))
679 (push (list sym-ann 'bar right-p marker) new-jobs))
680 ;; only put the jobs in the queue if this job has not been preempted.
681 (if (equal gnus-picons-job-already-running
682 (list sym-ann 'search user addrs dbs right-p marker))
683 (setq gnus-picons-jobs-alist
684 (nconc (if (and (gnus-picons-display-bar-p) right-p)
685 (list (list sym-ann 'bar right-p marker)))
687 gnus-picons-jobs-alist)))
688 (gnus-picons-next-job-internal)))
690 (defun gnus-picons-network-search-callback (user addrs dbs sym-ann right-p
692 (gnus-picons-network-search-internal
693 user addrs dbs sym-ann right-p marker
695 (gnus-picons-parse-filenames)
696 (kill-buffer (current-buffer)))))
698 ;; Initiate a query on the picon database
699 (defun gnus-picons-network-search (user addrs dbs sym-ann right-p marker)
700 (let* ((host (mapconcat 'identity addrs "."))
701 (key (list (or user "unknown") host (if user
702 gnus-picons-user-directories
704 (cache (assoc key gnus-picons-url-alist)))
706 (gnus-picons-url-retrieve
707 (concat gnus-picons-piconsearch-url
708 "?user=" (w3-form-encode-xwfu (or user "unknown"))
709 "&host=" (w3-form-encode-xwfu host)
710 "&db=" (mapconcat 'w3-form-encode-xwfu
713 gnus-picons-user-directories)
716 'gnus-picons-network-search-callback
717 (list user addrs dbs sym-ann right-p marker))
718 (gnus-picons-network-search-internal
719 user addrs dbs sym-ann right-p marker))))
721 ;;; Main jobs dispatcher function
723 (defun gnus-picons-next-job-internal ()
724 (when (setq gnus-picons-job-already-running (pop gnus-picons-jobs-alist))
725 (let* ((job gnus-picons-job-already-running)
730 ((stringp tag);; (SYM-ANN "..." RIGHT-P MARKER)
731 (gnus-picons-network-display-internal
732 sym-ann nil tag (pop job) (pop job)))
733 ((eq 'bar tag);; (SYM-ANN 'bar RIGHT-P MARKER)
734 (gnus-picons-network-display-internal
736 (let ((gnus-picons-file-suffixes '("xbm")))
737 (gnus-picons-try-face
738 gnus-xmas-glyph-directory "bar."))
739 nil (pop job) (pop job)))
740 ((eq 'search tag);; (SYM-ANN 'search USER ADDRS DBS RIGHT-P MARKER)
741 (gnus-picons-network-search
742 (pop job) (pop job) (pop job) sym-ann (pop job) (pop job)))
743 ((eq 'picon tag);; (SYM-ANN 'picon URL PART RIGHT-P MARKER)
744 (gnus-picons-network-display
745 (pop job) (pop job) sym-ann (pop job) (pop job)))
747 (setq gnus-picons-job-already-running nil)
748 (error "Unknown picon job tag %s" tag)))))))
750 (defun gnus-picons-next-job ()
751 "Start processing the job queue if it is not in progress."
752 (unless gnus-picons-job-already-running
753 (gnus-picons-next-job-internal)))
755 (provide 'gnus-picon)
757 ;;; gnus-picon.el ends here