Skip to content

Commit

Permalink
Preserving the split state after (de)activation of ECB
Browse files Browse the repository at this point in the history
  • Loading branch information
berndl committed Sep 8, 2003
1 parent 9b31eb2 commit 929ff62
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 19 deletions.
6 changes: 5 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@
auto. selected in the ECB-directories buffer and the ECB-sources buffer
displays the contents of this directory. See new option
`ecb-display-default-dir-after-start'.


** ECB preserves the split-state of the frame after activation rsp. deactivation
This is done if the already existing option `ecb-split-edit-window' has the
new value t.

** New command `ecb-toggle-window-sync' for fast toggling between autom.
synchronization of the ECB-buffers is switched on and off.

Expand Down
11 changes: 6 additions & 5 deletions ecb-layout.el
Original file line number Diff line number Diff line change
Expand Up @@ -432,12 +432,13 @@ frame-height)."
:value half)
(number :tag "Height" :value 0.3)))

(defcustom ecb-split-edit-window nil
(defcustom ecb-split-edit-window t
"*Sets how and if the edit window should be splitted.
But be aware: This option determines only if the edit-window should be
splitted at start-time of ECB."
:group 'ecb-layout
:type '(radio (const :tag "Split horizontally"
:type '(radio (const :tag "Split as before ECB-start" :value t)
(const :tag "Split horizontally"
:value horizontal)
(const :tag "Split vertically"
:value vertical)
Expand Down Expand Up @@ -3449,9 +3450,9 @@ this function the edit-window is selected which was current before redrawing."
(or (and compile-buffer-before-redraw
(ecb-compilation-buffer-p compile-buffer-before-redraw))
(some (function (lambda (buf)
(and (ecb-compilation-buffer-p buf)
(not (string= "*Completions*"
(buffer-name buf))))))
(and (not (string= "*Completions*"
(buffer-name buf)))
(ecb-compilation-buffer-p buf))))
(buffer-list ecb-frame))
(get-buffer-create "*scratch*"))))

Expand Down
74 changes: 61 additions & 13 deletions ecb.el
Original file line number Diff line number Diff line change
Expand Up @@ -5415,8 +5415,6 @@ always the ECB-frame if called from another frame."

;; enable basic advices
(ecb-enable-advices ecb-basic-adviced-functions)
;; enable window-function advices
(ecb-activate-adviced-functions ecb-advice-window-functions)

;; set the ecb-frame
(if ecb-new-ecb-frame
Expand Down Expand Up @@ -5675,23 +5673,47 @@ always the ECB-frame if called from another frame."
"Errors during the hooks of ecb-activate-before-layout-draw-hook.")))

(setq ecb-minor-mode t)


;; now we draw the screen-layout of ECB. We try to preserve the
;; split-state but only if the frame is splitted in two windows. More
;; windows can not be preserved because ECB can only split its edit-area
;; in two windows.
(condition-case nil
(progn
(let ((win-list (ecb-window-list ecb-frame 0 (frame-first-window ecb-frame)))
buf-1 buf-2 split first-win-selected)
(if (= (length win-list) 2)
(setq buf-1 (window-buffer (nth 0 win-list))
buf-2 (window-buffer (nth 1 win-list))
split (if (= (car (ecb-window-edges (nth 0 win-list)))
(car (ecb-window-edges (nth 1 win-list))))
'vertical
'horizontal)
first-win-selected (equal (selected-window) (nth 0 win-list))))
;; now we draw the layout chosen in `ecb-layout'. This function
;; activates at its end also the adviced functions if necessary!
;; Here are the directories- and history-buffer updated.
(let ((ecb-redraw-layout-quickly nil))
(ecb-redraw-layout-full 'no-buffer-sync))

(ecb-with-adviced-functions
;; activate the correct edit-window split
(cond ((equal ecb-split-edit-window 'vertical)
(split-window-vertically))
((equal ecb-split-edit-window 'horizontal)
(split-window-horizontally))
((not ecb-split-edit-window)
(delete-other-windows))))
(delete-other-windows))
(t
(cond ((equal split 'vertical)
(split-window-vertically))
((equal split 'horizontal)
(split-window-horizontally)))
(when split
(set-window-buffer ecb-edit-window buf-1)
(set-window-buffer (next-window ecb-edit-window)
buf-2)
(ecb-select-edit-window (not first-win-selected))
))))

;; now we synchronize all ECB-windows
(ecb-current-buffer-sync 'force)
Expand Down Expand Up @@ -5863,16 +5885,42 @@ does all necessary after finishing ediff."
(unless run-no-hooks
(run-hooks 'ecb-deactivate-hook))

;; clear the ecb-frame
;; clear the ecb-frame. Here we try to preserve the split-state after
;; deleting the ECB-screen-layout.
(when (frame-live-p ecb-frame)
(raise-frame ecb-frame)
(select-frame ecb-frame)
(ecb-select-edit-window)
;; first we delete all ECB-windows.
(delete-other-windows)
(if (get 'ecb-frame 'ecb-new-frame-created)
(ignore-errors (delete-frame ecb-frame t))))

(condition-case nil
(let* ((split (ecb-edit-window-splitted))
(buf-1 (window-buffer ecb-edit-window))
(buf-2 (if split (window-buffer (next-window ecb-edit-window))))
(sel-win (ecb-point-in-edit-window)))
;; first we delete all ECB-windows.
(ecb-select-edit-window)
(mapc (function (lambda (w)
(set-window-dedicated-p w nil)))
(ecb-window-list ecb-frame 0))
(delete-other-windows)
(set-window-dedicated-p (selected-window) nil)
;; now we try to restore the split-state
(cond ((equal split 'vertical)
(split-window-vertically))
((equal split 'horizontal)
(split-window-horizontally)))
(when split
(set-window-buffer (selected-window) buf-1)
(set-window-buffer (next-window (selected-window))
buf-2)
(if (and sel-win
(= sel-win 2))
(select-window (next-window)))))
(error
;; in case of an error we delete at least all other windows.
(ignore-errors (delete-other-windows))))

(if (get 'ecb-frame 'ecb-new-frame-created)
(ignore-errors (delete-frame ecb-frame t))))

(ecb-initialize-layout)

;; we can safely do the kills because killing non existing buffers
Expand Down

0 comments on commit 929ff62

Please sign in to comment.