From 6b95ea6db702c7d4caffe2ebed6c9e68769978cd Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 28 Sep 2010 11:51:26 +0200 Subject: [PATCH] gnus-gravatar: more robust search Signed-off-by: Julien Danjou --- lisp/ChangeLog | 7 +++++-- lisp/gnus-ems.el | 2 +- lisp/gnus-gravatar.el | 45 ++++++++++++++++++++++++------------------- 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index decf313a3..7b3efccc2 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,7 +1,10 @@ 2010-09-28 Julien Danjou - * gnus-gravatar.el (gnus-gravatar-insert): Search backward for ",\n" - for fields that are across several lines. + * gnus-ems.el (gnus-put-image): Revert Lars, change and insert + non-blank in header, otherwise it'll get stripped. + + * gnus-gravatar.el (gnus-gravatar-insert): Search backward for + real-name, and then for mail address rather than doing : or , search. 2010-09-28 Katsumi Yamaoka diff --git a/lisp/gnus-ems.el b/lisp/gnus-ems.el index 7b3f3d8a8..b4a2fe960 100644 --- a/lisp/gnus-ems.el +++ b/lisp/gnus-ems.el @@ -277,7 +277,7 @@ (defun gnus-put-image (glyph &optional string category) (let ((point (point))) - (insert-image glyph (or string " ")) + (insert-image glyph (or string "*")) (put-text-property point (point) 'gnus-image-category category) (unless string (put-text-property (1- (point)) (point) diff --git a/lisp/gnus-gravatar.el b/lisp/gnus-gravatar.el index 3edf34895..187b81610 100644 --- a/lisp/gnus-gravatar.el +++ b/lisp/gnus-gravatar.el @@ -59,7 +59,7 @@ unpressed button." (gravatar-retrieve (car address) 'gnus-gravatar-insert - (list header (car address) category))))))) + (list header address category))))))) (defun gnus-gravatar-insert (gravatar header address category) "Insert GRAVATAR for ADDRESS in HEADER in current article buffer. @@ -68,25 +68,30 @@ Set image category to CATEGORY." (gnus-with-article-headers (gnus-article-goto-header header) (mail-header-narrow-to-field) - (when (and (search-forward address nil t) - (or (search-backward ",\n" nil t) - (search-backward ", " nil t) - (search-backward ": " nil t))) - (goto-char (1+ (point))) - ;; Do not do anything if there's already a gravatar. This can - ;; happens if the buffer has been regenerated in the mean time, for - ;; example we were fetching someaddress, and then we change to - ;; another mail with the same someaddress. - (unless (memq 'gnus-gravatar (text-properties-at (point))) - (let ((inhibit-read-only t) - (point (point)) - (gravatar (append - gravatar - `(:ascent center :relief ,gnus-gravatar-relief)))) - (gnus-put-image gravatar nil category) - (put-text-property point (point) 'gnus-gravatar address) - (gnus-add-wash-type category) - (gnus-add-image category gravatar))))))) + (goto-char (point-max)) + (let ((real-name (cdr address)) + (mail-address (car address))) + (when (if real-name ; have a realname, go for it! + (search-backward real-name) + (search-backward address)) + (goto-char (1- (point))) + ;; If we're on the " quoting the name, go backward + (when (looking-at "\"") + (goto-char (1- (point)))) + ;; Do not do anything if there's already a gravatar. This can + ;; happens if the buffer has been regenerated in the mean time, for + ;; example we were fetching someaddress, and then we change to + ;; another mail with the same someaddress. + (unless (memq 'gnus-gravatar (text-properties-at (point))) + (let ((inhibit-read-only t) + (point (point)) + (gravatar (append + gravatar + `(:ascent center :relief ,gnus-gravatar-relief)))) + (gnus-put-image gravatar nil category) + (put-text-property point (point) 'gnus-gravatar address) + (gnus-add-wash-type category) + (gnus-add-image category gravatar)))))))) ;;;###autoload (defun gnus-treat-from-gravatar () -- 2.25.1