aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorKatsumi Yamaoka2013-06-04 08:14:23 +0000
committerKatsumi Yamaoka2013-06-04 08:14:23 +0000
commit923c1bfc1e100f993f5acaca89051f14aa5fb4f6 (patch)
tree0fa752982fdf9492357a26875bcc052b3c83b34f /lisp
parentc362f1950814689b0a6f03f0fa48b07784b90a16 (diff)
downloademacs-923c1bfc1e100f993f5acaca89051f14aa5fb4f6.tar.gz
emacs-923c1bfc1e100f993f5acaca89051f14aa5fb4f6.zip
gnus-art.el: Don't assume Date header begins with "Date"
Diffstat (limited to 'lisp')
-rw-r--r--lisp/gnus/ChangeLog7
-rw-r--r--lisp/gnus/gnus-art.el104
2 files changed, 68 insertions, 43 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 59e3e398788..0156894c902 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,10 @@
12013-06-04 Katsumi Yamaoka <yamaoka@jpl.org>
2
3 * gnus-art.el (article-date-ut, article-update-date-lapsed): Don't
4 assume Date header begins with "Date", that may be customized into
5 something like "X-Sent" using gnus-article-time-format.
6 (article-transform-date): Allow multi-line Date header.
7
12013-06-02 David Engster <deng@randomsample.de> 82013-06-02 David Engster <deng@randomsample.de>
2 9
3 * registry.el (initialize-instance, registry-lookup) 10 * registry.el (initialize-instance, registry-lookup)
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index 23603bc7722..65f4b76ad19 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -3430,15 +3430,13 @@ possible values."
3430 (visible-date (mail-fetch-field "Date")) 3430 (visible-date (mail-fetch-field "Date"))
3431 pos date bface eface) 3431 pos date bface eface)
3432 (save-excursion 3432 (save-excursion
3433 (goto-char (point-min))
3434 (when (re-search-forward "^Date:" nil t)
3435 (setq bface (get-text-property (point-at-bol) 'face)
3436 eface (get-text-property (1- (point-at-eol)) 'face)))
3437 ;; Delete any old Date headers.
3438 (if date-position 3433 (if date-position
3439 (progn 3434 (progn
3440 (goto-char date-position) 3435 (goto-char date-position)
3441 (setq date (get-text-property (point) 'original-date)) 3436 (setq date (get-text-property (point) 'original-date))
3437 (when (looking-at "[^:]+:[\t ]*")
3438 (setq bface (get-text-property (match-beginning 0) 'face)
3439 eface (get-text-property (match-end 0) 'face)))
3442 (delete-region (point) 3440 (delete-region (point)
3443 (progn 3441 (progn
3444 (gnus-article-forward-header) 3442 (gnus-article-forward-header)
@@ -3454,12 +3452,26 @@ possible values."
3454 (narrow-to-region pos (if (search-forward "\n\n" nil t) 3452 (narrow-to-region pos (if (search-forward "\n\n" nil t)
3455 (1+ (match-beginning 0)) 3453 (1+ (match-beginning 0))
3456 (point-max))) 3454 (point-max)))
3457 (goto-char (point-min)) 3455 (while (setq pos (text-property-not-all pos (point-max)
3458 (while (re-search-forward "^Date:" nil t) 3456 'gnus-date-type nil))
3459 (setq date (get-text-property (match-beginning 0) 'original-date)) 3457 (setq date (get-text-property pos 'original-date))
3460 (delete-region (point-at-bol) (progn 3458 (goto-char pos)
3461 (gnus-article-forward-header) 3459 (when (looking-at "[^:]+:[\t ]*")
3462 (point)))) 3460 (setq bface (get-text-property (match-beginning 0) 'face)
3461 eface (get-text-property (match-end 0) 'face)))
3462 (delete-region pos (or (text-property-any pos (point-max)
3463 'gnus-date-type nil)
3464 (point-max))))
3465 (unless date ;; the 1st time
3466 (goto-char (point-min))
3467 (while (re-search-forward "^Date:[\t ]*" nil t)
3468 (setq date (get-text-property (match-beginning 0)
3469 'original-date)
3470 bface (get-text-property (match-beginning 0) 'face)
3471 eface (get-text-property (match-end 0) 'face))
3472 (delete-region (point-at-bol) (progn
3473 (gnus-article-forward-header)
3474 (point)))))
3463 (when (and (not date) 3475 (when (and (not date)
3464 visible-date) 3476 visible-date)
3465 (setq date visible-date)) 3477 (setq date visible-date))
@@ -3476,20 +3488,25 @@ possible values."
3476 (list type)) 3488 (list type))
3477 (t 3489 (t
3478 type))) 3490 type)))
3479 (insert (article-make-date-line date (or this-type 'ut)) "\n") 3491 (goto-char
3480 (forward-line -1) 3492 (prog1
3481 (beginning-of-line) 3493 (point)
3482 (put-text-property (point) (1+ (point)) 3494 (add-text-properties
3483 'original-date date) 3495 (point)
3484 (put-text-property (point) (1+ (point)) 3496 (progn
3485 'gnus-date-type this-type) 3497 (insert (article-make-date-line date (or this-type 'ut)) "\n")
3498 (point))
3499 (list 'original-date date 'gnus-date-type this-type))))
3486 ;; Do highlighting. 3500 ;; Do highlighting.
3487 (when (looking-at "\\([^:]+\\): *\\(.*\\)$") 3501 (when (looking-at
3488 (put-text-property (match-beginning 1) (1+ (match-end 1)) 3502 "\\([^:]+:\\)[\t ]*\\(\\(?:[^\t\n ]+[\t ]+\\)*[^\t\n ]+\\)?")
3489 'face bface) 3503 (put-text-property (match-beginning 1) (match-end 1) 'face bface)
3490 (put-text-property (match-beginning 2) (match-end 2) 3504 (when (match-beginning 2)
3491 'face eface)) 3505 (put-text-property (match-beginning 2) (match-end 2) 'face eface))
3492 (forward-line 1))) 3506 (while (and (zerop (forward-line 1))
3507 (looking-at "[\t ]+\\(\\(?:[^\t\n ]+[\t ]+\\)*[^\t\n ]+\\)?"))
3508 (when (match-beginning 1)
3509 (put-text-property (match-beginning 1) (match-end 1) 'face eface))))))
3493 3510
3494(defun article-make-date-line (date type) 3511(defun article-make-date-line (date type)
3495 "Return a DATE line of TYPE." 3512 "Return a DATE line of TYPE."
@@ -3669,25 +3686,26 @@ function and want to see what the date was before converting."
3669 (when (eq major-mode 'gnus-article-mode) 3686 (when (eq major-mode 'gnus-article-mode)
3670 (let ((old-line (count-lines (point-min) (point))) 3687 (let ((old-line (count-lines (point-min) (point)))
3671 (old-column (- (point) (line-beginning-position))) 3688 (old-column (- (point) (line-beginning-position)))
3672 (window-start 3689 (window-start (window-start w))
3673 (window-start (get-buffer-window (current-buffer))))) 3690 (pos (point-min))
3674 (goto-char (point-min)) 3691 type next end)
3675 (while (re-search-forward "^Date:" nil t) 3692 (while (setq pos (text-property-not-all pos (point-max)
3676 (let ((type (get-text-property (match-beginning 0) 3693 'gnus-date-type nil))
3677 'gnus-date-type))) 3694 (setq next (or (next-single-property-change pos
3678 (when (memq type '(lapsed combined-lapsed user-format)) 3695 'gnus-date-type)
3679 (when (and window-start 3696 (point-max)))
3680 (not (= window-start 3697 (setq type (get-text-property pos 'gnus-date-type))
3681 (save-excursion 3698 (when (memq type '(lapsed combined-lapsed user-defined))
3682 (forward-line 1) 3699 (article-date-ut type t pos)
3683 (point))))) 3700 (setq end (or (next-single-property-change pos
3684 (setq window-start nil)) 3701 'gnus-date-type)
3685 (save-excursion 3702 (point-max)))
3686 (article-date-ut type t (match-beginning 0))) 3703 (when window-start
3687 (forward-line 1) 3704 (if (/= window-start next)
3688 (when window-start 3705 (setq window-start nil)
3689 (set-window-start (get-buffer-window (current-buffer)) 3706 (set-window-start w end)))
3690 (point)))))) 3707 (setq next end))
3708 (setq pos next))
3691 (goto-char (point-min)) 3709 (goto-char (point-min))
3692 (when (> old-column 0) 3710 (when (> old-column 0)
3693 (setq old-line (1- old-line))) 3711 (setq old-line (1- old-line)))