[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: diary-redraw-calendar clobbers point in diary-file buffer.

From: Glenn Morris
Subject: Re: diary-redraw-calendar clobbers point in diary-file buffer.
Date: Fri, 11 Mar 2005 22:01:56 +0000
User-agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)

Matt Hodges wrote:

> Anyway, I've briefly tested the attached patch (including your
> calendar-redrawing stuff), and it seems OK, so far.

I installed the redrawing stuff, since I'm pretty sure that's a Good
Thing regardless.

Many thanks for the patch. I'm not trying to be deliberately obtuse,
but I don't really see how your portions of it could relate to the
bugs that have been reported recently.

 (defun redraw-calendar ()
   "Redraw the calendar display, if `calendar-buffer' is live."
   (if (get-buffer calendar-buffer)
-      (save-excursion
+      (let (posn window)
         (with-current-buffer calendar-buffer
-          (let ((cursor-date (calendar-cursor-to-nearest-date)))
+          (let ((cursor-date (calendar-cursor-to-nearest-date))
+                (calendar-redrawing t))
             (generate-calendar-window displayed-month displayed-year)
-            (calendar-cursor-to-visible-date cursor-date))))))
+            (calendar-cursor-to-visible-date cursor-date))
+          (setq posn (point)))
+        (setq window (get-buffer-window calendar-buffer))
+       (when (and window
+                  (not (eq window (selected-window))))
+         (set-window-point window posn)))))

OK, so when generate-calendar erases the calendar buffer, window point
gets set to 1 and never moves back. You explictly set it back to the
cursor-date position. Isn't this purely cosmetic though? I don't see
how it could ever cause a bug of the recently reported kind. All lisp
commands will use the buffer point rather than the window point.
Someone would have to select the calendar window part-way through an
operation for this to cause a problem. I don't see any instance in
calendar.el that could do that.

And (trivially) what if the calendar window is in a different frame,
or there is more than one calendar window?

 (defun diary-redraw-calendar ()
   "If `calendar-buffer' is live and diary entries are marked, redraw it."
   (and mark-diary-entries-in-calendar
-       (redraw-calendar))
+       (save-excursion
+         (redraw-calendar)))
   ;; Return value suitable for `write-contents-functions'.

This function is only called when the diary is saved after, eg, "i d".
So I also don't see how this function could have caused any kind of
bug at calendar start-up.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]