Function: article-display-x-face

article-display-x-face is an interactive and byte-compiled function defined in gnus-art.el.gz.

Signature

(article-display-x-face &optional FORCE)

Documentation

Look for an X-Face header and display it if present.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-art.el.gz
(defun article-display-x-face (&optional force)
  "Look for an X-Face header and display it if present."
  (interactive (list 'force) gnus-article-mode gnus-summary-mode)
  (let ((wash-face-p buffer-read-only))	;; When type `W f'
    (gnus-with-article-headers
      ;; Delete the old process, if any.
      (when (process-status "article-x-face")
	(delete-process "article-x-face"))
      ;; See the comment in `article-display-face'.
      (if (and wash-face-p (memq 'xface gnus-article-wash-types))
	  ;; We have already displayed X-Faces, so we remove them
	  ;; instead.
	  (gnus-delete-images 'xface)
	;; Display X-Faces.
	(let ((from (message-fetch-field "from"))
	      x-faces)
	  (save-current-buffer
	    (when (and wash-face-p
		       (gnus-buffer-live-p gnus-original-article-buffer)
		       (not (re-search-forward "^X-Face:[\t ]*" nil t)))
	      ;; If type `W f', use gnus-original-article-buffer,
	      ;; otherwise use the current buffer because displaying
	      ;; RFC822 parts calls this function too.
	      (set-buffer gnus-original-article-buffer))
	    (save-restriction
	      (mail-narrow-to-head)
	      (and gnus-article-x-face-command
		   (or force
		       ;; Check whether this face is censored.
		       (not (and gnus-article-x-face-too-ugly
				 (or from
				     (setq from (message-fetch-field "from")))
				 (string-match gnus-article-x-face-too-ugly
					       from))))
		   (while (gnus-article-goto-header "X-Face")
		     (push (mail-header-field-value) x-faces)))))
	  (when x-faces
	    ;; We display the face.
	    (cond ((functionp gnus-article-x-face-command)
		   ;; The command is a lisp function, so we call it.
		   (mapc gnus-article-x-face-command x-faces))
		  ((stringp gnus-article-x-face-command)
		   ;; The command is a string, so we interpret the command
		   ;; as a, well, command, and fork it off.
		   (let ((process-connection-type nil))
		     (set-process-query-on-exit-flag
		      (start-process
		       "article-x-face" nil shell-file-name
		       shell-command-switch gnus-article-x-face-command)
		      nil)
		     ;; Sending multiple EOFs to xv doesn't work,
		     ;; so we only do a single external face.
		     (with-temp-buffer
		       (insert (car x-faces))
		       (process-send-region "article-x-face"
					    (point-min) (point-max)))
		     (process-send-eof "article-x-face")))
		  (t
		   (error "`%s' set to `%s' is not a function"
			  gnus-article-x-face-command
			  'gnus-article-x-face-command)))))))))