all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Restore window configuration after Ediff
@ 2011-04-15 22:33 PJ Weisberg
       [not found] ` <yu9y639d2yl.fsf@nyu.edu>
  2011-04-18 17:31 ` Guilherme Gondim
  0 siblings, 2 replies; 8+ messages in thread
From: PJ Weisberg @ 2011-04-15 22:33 UTC (permalink / raw)
  To: help-gnu-emacs

I'm not 100% sure if this is a bug or if I'm trying to do something I
should try to do.  I'm trying to call ediff-buffers and then use a
hook to restore the frame to its original state after Ediff is done.
Here's some sample code:

======================================================================
(defvar saved-configuration nil)

(defun do-ediff()
  (interactive)
  (add-hook 'ediff-quit-hook 'do-ediff-cleanup)
  (setq saved-configuration (current-window-configuration))
  (ediff-buffers "*scratch*" "*scratch*"))

(defun do-ediff-cleanup()
  (set-window-configuration saved-configuration)
  (remove-hook 'ediff-quit-hook 'do-ediff-cleanup))
======================================================================

The problem is that after I quit ediff, the ediff control frame
doesn't always disappear.

I get the behavior I want if I use ediff-after-quit-hook-internal
instead of ediff-quit-hook, but the "internal" part of that name tells
me that's a bad idea.

Is there a better way to accomplish what I'm trying to do?

-PJ



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Restore window configuration after Ediff
@ 2011-04-16  7:36 martin rudalics
  2011-04-16  8:33 ` PJ Weisberg
  0 siblings, 1 reply; 8+ messages in thread
From: martin rudalics @ 2011-04-16  7:36 UTC (permalink / raw)
  To: pj; +Cc: help-gnu-emacs

 > ======================================================================
 > (defvar saved-configuration nil)
 >
 > (defun do-ediff()
 >   (interactive)
 >   (add-hook 'ediff-quit-hook 'do-ediff-cleanup)
 >   (setq saved-configuration (current-window-configuration))
 >   (ediff-buffers "*scratch*" "*scratch*"))
 >
 > (defun do-ediff-cleanup()
 >   (set-window-configuration saved-configuration)
 >   (remove-hook 'ediff-quit-hook 'do-ediff-cleanup))
 > ======================================================================
 >
 > The problem is that after I quit ediff, the ediff control frame
 > doesn't always disappear.

Replace `current-window-configuration' by `current-frame-configuration'
and `set-window-configuration' by `set-frame-configuration'.

martin



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Restore window configuration after Ediff
  2011-04-16  7:36 martin rudalics
@ 2011-04-16  8:33 ` PJ Weisberg
  2011-04-16 10:08   ` martin rudalics
  0 siblings, 1 reply; 8+ messages in thread
From: PJ Weisberg @ 2011-04-16  8:33 UTC (permalink / raw)
  To: martin rudalics; +Cc: help-gnu-emacs

On Sat, Apr 16, 2011 at 12:36 AM, martin rudalics <rudalics@gmx.at> wrote:
>> ======================================================================
>> (defvar saved-configuration nil)
>>
>> (defun do-ediff()
>>   (interactive)
>>   (add-hook 'ediff-quit-hook 'do-ediff-cleanup)
>>   (setq saved-configuration (current-window-configuration))
>>   (ediff-buffers "*scratch*" "*scratch*"))
>>
>> (defun do-ediff-cleanup()
>>   (set-window-configuration saved-configuration)
>>   (remove-hook 'ediff-quit-hook 'do-ediff-cleanup))
>> ======================================================================
>>
>> The problem is that after I quit ediff, the ediff control frame
>> doesn't always disappear.
>
> Replace `current-window-configuration' by `current-frame-configuration'
> and `set-window-configuration' by `set-frame-configuration'.
>
> martin
>

It looks like current-frame-configuration returns a list of all frames
with parameters and window configurations for each of them.  I'd
prefer to just save and restore state of the one frame that was
selected when I started Ediff.

Is there a reason that the code I have *shouldn't* work (besides the
fact that it doesn't)?  I.e., is there a gap in my understanding?

-PJ



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Restore window configuration after Ediff
  2011-04-16  8:33 ` PJ Weisberg
@ 2011-04-16 10:08   ` martin rudalics
  2011-04-16 18:26     ` PJ Weisberg
  0 siblings, 1 reply; 8+ messages in thread
From: martin rudalics @ 2011-04-16 10:08 UTC (permalink / raw)
  To: PJ Weisberg; +Cc: help-gnu-emacs

 > Is there a reason that the code I have *shouldn't* work (besides the
 > fact that it doesn't)?  I.e., is there a gap in my understanding?

I suppose so ;-)

Your code saves and restores the state of one particular frame.  So it
disregards other frames deleted or created within these two actions.
And IIUC your complaint was about the ediff control panel appearing on
some new frame and not being deleted when the window configuration is
restored.

martin



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Restore window configuration after Ediff
  2011-04-16 10:08   ` martin rudalics
@ 2011-04-16 18:26     ` PJ Weisberg
  2011-04-17 10:24       ` martin rudalics
  0 siblings, 1 reply; 8+ messages in thread
From: PJ Weisberg @ 2011-04-16 18:26 UTC (permalink / raw)
  To: martin rudalics; +Cc: help-gnu-emacs@gnu.org

