>>>>> Glenn Morris writes:

 > > This save-excursion can't do anything meaningful to preserve
 > > point in the calendar buffer can it?

 > No, it's complete rubbish! As you and Stefan pointed (ahem) out,
 > I'm saving point in the calling buffer, not the calendar. Being
 > extra dim this week, sorry.

 > But I don't understand what's going on here.

 > The final calendar-cursor-to-visible-date in redraw-calendar should
 > mean that no saving of point is necessary (once the save-excursion
 > is deleted completely, that only messes things up).

As Johan Bockg�rd points out, "The buffer's point and the window's
point (cursor) aren't necessarily the same thing."

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

Thanks,

Matt

cvs diff: Diffing .
Index: cal-move.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/calendar/cal-move.el,v
retrieving revision 1.9
diff -u -r1.9 cal-move.el
--- cal-move.el	1 Sep 2003 15:45:19 -0000	1.9
+++ cal-move.el	10 Mar 2005 10:40:19 -0000
@@ -311,8 +311,9 @@
 		       (* 3 (mod
                              (- (calendar-day-of-week date)
                                 calendar-week-start-day)
-                             7))))))
-
+                             7)))))
+  (point))
+  
 (defun calendar-goto-date (date)
   "Move cursor to DATE."
   (interactive (list (calendar-read-date)))
Index: calendar.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/calendar/calendar.el,v
retrieving revision 1.163
diff -u -r1.163 calendar.el
--- calendar.el	9 Mar 2005 00:28:22 -0000	1.163
+++ calendar.el	10 Mar 2005 10:40:19 -0000
@@ -2150,15 +2150,24 @@
 	  (forward-line 1))))
   t)
 
+(defvar calendar-redrawing nil
+  "Internal calendar variable, non-nil if inside redraw-calendar.")
+
 (defun redraw-calendar ()
   "Redraw the calendar display, if `calendar-buffer' is live."
   (interactive)
   (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)))))
 
 ;;;###autoload
 (defcustom calendar-week-start-day 0
Index: diary-lib.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/calendar/diary-lib.el,v
retrieving revision 1.90
diff -u -r1.90 diary-lib.el
--- diary-lib.el	9 Mar 2005 00:29:14 -0000	1.90
+++ diary-lib.el	10 Mar 2005 10:40:19 -0000
@@ -846,7 +846,8 @@
              ;; Avoid redrawing when called recursively, eg through
              ;; mark-diary-entries-hook for #include's, else only get
              ;; the last set of diary marks.
-             (not marking-diary-entries))
+             (not marking-diary-entries)
+             (not calendar-redrawing))
     (setq mark-diary-entries-in-calendar nil)
     (redraw-calendar))
   (let ((marking-diary-entries t)
@@ -1658,7 +1659,8 @@
 (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'.
   nil)
 
_______________________________________________
Emacs-pretest-bug mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug

Reply via email to