emacs-devel
[Top][All Lists]
Advanced

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

Re: save-frame-excursion?


From: Robert Goldman
Subject: Re: save-frame-excursion?
Date: Fri, 24 Jul 2009 16:18:38 -0500
User-agent: Thunderbird 2.0.0.22 (Macintosh/20090605)

Stefan Monnier wrote:
>>>>> Do you know when/why it lost the focus?
>>>> The org frame lost focus because focus shifted to the frame that
>>>> contained the *Calendar* buffer.
>>> OK, so the next question is "why/when did focus shift to the *Calendar"
>>> buffer" (and just to be more clear by "why/when" I mean at the level of
>>> the Elisp code, which trail of calls causes it).
>> The calendar buffer was configured to be sticky in a particular frame,
>> so that when emacs wanted to show that calendar buffer, it showed it in
>> the different frame.
> 
> That still doesn't explain the shift of focus.
> 
>> I don't entirely understand how the stickiness happens -- configuration
>> of the emacs calendar is far beyond me.
> 
> Doesn't matter.  If the code doesn't explicitly ask for a change in
> focus, then there's no reason (other than to work around a bug
> somewhere, probably) why we need to reset the focus via
> select-frame-set-input-focus when unwinding.
> 
> That's why we need to know the detail.

Well, the calendar has this funny configuration variable:

calendar-setup is a variable defined in `calendar.el'.
Its value is nil


Documentation:
The frame setup of the calendar.
The choices are: `one-frame' (calendar and diary together in one separate,
dedicated frame); `two-frames' (calendar and diary in separate, dedicated
frames); `calendar-only' (calendar in a separate, dedicated frame); with
any other value the current frame is used.  Using any of the first
three options overrides the value of `view-diary-entries-initially'.

You can customize this variable.


So presumably the calendar code at least thinks about frames.  Org-mode
itself only invokes the (calendar) function:

(defun calendar (&optional arg)
  "Choose between the one frame, two frame, or basic calendar displays.
If called with an optional prefix argument, prompts for month and year.

The original function `calendar' has been renamed `calendar-basic-setup'.
See the documentation of that function for more information."
  (interactive "P")
  (cond ((equal calendar-setup 'one-frame) (calendar-one-frame-setup arg))
        ((equal calendar-setup 'two-frames) (calendar-two-frame-setup arg))
        ((equal calendar-setup 'calendar-only)
         (calendar-only-one-frame-setup arg))
        (t (calendar-basic-setup arg))))

There are calls to SELECT-FRAME in the call tree below calendar.  So
this is, I believe, a violation of the generalization about Emacs almost
never changing frame focus explicitly.

I hope this helps.  We are now /way/ out of my area of expertise.  I was
just building some save-and-restore logic around calendar.  I don't have
any first-hand understanding of what goes on inside calendar.

Best,
Robert

> 
>> Admittedly it's unlikely (at least now) to get into a state where you
>> will change the frame focus, but whenever you /do/ change the frame
>> focus, wouldn't you want it restored?
> 
> Emacs almost never changes frame focus explicitly (for the good reason
> that it's mighty hard to do it reliably for all possible WMs).
> 
> 
>         Stefan





reply via email to

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