Function: article-transform-date

article-transform-date is a byte-compiled function defined in gnus-art.el.gz.

Signature

(article-transform-date DATE TYPE BFACE EFACE)

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-art.el.gz
(defun article-transform-date (date type bface eface)
  (let (begin date-line)
    (dolist (this-type (cond ((null type)
			      (list 'ut))
			     ((atom type)
			      (list type))
			     (t
			      type)))
      (setq begin (point)
	    date-line (article-make-date-line date (or this-type 'ut)))
      (if (and (eq this-type 'user-defined) (bolp)
	       ;; Test if this is not a continuation.
	       (not (get-text-property
		     (prog2 (end-of-line 0) (point) (goto-char begin))
		     'gnus-date-type)))
	  (progn
	    (string-match "\\`\\([^\t\n :]+:\\)?[\t ]*" date-line)
	    (if (match-beginning 1)
		(insert date-line "\n")
	      ;; This user-defined date seems to intend to be a continuation
	      ;; line of a multi-line Date header like this:
	      ;;   Date: Thu, Jan  1 00:00:00 1970 +0000
	      ;;    (47 years, 5 months, 20 days ago)
	      (insert "Date: " (substring date-line (match-end 0)) "\n")))
	(insert date-line "\n"))
      (add-text-properties begin (point) (list 'original-date date
					       'gnus-date-type this-type))
      (goto-char begin)
      ;; Do highlighting.
      (beginning-of-line)
      (looking-at
       "\\([^\n:]+:\\)?[\t ]*\\(\\(?:[^\t\n ]+[\t ]+\\)*[^\t\n ]+\\)?")
      (when (and bface (match-beginning 1))
	(put-text-property (match-beginning 1) (match-end 1) 'face bface))
      (when (match-beginning 2)
	(when eface
	  (put-text-property (match-beginning 2) (match-end 2) 'face eface))
	(while (and (zerop (forward-line 1))
		    (looking-at
		     "[\t ]+\\(\\(?:[^\t\n ]+[\t ]+\\)*[^\t\n ]+\\)?"))
	  (when (and eface (match-beginning 1))
	    (put-text-property (match-beginning 1) (match-end 1)
			       'face eface)))))))