annotate lisp/gnus/gnus-picon.el @ 26:441bb1e64a06 r19-15b96

Import from CVS: tag r19-15b96
author cvs
date Mon, 13 Aug 2007 08:51:32 +0200
parents 0293115a14e9
children ec9a17fef872
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 ;;; gnus-picon.el --- displaying pretty icons in Gnus
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
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: Wes Hardaker <hardaker@ece.ucdavis.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: news xpm annotation glyph faces
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
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
28 (require 'gnus)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (require 'xpm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 (require 'annotations)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
31 (require 'custom)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
33 (defgroup picons nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
34 "Show pictures of people, domains, and newsgroups (XEmacs).
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
35 For this to work, you must add gnus-group-display-picons to the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
36 gnus-summary-display-hook or to the gnus-article-display-hook
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
37 depending on what gnus-picons-display-where is set to. You must
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
38 also add gnus-article-display-picons to gnus-article-display-hook."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
39 :group 'gnus-visual)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
41 (defcustom gnus-picons-buffer "*Icon Buffer*"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
42 "Buffer name to display the icons in if gnus-picons-display-where is 'picons."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
43 :type 'string
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
44 :group 'picons)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
46 (defcustom gnus-picons-display-where 'picons
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 16
diff changeset
47 "Where to display the group and article icons.
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 16
diff changeset
48 Legal values are `article' and `picons'."
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
49 :type '(choice symbol string)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
50 :group 'picons)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
51
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
52 (defcustom gnus-picons-database "/usr/local/faces"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 "Defines the location of the faces database.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 For information on obtaining this database of pretty pictures, please
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
55 see http://www.cs.indiana.edu/picons/ftp/index.html"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
56 :type 'directory
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
57 :group 'picons)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
59 (defcustom gnus-picons-news-directory "news"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
60 "Sub-directory of the faces database containing the icons for newsgroups."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
61 :type 'string
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
62 :group 'picons)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
63
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
64 (defcustom gnus-picons-user-directories '("local" "users" "usenix" "misc/MISC")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 "List of directories to search for user faces."
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
66 :type '(repeat string)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
67 :group 'picons)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
69 (defcustom gnus-picons-domain-directories '("domains")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 "List of directories to search for domain faces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 Some people may want to add \"unknown\" to this list."
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
72 :type '(repeat string)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
73 :group 'picons)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
75 (defcustom gnus-picons-refresh-before-display nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
76 "If non-nil, display the article buffer before computing the picons."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
77 :type 'boolean
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
78 :group 'picons)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
80 (defcustom gnus-picons-x-face-file-name
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
81 (format "/tmp/picon-xface.%s.xbm" (user-login-name))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
82 "The name of the file in which to store the converted X-face header."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
83 :type 'string
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
84 :group 'picons)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
85
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
86 (defcustom gnus-picons-convert-x-face (format "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | pbmtoxbm > %s" gnus-picons-x-face-file-name)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 "Command to convert the x-face header into a xbm file."
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
88 :type 'string
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
89 :group 'picons)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
91 (defcustom gnus-picons-display-as-address t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
92 "*If t display textual email addresses along with pictures."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
93 :type 'boolean
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
94 :group 'picons)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
95
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
96 (defcustom gnus-picons-file-suffixes
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (when (featurep 'x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (let ((types (list "xbm")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (when (featurep 'gif)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (push "gif" types))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (when (featurep 'xpm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (push "xpm" types))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 types))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
104 "List of suffixes on picon file names to try."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
105 :type '(repeat string)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
106 :group 'picons)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
108 (defcustom gnus-picons-display-article-move-p t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 "*Whether to move point to first empty line when displaying picons.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
110 This has only an effect if `gnus-picons-display-where' hs value article."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
111 :type 'boolean
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
112 :group 'picons)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
113
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
114 (defvar gnus-picons-map (make-sparse-keymap "gnus-picons-keys")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
115 "keymap to hide/show picon glyphs")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
116
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
117 (define-key gnus-picons-map [(button2)] 'gnus-picons-toggle-extent)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;;; Internal variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (defvar gnus-group-annotations nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (defvar gnus-article-annotations nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (defvar gnus-x-face-annotations nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (defun gnus-picons-remove (plist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (let ((listitem (car plist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (while (setq listitem (car plist))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
128 (when (annotationp listitem)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
129 (delete-annotation listitem))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
130 (setq plist (cdr plist)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (defun gnus-picons-remove-all ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 "Removes all picons from the Gnus display(s)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (gnus-picons-remove gnus-article-annotations)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (gnus-picons-remove gnus-group-annotations)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (gnus-picons-remove gnus-x-face-annotations)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (setq gnus-article-annotations nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 gnus-group-annotations nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 gnus-x-face-annotations nil)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
141 (when (bufferp gnus-picons-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
142 (kill-buffer gnus-picons-buffer)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (defun gnus-get-buffer-name (variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 "Returns the buffer name associated with the contents of a variable."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (cond ((symbolp variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (let ((newvar (cdr (assq variable gnus-window-to-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (cond ((symbolp newvar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (symbol-value newvar))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ((stringp newvar) newvar))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ((stringp variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 variable)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (defun gnus-picons-article-display-x-face ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 "Display the x-face header bitmap in the 'gnus-picons-display-where buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;; delete any old ones.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (gnus-picons-remove gnus-x-face-annotations)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (setq gnus-x-face-annotations nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;; display the new one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (let ((gnus-article-x-face-command 'gnus-picons-display-x-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (gnus-article-display-x-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (defun gnus-picons-display-x-face (beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 "Function to display the x-face header in the picons window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 To use: (setq gnus-article-x-face-command 'gnus-picons-display-x-face)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;; convert the x-face header to a .xbm file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (let ((process-connection-type nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (process nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (process-kill-without-query
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (setq process (start-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 "gnus-x-face" nil shell-file-name shell-command-switch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 gnus-picons-convert-x-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (process-send-region "gnus-x-face" beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (process-send-eof "gnus-x-face")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ;; wait for it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (while (not (equal (process-status process) 'exit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (sleep-for .1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ;; display it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (set-buffer (get-buffer-create (gnus-get-buffer-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 gnus-picons-display-where)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (gnus-add-current-to-buffer-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (let (buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (unless (eolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (push (make-annotation "\n" (point) 'text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 gnus-x-face-annotations))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;; append the annotation to gnus-article-annotations for deletion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (setq gnus-x-face-annotations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (gnus-picons-try-to-find-face gnus-picons-x-face-file-name t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 gnus-x-face-annotations)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;; delete the tmp file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (delete-file gnus-picons-x-face-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (defun gnus-article-display-picons ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 "Display faces for an author and his/her domain in gnus-picons-display-where."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (interactive)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
200 ;; let drawing catch up
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
201 (when gnus-picons-refresh-before-display
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
202 (sit-for 0))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
203 (let ((first t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
204 from at-idx databases)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
205 (when (and (featurep 'xpm)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (or (not (fboundp 'device-type)) (equal (device-type) 'x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (setq from (mail-fetch-field "from"))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
208 (setq from (downcase
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
209 (or (cadr (mail-extract-address-components from))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
210 "")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
211 (or (setq at-idx (string-match "@" from))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
212 (setq at-idx (length from))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (let ((username (substring from 0 at-idx))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
215 (addrs (if (eq at-idx (length from))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
216 (if gnus-local-domain
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
217 (nreverse (message-tokenize-header
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
218 gnus-local-domain "."))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
219 '(""))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
220 (nreverse (message-tokenize-header
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
221 (substring from (1+ at-idx)) ".")))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (set-buffer (get-buffer-create
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (gnus-get-buffer-name gnus-picons-display-where)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (gnus-add-current-to-buffer-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (if (and (eq gnus-picons-display-where 'article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 gnus-picons-display-article-move-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (when (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (forward-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (unless (eolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (push (make-annotation "\n" (point) 'text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 gnus-article-annotations)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (gnus-picons-remove gnus-article-annotations)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (setq gnus-article-annotations nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
237 ;; look for domain paths.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
238 (setq databases gnus-picons-domain-directories)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (while databases
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (setq gnus-article-annotations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (nconc (gnus-picons-insert-face-if-exists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (car databases)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 addrs
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
244 "unknown" (or gnus-picons-display-as-address
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
245 gnus-article-annotations) t t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 gnus-article-annotations))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (setq databases (cdr databases)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
248
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
249 ;; add an '@' if displaying as address
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
250 (when gnus-picons-display-as-address
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
251 (setq gnus-article-annotations
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
252 (nconc gnus-article-annotations
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
253 (list
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
254 (make-annotation "@" (point) 'text nil nil nil t)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
255
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
256 ;; then do user directories,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
257 (let (found)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
258 (setq databases gnus-picons-user-directories)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
259 (setq username (downcase username))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
260 (while databases
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
261 (setq found
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
262 (nconc (gnus-picons-insert-face-if-exists
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
263 (car databases) addrs username
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
264 (or gnus-picons-display-as-address
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
265 gnus-article-annotations) nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
266 found))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
267 (setq databases (cdr databases)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
268 ;; add their name if no face exists
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
269 (when (and gnus-picons-display-as-address (not found))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
270 (setq found
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
271 (list
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
272 (make-annotation username (point) 'text nil nil nil t))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
273 (setq gnus-article-annotations
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
274 (nconc found gnus-article-annotations)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
275
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (add-hook 'gnus-summary-exit-hook 'gnus-picons-remove-all))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (defun gnus-group-display-picons ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 "Display icons for the group in the gnus-picons-display-where buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (interactive)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
281 ;; let display catch up so far
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
282 (when gnus-picons-refresh-before-display
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
283 (sit-for 0))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
284 (when (and (featurep 'xpm)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (or (not (fboundp 'device-type)) (equal (device-type) 'x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (set-buffer (get-buffer-create
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (gnus-get-buffer-name gnus-picons-display-where)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (gnus-add-current-to-buffer-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (if (and (eq gnus-picons-display-where 'article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 gnus-picons-display-article-move-p)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
293 (when (search-forward "\n\n" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
294 (forward-line -1))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (unless (eolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (push (make-annotation "\n" (point) 'text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 gnus-group-annotations)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
298 (cond
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 ((listp gnus-group-annotations)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
300 (mapc #'(lambda (ext) (when (extent-live-p ext)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
301 (delete-annotation ext)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
302 gnus-group-annotations)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (setq gnus-group-annotations nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 ((annotationp gnus-group-annotations)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (delete-annotation gnus-group-annotations)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (setq gnus-group-annotations nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (gnus-picons-remove gnus-group-annotations)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (setq gnus-group-annotations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (gnus-picons-insert-face-if-exists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 gnus-picons-news-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (message-tokenize-header gnus-newsgroup-name ".")
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
312 "unknown" nil t))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (add-hook 'gnus-summary-exit-hook 'gnus-picons-remove-all))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (defsubst gnus-picons-try-suffixes (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (let ((suffixes gnus-picons-file-suffixes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (while (and suffixes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (not (file-exists-p (setq f (concat file (pop suffixes))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (setq f nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (defun gnus-picons-insert-face-if-exists (database addrs filename &optional
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
324 nobar-p dots rightp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 "Inserts a face at point if I can find one"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 ;; '(gnus-picons-insert-face-if-exists
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
327 ;; "Database" '("edu" "indiana" "cs") "Name")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 ;; looks for:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 ;; 1. edu/indiana/cs/Name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 ;; 2. edu/indiana/Name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 ;; 3. edu/Name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ;; '(gnus-picons-insert-face-if-exists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 ;; "Database/MISC" '("edu" "indiana" "cs") "Name")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ;; looks for:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 ;; 1. MISC/Name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 ;; The special treatment of MISC doesn't conform with the conventions for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 ;; picon databases, but otherwise we would always see the MISC/unknown face.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (let ((bar (and (not nobar-p)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
339 (or gnus-picons-display-as-address
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
340 (annotations-in-region
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
341 (point) (min (point-max) (1+ (point)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
342 (current-buffer)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (path (concat (file-name-as-directory gnus-picons-database)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 database "/"))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
345 (domainp (and gnus-picons-display-as-address dots))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
346 picons found bar-ann cur first)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
347 (when (string-match "/MISC" database)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
348 (setq addrs '("")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (while (and addrs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (file-accessible-directory-p path))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
351 (setq cur (pop addrs)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
352 path (concat path cur "/"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
353 (if (setq found
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
354 (gnus-picons-try-suffixes (concat path filename "/face.")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
355 (progn
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
356 (setq picons (nconc (when (and domainp first rightp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
357 (list (make-annotation
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
358 "." (point) 'text
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
359 nil nil nil rightp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
360 picons))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
361 (gnus-picons-try-to-find-face
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
362 found nil (if domainp cur filename) rightp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
363 (when (and domainp first (not rightp))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
364 (list (make-annotation
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
365 "." (point) 'text
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
366 nil nil nil rightp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
367 picons))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
368 picons)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
369 (when domainp
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
370 (setq picons
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
371 (nconc (list (make-annotation
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
372 (if first (concat (if (not rightp) ".") cur
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
373 (if rightp ".")) cur)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
374 (point) 'text nil nil nil rightp))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
375 picons))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
376 (when (and bar (or domainp found))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
377 (setq bar-ann (gnus-picons-try-to-find-face
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
378 (concat gnus-xmas-glyph-directory "bar.xbm")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
379 nil nil t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
380 (when bar-ann
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
381 (setq picons (nconc picons bar-ann))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
382 (setq bar nil)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
383 (setq first t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
384 (when (and addrs domainp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
385 (let ((it (mapconcat 'downcase (nreverse addrs) ".")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
386 (make-annotation
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
387 (if first (concat (if (not rightp) ".") it (if rightp ".")) it)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
388 (point) 'text nil nil nil rightp)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
389 picons))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (defvar gnus-picons-glyph-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
393 (defun gnus-picons-try-to-find-face (path &optional xface-p part rightp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
394 "If PATH exists, display it as a bitmap. Returns t if succeeded."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (let ((glyph (and (not xface-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (cdr (assoc path gnus-picons-glyph-alist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (when (or glyph (file-exists-p path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (unless glyph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (setq glyph (make-glyph path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (unless xface-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (push (cons path glyph) gnus-picons-glyph-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (set-glyph-face glyph 'default))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
403 (let ((new (make-annotation glyph (point) 'text nil nil nil rightp)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
404 (nconc
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
405 (list new)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
406 (when (and (eq major-mode 'gnus-article-mode)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
407 (not gnus-picons-display-as-address)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
408 (not part))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
409 (list (make-annotation " " (point) 'text nil nil nil rightp)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
410 (when (and part gnus-picons-display-as-address)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
411 (let ((txt (make-annotation part (point) 'text nil nil nil rightp)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
412 (hide-annotation txt)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
413 (set-extent-property txt 'its-partner new)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
414 (set-extent-property txt 'keymap gnus-picons-map)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
415 (set-extent-property txt 'mouse-face gnus-article-mouse-face)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
416 (set-extent-property new 'its-partner txt)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
417 (set-extent-property new 'keymap gnus-picons-map))))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (defun gnus-picons-reverse-domain-path (str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 "a/b/c/d -> d/c/b/a"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (mapconcat 'downcase (nreverse (message-tokenize-header str "/")) "/"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
423 (defun gnus-picons-toggle-extent (event)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
424 "Toggle picon glyph at given point"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
425 (interactive "e")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
426 (let* ((ant1 (event-glyph-extent event))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
427 (ant2 (extent-property ant1 'its-partner)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
428 (when (and (annotationp ant1) (annotationp ant2))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
429 (reveal-annotation ant2)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
430 (hide-annotation ant1))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
431
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (gnus-add-shutdown 'gnus-picons-close 'gnus)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (defun gnus-picons-close ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 "Shut down the picons."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (setq gnus-picons-glyph-alist nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (provide 'gnus-picon)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 ;;; gnus-picon.el ends here