Subject: Re: bug#16257: 24.3.50; calendar-cursor-to-visible-date needs set-window-point

From: Stefan Monnier <[email-masked]>
Date: Fri, 03 Jan 2014 17:25:09 -0500

tags 16257 notabug
thanks

> Here is the thread on stackoverflow that provides a working example of
> the problem, and a working solution:

> http://stackoverflow.com/questions/20776564/how-to-use-calendar-cursor-to-visible-date-without-switching-to-calendar

The question is not clear.  E.g.:

   "I would like the function to work without actually switching to the
   calendar window -- i.e., it should work even when the buffer is buried."

While we clearly can't select the calendar window if the calendar is
not displayed, I don't see why that would make it undesirable to
temporarily select that window when it does exist.  E.g.

   (with-selected-window (or (get-buffer-window (current-buffer) 0)
                             (selected-window))
     (calendar-cursor-to-visible-date date))

Of course, if there are various windows displaying that buffer, things
are more interesting.

> Without adding `set-window-point` to the function
> `calendar-cursor-to-visible-date`, functions like
> `with-current-buffer` and `set-buffer` do not work properly.

Those work just fine (although they don't quite do what you think they do).

> From another window, it should be possible to use
> `calendar-cursor-to-visible-date` without actually switching to that
> "*Calendar*" buffer.

Here I lost you again.  calendar-cursor-to-visible-date works inside the
calendar buffer, so you can't use it without switching to the
*Calendar* buffer.  But that's unrelated to whether or not you select
the corresponding window (if any).

        Stefan