Synch to No Gnus 200504280959.
[elisp/gnus.git-] / lisp / gnus-art.el
index 0b80072..c4fee02 100644 (file)
@@ -3015,10 +3015,14 @@ how much time has lapsed since DATE.  For `lapsed', the value of
 should replace the \"Date:\" one, or should be added below it."
   (interactive (list 'ut t))
   (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
-        (date-regexp (if (and gnus-article-date-lapsed-new-header
-                              (eq type 'lapsed))
-                         "^X-Sent:[ \t]"
-                       tdate-regexp))
+        (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
+                            tdate-regexp)
+                           ((eq type 'lapsed)
+                            "^X-Sent:[ \t]")
+                           (article-lapsed-timer
+                            "^Date:[ \t]")
+                           (t
+                            tdate-regexp)))
         (case-fold-search t)
         (inhibit-read-only t)
         (inhibit-point-motion-hooks t)
@@ -3027,17 +3031,15 @@ should replace the \"Date:\" one, or should be added below it."
       (save-restriction
        (widen)
        (goto-char (point-min))
-       (while (and (or (setq date (get-text-property (setq pos (point))
-                                                     'original-date))
-                       (and (setq pos (next-single-property-change
-                                       (point) 'original-date))
-                            (setq date (get-text-property pos
-                                                          'original-date))))
-                   (not (string-equal date "")))
-         (narrow-to-region
-          pos
-          (or (text-property-any pos (point-max) 'original-date nil)
-              (point-max)))
+       (while (or (setq date (get-text-property (setq pos (point))
+                                                'original-date))
+                  (when (setq pos (next-single-property-change
+                                   (point) 'original-date))
+                    (setq date (get-text-property pos 'original-date))
+                    t))
+         (narrow-to-region pos (or (text-property-any pos (point-max)
+                                                      'original-date nil)
+                                   (point-max)))
          (goto-char (point-min))
          (when (re-search-forward tdate-regexp nil t)
            (setq bface (get-text-property (point-at-bol) 'face)
@@ -3219,7 +3221,10 @@ function and want to see what the date was before converting."
        (walk-windows
         (lambda (w)
           (set-buffer (window-buffer w))
-          (when (eq major-mode 'gnus-article-mode)
+          (when (or (and (eq major-mode 'mime-view-mode)
+                         (eq (mime-preview-original-major-mode)
+                             'gnus-original-article-mode))
+                    (eq major-mode 'gnus-article-mode))
             (let ((mark (point-marker)))
               (goto-char (point-min))
               (when (re-search-forward "^X-Sent:" nil t)
@@ -3257,21 +3262,26 @@ This format is defined by the `gnus-article-time-format' variable."
   (interactive (list t))
   (article-date-ut 'iso8601 highlight))
 
-(defun gnus-article-save-original-date ()
-  "Save the original date as a text property."
-  ;;(goto-char (point-max))
-  (skip-chars-backward "\n")
-  (let (start
-       (end (point))
-       (case-fold-search t))
-    (goto-char (point-min))
-    (when (and (re-search-forward "^date:[\t\n ]+" nil t)
-              (progn
-                (setq start (match-end 0))
-                (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)" nil t)))
-      (put-text-property
-       (point-min) end 'original-date
-       (buffer-substring-no-properties start (match-beginning 0))))))
+(defmacro gnus-article-save-original-date (&rest forms)
+  "Save the original date as a text property and evaluate FORMS."
+  `(let* ((case-fold-search t)
+         (start (progn
+                  (goto-char (point-min))
+                  (when (and (re-search-forward "^date:[\t\n ]+" nil t)
+                             (not (bolp)))
+                    (match-end 0))))
+         (date (when (and start
+                          (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
+                                             nil t))
+                 (buffer-substring-no-properties start
+                                                 (match-beginning 0)))))
+     (goto-char (point-max))
+     (skip-chars-backward "\n")
+     (put-text-property (point-min) (point) 'original-date date)
+     ,@forms
+     (goto-char (point-max))
+     (skip-chars-backward "\n")
+     (put-text-property (point-min) (point) 'original-date date)))
 
 ;; (defun article-show-all ()
 ;;   "Show all hidden text in the article buffer."
@@ -4211,8 +4221,7 @@ If ALL-HEADERS is non-nil, no headers are hidden."
                        (if (search-forward "\n\n" nil t)
                            (point)
                          (point-max)))
-      (gnus-article-save-original-date)
-      (gnus-treat-article 'head)
+      (gnus-article-save-original-date (gnus-treat-article 'head))
       (put-text-property (point-min) (point-max) 'article-treated-header t)
       (goto-char (point-max)))
     (while (and (not (eobp)) entity)
@@ -4307,8 +4316,7 @@ If ALL-HEADERS is non-nil, no headers are hidden."
                          (if (search-forward "\n\n" nil t)
                              (point)
                            (point-max)))
-       (gnus-article-save-original-date)
-       (gnus-treat-article 'head)
+       (gnus-article-save-original-date (gnus-treat-article 'head))
        (put-text-property (point-min) (point-max) 'article-treated-header t)
        (goto-char (point-max))
        (widen)
@@ -4434,6 +4442,7 @@ This function is exclusively used by `gnus-mime-save-part-and-strip'
 and `gnus-mime-delete-part', and not provided at run-time normally."
     (gnus-article-edit-article
      `(lambda ()
+       (buffer-disable-undo)
        (erase-buffer)
        (let ((mail-parse-charset (or gnus-article-charset
                                      ',gnus-newsgroup-charset))
@@ -5028,7 +5037,7 @@ N is the numerical prefix."
          (set-window-point window point)))
       (let ((handles ihandles)
            (inhibit-read-only t)
-           handle name type b e display)
+           handle)
        (cond (handles)
              ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
               (when gnus-article-emulate-mime
@@ -5067,8 +5076,8 @@ N is the numerical prefix."
            (save-restriction
              (article-goto-body)
              (narrow-to-region (point-min) (point))
-             (gnus-article-save-original-date)
-             (gnus-treat-article 'head))))))))
+             (gnus-article-save-original-date
+              (gnus-treat-article 'head)))))))))
 
 (defcustom gnus-mime-display-multipart-as-mixed nil
   "Display \"multipart\" parts as  \"multipart/mixed\".