From 6c8570177af69650c650ae3a9c5744bcd3c7ea45 Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Fri, 4 Jan 2002 04:48:02 +0000 Subject: [PATCH] * gnus-art.el (article-display-x-face): Check whether valid grey face was returned. (article-display-x-face): Place image in the right spot. * gnus-fun.el (gnus-convert-gray-x-face-to-xpm): Get rid of stderr. (gnus-convert-gray-x-face-to-xpm): Check whether output is valid. --- lisp/ChangeLog | 10 ++++++++++ lisp/gnus-art.el | 12 +++++++++--- lisp/gnus-fun.el | 35 ++++++++++++++++++++--------------- 3 files changed, 39 insertions(+), 18 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9851abb58..fc5a4b3ec 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,13 @@ +2002-01-04 Lars Magne Ingebrigtsen + + * gnus-art.el (article-display-x-face): Check whether valid grey + face was returned. + (article-display-x-face): Place image in the right spot. + + * gnus-fun.el (gnus-convert-gray-x-face-to-xpm): Get rid of + stderr. + (gnus-convert-gray-x-face-to-xpm): Check whether output is valid. + 2002-01-03 Lars Magne Ingebrigtsen * gnus-xmas.el (gnus-xmas-create-image): Take optional diff --git a/lisp/gnus-art.el b/lisp/gnus-art.el index 6674ce817..8d312e38c 100644 --- a/lisp/gnus-art.el +++ b/lisp/gnus-art.el @@ -1802,9 +1802,15 @@ unfolded." (push (mail-header-field-value) x-faces)) (setq from (message-fetch-field "from")))) (if grey - (gnus-put-image - (gnus-create-image - (gnus-convert-gray-x-face-to-xpm x-faces) 'xpm t)) + (let ((xpm (gnus-convert-gray-x-face-to-xpm x-faces)) + image) + (when xpm + (setq image (gnus-create-image xpm 'xpm t)) + (goto-char (point-min)) + (re-search-forward "^From:" nil 'move) + (gnus-add-wash-type 'xface) + (gnus-add-image 'xface image) + (gnus-put-image image))) ;; Sending multiple EOFs to xv doesn't work, so we only do a ;; single external face. (when (stringp gnus-article-x-face-command) diff --git a/lisp/gnus-fun.el b/lisp/gnus-fun.el index c737b1306..caae6ee67 100644 --- a/lisp/gnus-fun.el +++ b/lisp/gnus-fun.el @@ -105,13 +105,15 @@ (defun gnus-convert-gray-x-face-to-xpm (faces) (let* ((depth (length faces)) (scale (/ 255 (1- (expt 2 depth)))) + (ok-p t) bit-list bit-lists pixels pixel) (dolist (face faces) + (setq bit-list nil) (with-temp-buffer (insert (uncompface face)) (shell-command-on-region (point-min) (point-max) - "pnmnoraw" + "pnmnoraw 2>/dev/null" (current-buffer) t) (goto-char (point-min)) (forward-line 2) @@ -122,21 +124,24 @@ ((eq (following-char) ?1) (push 1 bit-list))) (forward-char 1))) + (unless (= (length bit-list) (* 48 48)) + (setq ok-p nil)) (push bit-list bit-lists)) - (dotimes (i (* 48 48)) - (setq pixel 0) - (dotimes (plane depth) - (setq pixel (+ (* pixel 2) (nth i (nth plane bit-lists))))) - (push pixel pixels)) - (with-temp-buffer - (insert "P2\n48 48\n255\n") - (dolist (pixel pixels) - (insert (number-to-string (* scale pixel)) " ")) - (shell-command-on-region - (point-min) (point-max) - "ppmtoxpm 2>/dev/null" - (current-buffer) t) - (buffer-string)))) + (when ok-p + (dotimes (i (* 48 48)) + (setq pixel 0) + (dotimes (plane depth) + (setq pixel (+ (* pixel 2) (nth i (nth plane bit-lists))))) + (push pixel pixels)) + (with-temp-buffer + (insert "P2\n48 48\n255\n") + (dolist (pixel pixels) + (insert (number-to-string (* scale pixel)) " ")) + (shell-command-on-region + (point-min) (point-max) + "ppmtoxpm 2>/dev/null" + (current-buffer) t) + (buffer-string))))) ;;;###autoload (defun gnus-convert-gray-x-face-region (beg end) -- 2.25.1