[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Add function to rotate/transpose all windows
From: |
pranshu sharma |
Subject: |
Re: Add function to rotate/transpose all windows |
Date: |
Sat, 28 Sep 2024 17:52:29 +1000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
martin rudalics <rudalics@gmx.at> writes:
> Sure. I'll wait until the OP approves the concept and was able to make
> use of it.
Hello Martin,
I managed to make remake the transpose frame function without using
reseruct window, and instead used swap-window-states. I still have to
do some cleaning up and error handling tho, eg is still returns error
when you only have one window.
However one thing I'm stuck with it getting it to work with root C-x 2
C-x 3 kinda splits (basiclly where (listp (caddar (window-tree))) is
true). However if you start with no windows, split window once, go to
split window, they you can go crazy with splitting in any direction
(even the C-x 2 C-x 3) and it will work when you call transpose-frame.
This also different from the transpose-windows.el in that it does not
start on a blank slate(transpose-windows.el calls delete-other-windows
in the transpose-frame-set-arrangement), so transposing partial window
trees much easier but I haven't implimented it yet.
---------------------------
;; is there already another inbuilt funcion like this?
(defun deepmap(func ls)
(if (null ls)
()
(cons (if (listp (car ls))
(deepmap func (car ls))
(funcall func (car ls)))
(deepmap func (cdr ls)))))
(defun transpose-frame ()
(interactive)
(let ((fwin (car (window-tree))))
(toggle-window-split
;; We gotta get sizes now, cuz if not then window split mess em
;; up
(deepmap (lambda (e) (if (windowp e)
(cons
e (window-edges e))
e))
(car (window-tree)))
fwin
t)
))
(defun toggle-window-split (subtree cwin &optional nokill)
(pcase-let* ((`(,eee . ,flen) (if (car subtree)
(cons 1 (window-width cwin))
(cons 0 (window-height cwin))))
(ilen (float (- (nth (+ 2 eee) (cadr subtree))
(nth (+ eee 0) (cadr subtree))))))
(mapcar
(pcase-lambda (`(,win . ,size))
(if (listp win)
(progn
(toggle-window-split win (split-window cwin
(- (round (* flen (/ size
ilen))))
(car subtree))))
(progn
(let ((newwin (split-window cwin
(- (round (* flen (/ size ilen))))
(car subtree))))
(window-swap-states newwin win nil)
(delete-window win)))))
(mapcar
(lambda (e)
(pcase-let ((`(,edges ,window?)
(if (windowp (car e))
(list (cdr e) (car e))
(list (cadr e) e))))
(cons window? (- (nth (+ 2 eee) edges)
(nth eee edges)))))
(nreverse (cdddr subtree))))
(unless nokill
(if (windowp (caaddr subtree))
(delete-window (caaddr subtree))
(toggle-window-split (caddr subtree) cwin)))))
---------------------------
- Re: Add function to rotate/transpose all windows, (continued)
- Re: Add function to rotate/transpose all windows, Eli Zaretskii, 2024/09/26
- Re: Add function to rotate/transpose all windows, martin rudalics, 2024/09/27
- Re: Add function to rotate/transpose all windows, Eli Zaretskii, 2024/09/28
- Re: Add function to rotate/transpose all windows, martin rudalics, 2024/09/28
- Re: Add function to rotate/transpose all windows, Eli Zaretskii, 2024/09/28
- Re: Add function to rotate/transpose all windows, martin rudalics, 2024/09/28
- Re: Add function to rotate/transpose all windows, Eli Zaretskii, 2024/09/28
- Re: Add function to rotate/transpose all windows, pranshu sharma, 2024/09/28
- Re: Add function to rotate/transpose all windows, Eli Zaretskii, 2024/09/28
- Re: Add function to rotate/transpose all windows, martin rudalics, 2024/09/28
- Re: Add function to rotate/transpose all windows,
pranshu sharma <=
- Re: Add function to rotate/transpose all windows, martin rudalics, 2024/09/28
- Re: Add function to rotate/transpose all windows, pranshu sharma, 2024/09/28
- Re: Add function to rotate/transpose all windows, martin rudalics, 2024/09/28
- Re: Add function to rotate/transpose all windows, pranshu sharma, 2024/09/29
- Re: Add function to rotate/transpose all windows, martin rudalics, 2024/09/29
- Re: Add function to rotate/transpose all windows, pranshu sharma, 2024/09/29
- Re: Add function to rotate/transpose all windows, martin rudalics, 2024/09/29
- Re: Add function to rotate/transpose all windows, pranshu sharma, 2024/09/30
- Re: Add function to rotate/transpose all windows, martin rudalics, 2024/09/30
- Re: Add function to rotate/transpose all windows, pranshu sharma, 2024/09/28