Ensure that point stays at the "same place" even if point is on the line being replaced.
authorLars Magne Ingebrigtsen <larsi@gnus.org>
Thu, 27 Jan 2011 23:04:14 +0000 (15:04 -0800)
committerLars Magne Ingebrigtsen <larsi@gnus.org>
Thu, 27 Jan 2011 23:04:14 +0000 (15:04 -0800)
lisp/ChangeLog
lisp/gnus-art.el

index 37fe099..9842acd 100644 (file)
@@ -1,3 +1,8 @@
+2011-01-27  Lars Ingebrigtsen  <larsi@gnus.org>
+
+       * gnus-art.el (article-update-date-lapsed): Ensure that point stays at
+       the "same place" even if point is on the line being replaced.
+
 2011-01-27  Julien Danjou  <julien@danjou.info>
 
        * mml2015.el (mml2015-epg-sign): Add and use mml2015-sign-with-sender.
index 327250e..c72c2fe 100644 (file)
@@ -3674,19 +3674,27 @@ function and want to see what the date was before converting."
   "Function to be run from a timer to update the lapsed time line."
   (save-match-data
     (let (deactivate-mark)
-      (save-excursion
+      (save-window-excursion
        (ignore-errors
         (walk-windows
          (lambda (w)
            (set-buffer (window-buffer w))
            (when (eq major-mode 'gnus-article-mode)
-             (let ((mark (point-marker)))
+             (let ((mark (point-marker))
+                   (old-point (point)))
                (goto-char (point-min))
                (when (re-search-forward "^X-Sent:\\|^Date:" nil t)
+                 ;; If the point is on the Date line, then use that
+                 ;; absolute position.  Otherwise, use the mark.
+                 ;; This will ensure that point stays at the "same
+                 ;; place".
+                 (when (or (< old-point (match-beginning 0))
+                           (> old-point (line-end-position)))
+                   (setq old-point nil))
                  (if gnus-treat-date-combined-lapsed
                      (article-date-combined-lapsed t)
                    (article-date-lapsed t)))
-               (goto-char (marker-position mark))
+               (goto-char (or old-point (marker-position mark)))
                (move-marker mark nil))))
          nil 'visible))))))