annotate lisp/gnus/gnus-picon.el @ 136:b980b6286996 r20-2b2

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