Mercurial > emacs
annotate lisp/gnus/gnus-gravatar.el @ 110629:531fc2a3b1cc
Fix message-* user options that differ from Gnus trunk.
message.el (message-from-style, message-interactive, message-signature): Remove comment.
message.el (message-cite-prefix-regexp): Default to mail-citation-prefix-regexp always.
message.el (message-sendmail-envelope-from): Comment fix.
message.el (message-yank-prefix): Default to mail-yank-prefix always.
message.el (message-indentation-spaces): Default to mail-indentation-spaces always.
message.el (message-signature-file): Default to mail-signature-file always.
sendmail.el (mail-citation-prefix-regexp): Remove "}" from citation prefix.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Tue, 28 Sep 2010 02:13:41 +0000 |
parents | 5b5c2cab9a6a |
children | 05430cec48ff |
rev | line source |
---|---|
110555
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
1 ;;; gnus-gravatar.el --- Gnus Gravatar support |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
2 |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
3 ;; Copyright (C) 2010 Free Software Foundation, Inc. |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
4 |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
5 ;; Author: Julien Danjou <julien@danjou.info> |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
6 ;; Keywords: news |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
7 |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
8 ;; This file is part of GNU Emacs. |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
9 |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
10 ;; GNU Emacs is free software: you can redistribute it and/or modify |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
11 ;; it under the terms of the GNU General Public License as published by |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
12 ;; the Free Software Foundation, either version 3 of the License, or |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
13 ;; (at your option) any later version. |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
14 |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
15 ;; GNU Emacs is distributed in the hope that it will be useful, |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
18 ;; GNU General Public License for more details. |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
19 |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
20 ;; You should have received a copy of the GNU General Public License |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
22 |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
23 ;;; Commentary: |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
24 |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
25 ;;; Code: |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
26 |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
27 (require 'gravatar) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
28 |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
29 (defgroup gnus-gravatar nil |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
30 "Gnus Gravatar." |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
31 :group 'gnus-visual) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
32 |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
33 (defcustom gnus-gravatar-size 32 |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
34 "How big should gravatars be displayed." |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
35 :type 'integer |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
36 :group 'gnus-gravatar) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
37 |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
38 (defcustom gnus-gravatar-relief 1 |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
39 "If non-nil, adds a shadow rectangle around the image. The |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
40 value, relief, specifies the width of the shadow lines, in |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
41 pixels. If relief is negative, shadows are drawn so that the |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
42 image appears as a pressed button; otherwise, it appears as an |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
43 unpressed button." |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
44 :group 'gnus-gravatar) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
45 |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
46 (defun gnus-gravatar-transform-address (header category) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
47 (gnus-with-article-headers |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
48 (let ((addresses |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
49 (mail-header-parse-addresses |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
50 ;; mail-header-parse-addresses does not work (reliably) on |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
51 ;; decoded headers. |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
52 (or |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
53 (ignore-errors |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
54 (mail-encode-encoded-word-string |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
55 (or (mail-fetch-field header) ""))) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
56 (mail-fetch-field header))))) |
110563
5b5c2cab9a6a
Merge changes made in Gnus.tranck
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110555
diff
changeset
|
57 (let ((gravatar-size gnus-gravatar-size)) |
5b5c2cab9a6a
Merge changes made in Gnus.tranck
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110555
diff
changeset
|
58 (dolist (address addresses) |
5b5c2cab9a6a
Merge changes made in Gnus.tranck
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110555
diff
changeset
|
59 (gravatar-retrieve |
5b5c2cab9a6a
Merge changes made in Gnus.tranck
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110555
diff
changeset
|
60 (car address) |
5b5c2cab9a6a
Merge changes made in Gnus.tranck
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110555
diff
changeset
|
61 'gnus-gravatar-insert |
5b5c2cab9a6a
Merge changes made in Gnus.tranck
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110555
diff
changeset
|
62 (list header (car address) category))))))) |
110555
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
63 |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
64 (defun gnus-gravatar-insert (gravatar header address category) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
65 "Insert GRAVATAR for ADDRESS in HEADER in current article buffer. |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
66 Set image category to CATEGORY." |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
67 (unless (eq gravatar 'error) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
68 (gnus-with-article-headers |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
69 (gnus-article-goto-header header) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
70 (mail-header-narrow-to-field) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
71 (when (and (search-forward address nil t) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
72 (or (search-backward ", " nil t) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
73 (search-backward ": " nil t))) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
74 (goto-char (1+ (point))) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
75 ;; Do not do anything if there's already a gravatar. This can |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
76 ;; happens if the buffer has been regenerated in the mean time, for |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
77 ;; example we were fetching someaddress, and then we change to |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
78 ;; another mail with the same someaddress. |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
79 (unless (memq 'gnus-gravatar (text-properties-at (point))) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
80 (let ((inhibit-read-only t) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
81 (point (point)) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
82 (gravatar (append |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
83 gravatar |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
84 `(:ascent center :relief ,gnus-gravatar-relief)))) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
85 (gnus-put-image gravatar nil category) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
86 (put-text-property point (point) 'gnus-gravatar address) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
87 (gnus-add-wash-type category) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
88 (gnus-add-image category gravatar))))))) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
89 |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
90 ;;;###autoload |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
91 (defun gnus-treat-from-gravatar () |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
92 "Display gravatar in the From header. |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
93 If gravatar is already displayed, remove it." |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
94 (interactive) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
95 (gnus-with-article-buffer |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
96 (if (memq 'from-gravatar gnus-article-wash-types) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
97 (gnus-delete-images 'from-gravatar) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
98 (gnus-gravatar-transform-address "from" 'from-gravatar)))) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
99 |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
100 ;;;###autoload |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
101 (defun gnus-treat-mail-gravatar () |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
102 "Display gravatars in the Cc and To headers. |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
103 If gravatars are already displayed, remove them." |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
104 (interactive) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
105 (gnus-with-article-buffer |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
106 (if (memq 'mail-gravatar gnus-article-wash-types) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
107 (gnus-delete-images 'mail-gravatar) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
108 (gnus-gravatar-transform-address "cc" 'mail-gravatar) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
109 (gnus-gravatar-transform-address "to" 'mail-gravatar)))) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
110 |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
111 (provide 'gnus-gravatar) |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
112 |
e07971bb896c
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
113 ;;; gnus-gravatar.el ends here |