On Saturday, April 16, 2011, martin rudalics <rudalics@gmx.at> wrote:
>> Is there a reason that the code I have *shouldn't* work (besides the
>> fact that it doesn't)?  I.e., is there a gap in my understanding?
>
> I suppose so ;-)
>
> Your code saves and restores the state of one particular frame.  So it
> disregards other frames deleted or created within these two actions.
> And IIUC your complaint was about the ediff control panel appearing on
> some new frame and not being deleted when the window configuration is
> restored.
>
> martin
>

My goal was to save and restore that particular frame without
affecting what would otherwise happen to other frames.  Ediff normally
deletes its control frame, so I want it to do so while I restore the
other frame to the way it was before Ediff was invoked.


-- 

-PJ



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Restore window configuration after Ediff
  2011-04-16 18:26     ` PJ Weisberg
@ 2011-04-17 10:24       ` martin rudalics
  0 siblings, 0 replies; 8+ messages in thread
From: martin rudalics @ 2011-04-17 10:24 UTC (permalink / raw)
  To: PJ Weisberg; +Cc: help-gnu-emacs@gnu.org

 > My goal was to save and restore that particular frame without
 > affecting what would otherwise happen to other frames.  Ediff normally
 > deletes its control frame, so I want it to do so while I restore the
 > other frame to the way it was before Ediff was invoked.

I hope I finally understand what you mean.  The problem seems with
ediff's handling of buffer local variables, current buffers, and
selected windows.  I don't understand that at all :-(

Could you try the following?

(defun do-ediff-cleanup()
   (save-current-buffer
     (save-selected-window
       (set-window-configuration saved-configuration)))
   (remove-hook 'ediff-quit-hook 'do-ediff-cleanup))

martin



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Restore window configuration after Ediff
       [not found] ` <yu9y639d2yl.fsf@nyu.edu>
@ 2011-04-17 18:09   ` PJ Weisberg
  0 siblings, 0 replies; 8+ messages in thread
From: PJ Weisberg @ 2011-04-17 18:09 UTC (permalink / raw)
  To: Allan Gottlieb, help-gnu-emacs

On Sat, Apr 16, 2011 at 7:30 PM, Allan Gottlieb <gottlieb@nyu.edu> wrote:
> On Fri, Apr 15 2011, PJ Weisberg wrote:
>
>> I'm not 100% sure if this is a bug or if I'm trying to do something I
>> should try to do.  I'm trying to call ediff-buffers and then use a
>> hook to restore the frame to its original state after Ediff is done.
>> Here's some sample code:
>>
>> ======================================================================
>> (defvar saved-configuration nil)
>>
>> (defun do-ediff()
>>   (interactive)
>>   (add-hook 'ediff-quit-hook 'do-ediff-cleanup)
>>   (setq saved-configuration (current-window-configuration))
>>   (ediff-buffers "*scratch*" "*scratch*"))
>>
>> (defun do-ediff-cleanup()
>>   (set-window-configuration saved-configuration)
>>   (remove-hook 'ediff-quit-hook 'do-ediff-cleanup))
>> ======================================================================
>>
>> The problem is that after I quit ediff, the ediff control frame
>> doesn't always disappear.
>>
>> I get the behavior I want if I use ediff-after-quit-hook-internal
>> instead of ediff-quit-hook, but the "internal" part of that name tells
>> me that's a bad idea.
>>
>> Is there a better way to accomplish what I'm trying to do?
>>
>> -PJ
>
> I think ediff-cleanup-mess is supposed to remove the control buffer.
> It seems to be by default on ediff-quit-hook.  Do you remove it from the
> hook or stop it from being executed?

Ah-ha!  Figured it out.  My hook has to run *after*
ediff-cleanup-mess, because ediff-cleanup-mess depends on some
buffer-local variables and my code changes which buffer is current.
So adding a third argument to add-hook fixes the problem.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Restore window configuration after Ediff
  2011-04-15 22:33 Restore window configuration after Ediff PJ Weisberg
       [not found] ` <yu9y639d2yl.fsf@nyu.edu>
@ 2011-04-18 17:31 ` Guilherme Gondim
  1 sibling, 0 replies; 8+ messages in thread
From: Guilherme Gondim @ 2011-04-18 17:31 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 313 bytes --]

PJ Weisberg <pj@irregularexpressions.net> writes:

> Is there a better way to accomplish what I'm trying to do?

Maybe using the following functions from register.el (included in GNU Emacs):

  * window-configuration-to-register
  * jump-to-register

Cheers,
semente

-- 
Guilherme Gondim (semente)

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-04-18 17:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-15 22:33 Restore window configuration after Ediff PJ Weisberg
     [not found] ` <yu9y639d2yl.fsf@nyu.edu>
2011-04-17 18:09   ` PJ Weisberg
2011-04-18 17:31 ` Guilherme Gondim
  -- strict thread matches above, loose matches on Subject: below --
2011-04-16  7:36 martin rudalics
2011-04-16  8:33 ` PJ Weisberg
2011-04-16 10:08   ` martin rudalics
2011-04-16 18:26     ` PJ Weisberg
2011-04-17 10:24       ` martin rudalics

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.