annotate lisp/gnus/gnus-picon.el @ 90:99da576a67e7 xemacs-20-0

Import from CVS: tag xemacs-20-0
author cvs
date Mon, 13 Aug 2007 09:10:46 +0200
parents 131b0175ea99
children 0d2f883870bc
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
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
2 ;; Copyright (C) 1996 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
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
26 ;; Usage:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
27 ;; - You must have XEmacs (19.12 or above I think) to use this.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
28 ;; - Read the variable descriptions below.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
29 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
30 ;; - chose a setup:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
31 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
32 ;; 1) display the icons in its own buffer:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
33 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
34 ;; (add-hook 'gnus-article-display-hook 'gnus-article-display-picons t)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
35 ;; (add-hook 'gnus-summary-prepare-hook 'gnus-group-display-picons t)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
36 ;; (setq gnus-picons-display-where 'picons)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
37 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
38 ;; Then add the picons buffer to your display configuration:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
39 ;; The picons buffer needs to be at least 48 pixels high,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
40 ;; which for me is 5 lines:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
41 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
42 ;; (gnus-add-configuration
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
43 ;; '(article (vertical 1.0
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
44 ;; (group 6)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
45 ;; (picons 5)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
46 ;; (summary .25 point)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
47 ;; (article 1.0))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
48 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
49 ;; (gnus-add-configuration
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
50 ;; '(summary (vertical 1.0 (group 6)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
51 ;; (picons 5)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
52 ;; (summary 1.0 point))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
53 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
54 ;; 2) display the icons in the summary buffer
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
55 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
56 ;; (add-hook 'gnus-article-display-hook 'gnus-article-display-picons t)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
57 ;; (add-hook 'gnus-summary-prepare-hook 'gnus-group-display-picons t)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
58 ;; (setq gnus-picons-display-where 'summary)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
59 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
60 ;; 3) display the icons in the article buffer
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
61 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
62 ;; (add-hook 'gnus-article-display-hook 'gnus-article-display-picons t)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
63 ;; (add-hook 'gnus-article-prepare-hook 'gnus-group-display-picons t)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
64 ;; (setq gnus-picons-display-where 'article)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
65 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
66 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
67 ;; Warnings:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
68 ;; - I'm not even close to being a lisp expert.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
69 ;; - The 't' (append) flag MUST be in the add-hook line
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
70 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
71 ;; TODO:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
72 ;; - Remove the TODO section in the headers.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
73 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
74
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (require 'xpm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (require 'annotations)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
79 (eval-when-compile (require 'cl))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
81 (defvar gnus-picons-buffer "*Icon Buffer*"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
82 "Buffer name to display the icons in if gnus-picons-display-where is 'picons.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
84 (defvar gnus-picons-display-where 'picons
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
85 "Where to display the group and article icons.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
87 (defvar gnus-picons-database "/usr/local/faces"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
88 "Defines the location of the faces database.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
89 For information on obtaining this database of pretty pictures, please
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
90 see http://www.cs.indiana.edu/picons/ftp/index.html" )
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
91
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
92 (defvar gnus-picons-news-directory "news"
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
93 "Sub-directory of the faces database containing the icons for newsgroups."
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
94 )
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
95
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
96 (defvar gnus-picons-user-directories '("local" "users" "usenix" "misc/MISC")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 "List of directories to search for user faces."
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
98 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
100 (defvar gnus-picons-domain-directories '("domains")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
101 "List of directories to search for domain faces.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
102 Some people may want to add \"unknown\" to this list."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
103 )
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
104
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
105 (defvar gnus-picons-x-face-file-name
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
106 (format "/tmp/picon-xface.%s.xbm" (user-login-name))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
107 "The name of the file in which to store the converted X-face header.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
109 (defvar gnus-picons-convert-x-face (format "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | pbmtoxbm > %s" gnus-picons-x-face-file-name)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
110 "Command to convert the x-face header into a xbm file."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
111 )
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
112
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
113 (defvar gnus-picons-file-suffixes
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (when (featurep 'x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (let ((types (list "xbm")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (when (featurep 'gif)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (push "gif" types))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (when (featurep 'xpm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (push "xpm" types))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 types))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
121 "List of suffixes on picon file names to try.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
123 (defvar gnus-picons-display-article-move-p t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 "*Whether to move point to first empty line when displaying picons.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
125 This has only an effect if `gnus-picons-display-where' hs value article.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;;; Internal variables.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
128
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (defvar gnus-group-annotations nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (defvar gnus-article-annotations nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (defvar gnus-x-face-annotations nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (defun gnus-picons-remove (plist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (let ((listitem (car plist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (while (setq listitem (car plist))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
136 (if (annotationp listitem)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
137 (delete-annotation listitem))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
138 (setq plist (cdr plist))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
139 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (defun gnus-picons-remove-all ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 "Removes all picons from the Gnus display(s)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (gnus-picons-remove gnus-article-annotations)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (gnus-picons-remove gnus-group-annotations)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (gnus-picons-remove gnus-x-face-annotations)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (setq gnus-article-annotations nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 gnus-group-annotations nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 gnus-x-face-annotations nil)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
150 (if (bufferp gnus-picons-buffer)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
151 (kill-buffer gnus-picons-buffer))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
152 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (defun gnus-get-buffer-name (variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 "Returns the buffer name associated with the contents of a variable."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (cond ((symbolp variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (let ((newvar (cdr (assq variable gnus-window-to-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (cond ((symbolp newvar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (symbol-value newvar))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ((stringp newvar) newvar))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ((stringp variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 variable)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (defun gnus-picons-article-display-x-face ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 "Display the x-face header bitmap in the 'gnus-picons-display-where buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;; delete any old ones.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (gnus-picons-remove gnus-x-face-annotations)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (setq gnus-x-face-annotations nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;; display the new one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (let ((gnus-article-x-face-command 'gnus-picons-display-x-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (gnus-article-display-x-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (defun gnus-picons-display-x-face (beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 "Function to display the x-face header in the picons window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 To use: (setq gnus-article-x-face-command 'gnus-picons-display-x-face)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;; convert the x-face header to a .xbm file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (let ((process-connection-type nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (process nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (process-kill-without-query
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (setq process (start-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 "gnus-x-face" nil shell-file-name shell-command-switch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 gnus-picons-convert-x-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (process-send-region "gnus-x-face" beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (process-send-eof "gnus-x-face")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;; wait for it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (while (not (equal (process-status process) 'exit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (sleep-for .1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;; display it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (save-excursion
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
191 (set-buffer (get-buffer-create (gnus-get-buffer-name
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 gnus-picons-display-where)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (gnus-add-current-to-buffer-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (let (buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (unless (eolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (push (make-annotation "\n" (point) 'text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 gnus-x-face-annotations))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;; append the annotation to gnus-article-annotations for deletion.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
200 (setq gnus-x-face-annotations
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (gnus-picons-try-to-find-face gnus-picons-x-face-file-name t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 gnus-x-face-annotations)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;; delete the tmp file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (delete-file gnus-picons-x-face-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (defun gnus-article-display-picons ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 "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
209 (interactive)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
210 (let (from at-idx databases)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
211 (when (and (featurep 'xpm)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (or (not (fboundp 'device-type)) (equal (device-type) 'x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (setq from (mail-fetch-field "from"))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
214 (setq from (downcase (or (cadr (mail-extract-address-components
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
215 from))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
216 ""))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
217 at-idx (string-match "@" from)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (let ((username (substring from 0 at-idx))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
220 (addrs (nreverse
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
221 (message-tokenize-header (substring from (1+ at-idx))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
222 "."))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (set-buffer (get-buffer-create
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (gnus-get-buffer-name gnus-picons-display-where)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (gnus-add-current-to-buffer-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (if (and (eq gnus-picons-display-where 'article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 gnus-picons-display-article-move-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (when (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (forward-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (unless (eolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (push (make-annotation "\n" (point) 'text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 gnus-article-annotations)))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
234
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (gnus-picons-remove gnus-article-annotations)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (setq gnus-article-annotations nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
238 (setq databases (append gnus-picons-user-directories
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
239 gnus-picons-domain-directories))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (while databases
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (setq gnus-article-annotations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (nconc (gnus-picons-insert-face-if-exists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (car databases)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 addrs
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
245 "unknown")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
246 (gnus-picons-insert-face-if-exists
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
247 (car databases)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
248 addrs
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
249 (downcase username) t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 gnus-article-annotations))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (setq databases (cdr databases)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (add-hook 'gnus-summary-exit-hook 'gnus-picons-remove-all))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (defun gnus-group-display-picons ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
255 "Display icons for the group in the gnus-picons-display-where buffer."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (interactive)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
257 (when (and (featurep 'xpm)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (or (not (fboundp 'device-type)) (equal (device-type) 'x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (set-buffer (get-buffer-create
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (gnus-get-buffer-name gnus-picons-display-where)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (gnus-add-current-to-buffer-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (if (and (eq gnus-picons-display-where 'article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 gnus-picons-display-article-move-p)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
266 (if (search-forward "\n\n" nil t)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
267 (forward-line -1))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (unless (eolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (push (make-annotation "\n" (point) 'text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 gnus-group-annotations)))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
271 (cond
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ((listp gnus-group-annotations)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
273 (mapcar 'delete-annotation gnus-group-annotations)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (setq gnus-group-annotations nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 ((annotationp gnus-group-annotations)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (delete-annotation gnus-group-annotations)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (setq gnus-group-annotations nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (gnus-picons-remove gnus-group-annotations)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (setq gnus-group-annotations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (gnus-picons-insert-face-if-exists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 gnus-picons-news-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (message-tokenize-header gnus-newsgroup-name ".")
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
283 "unknown"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (add-hook 'gnus-summary-exit-hook 'gnus-picons-remove-all))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (defsubst gnus-picons-try-suffixes (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (let ((suffixes gnus-picons-file-suffixes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (while (and suffixes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (not (file-exists-p (setq f (concat file (pop suffixes))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (setq f nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (defun gnus-picons-insert-face-if-exists (database addrs filename &optional
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
295 nobar-p)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 "Inserts a face at point if I can find one"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 ;; '(gnus-picons-insert-face-if-exists
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
298 ; "Database" '("edu" "indiana" "cs") "Name")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 ;; looks for:
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
300 ;; 1. edu/indiana/cs/Name
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
301 ;; 2. edu/indiana/Name
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 ;; 3. edu/Name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 ;; '(gnus-picons-insert-face-if-exists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 ;; "Database/MISC" '("edu" "indiana" "cs") "Name")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 ;; looks for:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 ;; 1. MISC/Name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 ;; The special treatment of MISC doesn't conform with the conventions for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 ;; picon databases, but otherwise we would always see the MISC/unknown face.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (let ((bar (and (not nobar-p)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
310 (annotations-in-region
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
311 (point) (min (point-max) (1+ (point)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
312 (current-buffer))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (path (concat (file-name-as-directory gnus-picons-database)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 database "/"))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
315 picons found bar-ann)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
316 (if (string-match "/MISC" database)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
317 (setq addrs '("")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (while (and addrs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (file-accessible-directory-p path))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
320 (setq path (concat path (pop addrs) "/"))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
321 (when (setq found
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
322 (gnus-picons-try-suffixes
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
323 (concat path filename "/face.")))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
324 (when bar
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
325 (setq bar-ann (gnus-picons-try-to-find-face
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
326 (concat gnus-xmas-glyph-directory "bar.xbm")))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
327 (when bar-ann
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
328 (setq picons (nconc picons bar-ann))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
329 (setq bar nil)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
330 (setq picons (nconc (gnus-picons-try-to-find-face found)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
331 picons))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
332 (nreverse picons)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (defvar gnus-picons-glyph-alist nil)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
335
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
336 (defun gnus-picons-try-to-find-face (path &optional xface-p)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
337 "If PATH exists, display it as a bitmap. Returns t if succedded."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (let ((glyph (and (not xface-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (cdr (assoc path gnus-picons-glyph-alist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (when (or glyph (file-exists-p path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (unless glyph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (setq glyph (make-glyph path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (unless xface-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (push (cons path glyph) gnus-picons-glyph-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (set-glyph-face glyph 'default))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
346 (nconc
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
347 (list (make-annotation glyph (point) 'text))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
348 (when (eq major-mode 'gnus-article-mode)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
349 (list (make-annotation " " (point) 'text)))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (defun gnus-picons-reverse-domain-path (str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 "a/b/c/d -> d/c/b/a"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (mapconcat 'downcase (nreverse (message-tokenize-header str "/")) "/"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (gnus-add-shutdown 'gnus-picons-close 'gnus)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (defun gnus-picons-close ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 "Shut down the picons."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (setq gnus-picons-glyph-alist nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (provide 'gnus-picon)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 ;;; gnus-picon.el ends here