help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: MY window tree!


From: martin rudalics
Subject: Re: MY window tree!
Date: Tue, 16 Jan 2007 08:46:25 +0100
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

> 1) I think I must search all buffers

No.  Only the buffers that have an ovlwin-window association.

> 2) I must check all overlays in these buffers

Yes (unfortunately) but _only_ in the buffers mentioned above.

> 3) The only thing I have to check in the overlays is the 'window prop

Yes.

> 4) I only have to care if the prop value is a window in the saved tree

Yes.

> 5) If that window is not on a frame any more I just replace the value

Together steps 1) and 4) assert that the window is not on a frame any
more, hence, you don't have to check this.

> 6) Otherwise I make a new overlay -- seldom

_Never_ make a new overlay.

> The above is what I am doing. Is any of those points incorrect in your
> opinion? Here is the code:
>
>     (dolist (buf (buffer-list))

`buffer-list' is bad.  I'd use something like

(dolist (buf (let (buffer buffers)
               (dolist (win win-list buffers)
                 ;; I presume cadr refers to the "new" window.
                 (setq buffer (window-buffer (cadr win)))
                 (unless (memq buffer buffers)
                   (setq buffers (cons buffer buffers))))))
  ...

>       (with-current-buffer buf
>         (save-restriction
>           (widen)
>           (dolist (overlay (overlays-in (point-min) (point-max)))
>             (when (setq ovlwin (car (memq (overlay-get overlay 'window)
> oldwins)))
>               (setq window (cadr (assoc ovlwin win-list)))
>               ;; If the old window is still alive then copy overlay,
>               ;; otherwise change the 'window prop.

This should be something along the (100% incorrect)

(dolist (overlay (overlays-in (point-min) (point-max)))
  (when (setq window (cadr (assoc (overlay-get overlay 'window))
                           win-list))
    (overlay-put overlay 'window window)))

If the old window is still alive don't do anything.  Windows that
survived the reconfiguration should not be on `win-list'.

>               (if (not (and (window-live-p ovlwin)
>                             (window-frame ovlwin)))
>                    ....
>
> `oldwins' is a list with the old windows, ie the windows in the saved tree.

> I believe it would be possible to right code to manipulate the internal
> tree as above. A solution building on that would probably use the
> resizing part from my elisp solution (or something similar).

The only time and space consuming operation is finding the overlays and
changing their property.  There's nothing you can do about that.  Note
that current solutions (like `edebug-current-windows') ignore overlays
(and many other things like dedicated windows) completely.  This could
be corrected with your algorithm, provided the save/restore step occurs
smoothly.

For `desktop-save', on the other hand, you should think of an option to
ignore overlays, though.  Storing overlays on disk is hardly conceivable
as long as we don't even bother to save text properties.





reply via email to

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