annotate lisp/gnus/gnus-picon.el @ 98:0d2f883870bc r20-1b1

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